• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved Bug in globalevents?

silveralol

Advanced OT User
Joined
Mar 16, 2010
Messages
1,484
Solutions
9
Reaction score
217
hello! I'm trying make a script that load map with a rand
my simple code
Code:
function onStartup()
    local rand = Game.setStorageValue(GlobalStorage.Teste, math.random(3))
    if rand == 1 then
        Game.loadMap("data/world/teste/1.otbm")
        print("test1")
   elseif rand == 2 then
        Game.loadMap("data/world/teste/2.otbm")
        print("test2")
    elseif rand == 3 then
        Game.loadMap("data/world/teste/3.otbm")
        print("test3")
    end
    return true
end
but the code not load the map and not print my tests

USING TFS 1.2!!!!

maybe @Printer or @WibbenZ know how fix it :3
 
Last edited:
hello! I'm trying make a script that load map with a rand
my simple code
Code:
function onStartup()
    local rand = Game.setStorageValue(GlobalStorage.Teste, math.random(3))
    if rand == 1 then
        Game.loadMap("data/world/teste/1.otbm")
        print("test1")
   elseif rand == 2 then
        Game.loadMap("data/world/teste/2.otbm")
        print("test2")
    elseif rand == 3 then
        Game.loadMap("data/world/teste/3.otbm")
        print("test3")
    end
    return true
end
but the code not load the map and not print my tests

USING TFS 1.2!!!!

maybe @Printer or @WibbenZ know how fix it :3
PHP:
local rand = Game.setStorageValue(GlobalStorage.Teste, math.random(3))
should be:
PHP:
local rand = math.random(3)
Game.setStorageValue(GlobalStorage.Teste, rand)
You tried to use 'result of storage save' as 'rand'.



-------------------------------------
Game.setStorageValue returns 'nil', it's not 1/2/3 :)
I would check, if Game.setStorageValue works fine in TFS 1.2 (or ask some TFS 1.2 developer), because in old TFSes code that TFS 1.2 uses, would separate storages for each 'data' folder (if you setStorageValue in 'movements' it's still 'nil' in 'actions').
 
Last edited:
PHP:
local rand = Game.setStorageValue(GlobalStorage.Teste, math.random(3))
should be:
PHP:
local rand = math.random(3)
Game.setStorageValue(GlobalStorage.Teste, rand)
You tried to use 'result of storage save' as 'rand'.



-------------------------------------
Game.setStorageValue returns 'nil', it's not 1/2/3 :)
I would check, if Game.setStorageValue works fine in TFS 1.2 (or ask some TFS 1.2 developer), because in old TFSes code that TFS 1.2 uses, would separate storages for each 'data' folder (if you setStorageValue in 'movements' it's still 'nil' in 'actions').
thank you, I solved my problem with another thing
but thanks!
 
Back
Top