Hello, currently starting working on an OT and working towards a better understanding of the how and why things do what they do.
first step is very simple, understanding the rat bridge in rook.
Before posting this i have looked at both these posts.. [Request] Rat Bridge (Rook) (https://otland.net/threads/request-rat-bridge-rook.75874/) and Action - RookGard Rats Lever (https://otland.net/threads/rookgard-rats-lever.50534/#post507355) both giving different nil errors when attempted to use.
Currently using TFS 1.5 downgrade to 8.6, along with Nekiro distributions.
As i am going off of an example i saw in the action scripts for demon helmet quest to remove the stone from pulling lever (granted it doesnt work either currently) but in my basic understanding this should work.... added some descriptions in code to give my thought process (feel free to critique or tell me im absolutely off here)
Currently when running this code im getting this error.
which i understand the function is line 7, and line 23, e.g. the getTileItemById being nil....but why is it nil? i have attempted using it in the following ways...
getTileItemById()
getTileItemById(405)
getTileItemById(position[1], 405)
in the compat.lua file this is the function itself... (unsure what the final parameter is with ...)
appreciate any help, thank you.
first step is very simple, understanding the rat bridge in rook.
Before posting this i have looked at both these posts.. [Request] Rat Bridge (Rook) (https://otland.net/threads/request-rat-bridge-rook.75874/) and Action - RookGard Rats Lever (https://otland.net/threads/rookgard-rats-lever.50534/#post507355) both giving different nil errors when attempted to use.
Currently using TFS 1.5 downgrade to 8.6, along with Nekiro distributions.
As i am going off of an example i saw in the action scripts for demon helmet quest to remove the stone from pulling lever (granted it doesnt work either currently) but in my basic understanding this should work.... added some descriptions in code to give my thought process (feel free to critique or tell me im absolutely off here)
Lua:
local positions = {
Position(32100, 32205, 8), -- bridge left position
Position(32101, 32205, 8) -- bridge right position
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item.itemid == 1945 then --checking lever left or right pos.
local bridgeLeft = positions[1]:getTileItemById(405) -- creating bridgeLeft as a boolean, positions[1] should come from above local, :getTileItemById(405) should get a true or false if that item is id 405.
if bridgeLeft == false then
Game.createItem(405, 1, positions[1]) -- this is one method i saw concerning another bridge script, 405 should make that tile, 1 quantity, and position[1].
end
local bridgeRight = positions[2]:getTileItemById(positions[2], 405)
if bridgeRight == false then
Game.createItem(405, 1, positions[2])
end
elseif item.itemid == 1946 then --checking lever left or right pos.
local bridgeLeft = positions[1]:getTileItemById(positions[1], 405)
if bridgeLeft then
bridgeLeft:remove()
end
local bridgeRight = positions[2]:getTileItemById(positions[2], 405)
if bridgeRight then
bridgeRight:remove()
end
local item = positions[2]:getItemById(405)
if item then
item:add()
end
positions[2]:sendMagicEffect(CONST_ME_POFF)
Game.createItem(1355, 1, positions[1])
end
item:transform(item.itemid == 1945 and 1946 or 1945)
return true
end
Currently when running this code im getting this error.
Lua:
Lua Script Error: [Action Interface]
data/actions/scripts/rook/rookRatBridge.lua:onUse
data/actions/scripts/rook/rookRatBridge.lua:23: attempt to call method 'getTileItemById' (a nil value)
stack traceback:
[C]: in function 'getTileItemById'
data/actions/scripts/rook/rookRatBridge.lua:23: in function <data/actions/scripts/rook/rookRatBridge.lua:7>
which i understand the function is line 7, and line 23, e.g. the getTileItemById being nil....but why is it nil? i have attempted using it in the following ways...
getTileItemById()
getTileItemById(405)
getTileItemById(position[1], 405)
in the compat.lua file this is the function itself... (unsure what the final parameter is with ...)
Lua:
function getTileItemById(position, itemId, ...)
local t = Tile(position)
if t == nil then
return pushThing(nil)
end
return pushThing(t:getItemById(itemId, ...))
end
appreciate any help, thank you.
Last edited: