• 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 TFS 1.2 8.6 Boss arena

Solution
ok, first for my sanity, a refactor to kill the super long line
Diff:
-    local specs = Game.getSpectators(bossarenaconfig.waitingRoomPosition.centerPos, false, true, 0, bossarenaconfig.waitingRoomPosition.radiusX, 0, bossarenaconfig.waitingRoomPosition.radiusY)
+    local lobby = bossarenaconfig.waitingRoomPosition
+    local specs = Game.getSpectators(lobby.centerPos, false, true, 0, lobby.radiusX, 0, lobby.radiusY)



ok,

LUA:
function resetEvent() --  <---- in this function
    local lobby = bossarenaconfig.waitingRoomPosition
    local specs = Game.getSpectators(lobby.centerPos, false, true, 0, lobby.radiusX, 0, lobby.radiusY)
    if #specs >= 1 then
        for i = 0, #specs do
            if...
ok, first for my sanity, a refactor to kill the super long line
Diff:
-    local specs = Game.getSpectators(bossarenaconfig.waitingRoomPosition.centerPos, false, true, 0, bossarenaconfig.waitingRoomPosition.radiusX, 0, bossarenaconfig.waitingRoomPosition.radiusY)
+    local lobby = bossarenaconfig.waitingRoomPosition
+    local specs = Game.getSpectators(lobby.centerPos, false, true, 0, lobby.radiusX, 0, lobby.radiusY)



ok,

LUA:
function resetEvent() --  <---- in this function
    local lobby = bossarenaconfig.waitingRoomPosition
    local specs = Game.getSpectators(lobby.centerPos, false, true, 0, lobby.radiusX, 0, lobby.radiusY)
    if #specs >= 1 then
        for i = 0, #specs do
            if specs[i]:getStorageValue(bossarenaconfig.joinedStorage) == 1 then
                specs[i]:teleportTo(specs[i]:getTown():getTemplePosition())
                specs[i]:setStorageValue(bossarenaconfig.joinedStorage, 0)
            end
        end
    end
--  in this block ⇲
    local specs2 = Game.getSpectators(Position(528, 776, 7), false, true, 39, 39, 55, 55)
    if #specs2 >= 1 then
        for i = 0, #specs2 do
--          this invocation is incorrect
            if specs2[i]:getStorageValue(bossarenaconfig.joinedStorage) == 1 then
                specs2[i]:teleportTo(specs2[i]:getTown():getTemplePosition())
                specs2[i]:setStorageValue(bossarenaconfig.joinedStorage, 0)
            end
        end
    end


My initial suspicion is this programmer is not familiar with Lua very well and that i = 1 because Lua is 1-indexed not 0-indexed, but then previous loop should have broke first... so my second suspicion is about this targeting hardcoded positions, but that could be some real-map thing.

Ok, I searched GitHub and see lots of i = 1 loops when it comes to Game.getSpectators so I would go with that. Change all the get spectator for-loops in that function to use i = 1.

Here you go.
 
Last edited:
Solution
ok, first for my sanity, a refactor to kill the super long line
Diff:
-    local specs = Game.getSpectators(bossarenaconfig.waitingRoomPosition.centerPos, false, true, 0, bossarenaconfig.waitingRoomPosition.radiusX, 0, bossarenaconfig.waitingRoomPosition.radiusY)
+    local lobby = bossarenaconfig.waitingRoomPosition
+    local specs = Game.getSpectators(lobby.centerPos, false, true, 0, lobby.radiusX, 0, lobby.radiusY)



ok,

LUA:
function resetEvent() --  <---- in this function
    local lobby = bossarenaconfig.waitingRoomPosition
    local specs = Game.getSpectators(lobby.centerPos, false, true, 0, lobby.radiusX, 0, lobby.radiusY)
    if #specs >= 1 then
        for i = 0, #specs do
            if specs[i]:getStorageValue(bossarenaconfig.joinedStorage) == 1 then
                specs[i]:teleportTo(specs[i]:getTown():getTemplePosition())
                specs[i]:setStorageValue(bossarenaconfig.joinedStorage, 0)
            end
        end
    end
--  in this block ⇲
    local specs2 = Game.getSpectators(Position(528, 776, 7), false, true, 39, 39, 55, 55)
    if #specs2 >= 1 then
        for i = 0, #specs2 do
--          this invocation is incorrect
            if specs2[i]:getStorageValue(bossarenaconfig.joinedStorage) == 1 then
                specs2[i]:teleportTo(specs2[i]:getTown():getTemplePosition())
                specs2[i]:setStorageValue(bossarenaconfig.joinedStorage, 0)
            end
        end
    end


My initial suspicion is this programmer is not familiar with Lua very well and that i = 1 because Lua is 1-indexed not 0-indexed, but then previous loop should have broke first... so my second suspicion is about this targeting hardcoded positions, but that could be some real-map thing.

Ok, I searched GitHub and see lots of i = 1 loops when it comes to Game.getSpectators so I would go with that. Change all the get spectator for-loops in that function to use i = 1.

Here you go.

Still the same :(
 
change this portion of the script to spit out debug info

LUA:
    local specs2 = Game.getSpectators(Position(528, 776, 7), false, true, 39, 39, 55, 55)
    if #specs2 >= 1 then
        for i = 1, #specs2 do
            print(1, i)
            print(2, specs2[i])
            print(3, specs2[i]:getStorageValue)
            print(4, bossarenaconfig)
            print(5, bossarenaconfig.joinedStorage)
            print(6, specs2[i]:getStorageValue(bossarenaconfig.joinedStorage))
            if specs2[i]:getStorageValue(bossarenaconfig.joinedStorage) == 1 then
                specs2[i]:teleportTo(specs2[i]:getTown():getTemplePosition())
                specs2[i]:setStorageValue(bossarenaconfig.joinedStorage, 0)
            end
        end
    end
 
Um, what?
This code you pasted should not be the state of your code.

This should be

Also: You didn't even do all the fixes? It's still using index of 0!
Code:
    local specs = Game.getSpectators(lobby.centerPos, false, true, 0, lobby.radiusX, 0, lobby.radiusY)
    if #specs >= 1 then
        for i = 0, #specs do
            if specs[i]:getStorageValue(bossarenaconfig.joinedStorage) == 1 then
                specs[i]:teleportTo(specs[i]:getTown():getTemplePosition())
                specs[i]:setStorageValue(bossarenaconfig.joinedStorage, 0)
            end
        end
    end
 

Similar threads

Back
Top