Originally Posted by votan
I think the problem is the DoesScriptNameExist function.
CLICK4INFO.sv.scripts is a indexed table (using table.insert)
The function should be like this:
Lua Code:
local function DoesScriptNameExist(scriptName) local scripts = CLICK4INFO.sv.scripts for _, script in ipairs(scripts) do if script.scriptName == scriptName then return true end end return false end
CU
|
Or you can replace table.insert and remove whole DoesScriptNameExist function:
Lua Code:
function Click4Info_AddScript(self)
local scriptName = CLICK4INFO.nameEditBox:GetText()
local script = CLICK4INFO.scriptEditBox:GetText()
if not script or script == "" then return end
if not scriptName or scriptName == "" then
scriptName = "New Script"
end
debugMsg("Adding Script")
local scripts = CLICK4INFO.sv.scripts
local uniqueScriptName = scriptName
local counter = 1
while scripts[uniqueScriptName] ~= nil do
uniqueScriptName = ("%s (%d)"):format(scriptName, counter)
counter = counter + 1
end
scripts[uniqueScriptName] = script
end