devianceone
Lua Scripter
- Joined
- Jan 24, 2009
- Messages
- 756
- Reaction score
- 28
I have a problem, I'm writing a script that uses a global event, activated every 2 seconds which has a check to see if a event is active or not before executing the code..
tpIsActive() was at first was the code below, always returning true if I had my global storage set to 1 or higher, else sending false.
After about 15-20 minutes, I always get a error about attempting to compare a string to a bool, this means tpIsActive, which should always return a bool, returned a string instead.
I changed the code up to see what was happening and set it to
Again, after 20 minutes I got my error message, it was a string containing weird characters.
Can anyone explain to me whats going on? Why does grabbing global storages, or functions sometimes return a string to me usually at the 15-20 minute mark? The script will work fine after I handle the potential errors, functions return values as normal.
0.4dev, r3884
Code:
if tpIsActive() == false or tpIsWaiting() == true then
return true
end
Code:
return getStorage(ThePlague.Config.gsGameIsActive) > 0
After about 15-20 minutes, I always get a error about attempting to compare a string to a bool, this means tpIsActive, which should always return a bool, returned a string instead.
I changed the code up to see what was happening and set it to
Code:
function tpIsActive()
local isActive = getStorage(ThePlague.Config.gsGameIsActive)
if type(isActive) == "number" then
if tonumber(isActive) >= 1 then
return true
else
return false
end
else
print("[ THE PLAGUE ] Error: isActive returned a non number! [" .. tostring(isActive) .. ", type: " .. tostring(type(isActive)) .. "]")
return false
end
return false
end
Code:
[ THE PLAGUE ] Error: isActive returned a non number! [└ -, type: string]
Can anyone explain to me whats going on? Why does grabbing global storages, or functions sometimes return a string to me usually at the 15-20 minute mark? The script will work fine after I handle the potential errors, functions return values as normal.
0.4dev, r3884