Version 2.2.1 - updated market, text editor, bot

This commit is contained in:
OTCv8
2020-04-02 06:47:02 +02:00
parent 932165111d
commit ed8162a9d5
20 changed files with 263 additions and 163 deletions

View File

@@ -146,6 +146,10 @@ context.onChannelEvent = function(callback)
return context.callback("onChannelEvent", callback)
end
-- onTurn -- callback = function(creature, direction)
context.onTurn = function(callback)
return context.callback("onTurn", callback)
end
-- CUSTOM CALLBACKS

View File

@@ -166,7 +166,7 @@ Config.setup = function(dir, widget, configExtension, callback)
end
widget.add.onClick = function()
context.UI.SinglelineEditorWindow("config_name", function(name)
context.UI.SinglelineEditorWindow("config_name", {title="Enter config name"}, function(name)
name = name:gsub("%s+", "_")
if name:len() == 0 or name:len() >= 30 or name:find("/") or name:find("\\") then
return context.error("Invalid config name")
@@ -185,8 +185,7 @@ Config.setup = function(dir, widget, configExtension, callback)
widget.edit.onClick = function()
local name = context.storage._configs[dir].selected
if not name then return end
context.UI.MultilineEditorWindow("Config editor - " .. name .. " in " .. dir,
Config.loadRaw(dir, name), function(newValue)
context.UI.MultilineEditorWindow(Config.loadRaw(dir, name), {title="Config editor - " .. name .. " in " .. dir}, function(newValue)
local data = Config.parse(newValue)
Config.save(dir, name, data, configExtension)
refresh()

View File

@@ -4,12 +4,31 @@ if type(context.UI) ~= "table" then
end
local UI = context.UI
UI.SinglelineEditorWindow = function(text, callback)
return modules.game_textedit.singlelineEditor(text, callback)
UI.EditorWindow = function(text, options, callback)
--[[
Available options:
title = text
description = text
multiline = true / false
width = number
validation = text (regex)
examples = {{name, text}, {name, text}}
]]--
local window = modules.game_textedit.edit(text, options, callback)
window.botWidget = true
return window
end
UI.MultilineEditorWindow = function(description, test, callback)
return modules.game_textedit.multilineEditor(description, test, callback)
UI.SinglelineEditorWindow = function(text, options, callback)
options = options or {}
options.multiline = false
return UI.EditorWindow(text, options, callback)
end
UI.MultilineEditorWindow = function(text, options, callback)
options = options or {}
options.multiline = true
return UI.EditorWindow(text, options, callback)
end
UI.ConfirmationWindow = function(title, question, callback)