• 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!

TFS 0.3.6 'isWater' (a nil value)

Morteusz

New Member
Joined
Oct 22, 2023
Messages
11
Reaction score
3
Hello guys!

I would like to ask for your assistance. Trying to execute this script but it seems function isWater is not working.
function isWalkableSnowTile(pos, creature, proj, pz, water)
if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
if isWater(getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid) and water and isOnlySurfTile(getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid) or not isInArray(SnowTile, getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid) or isInArray(BlockProfitItem, getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid) then return false end
if getTopCreature(pos).uid > 0 and creature then return false end
if getTileInfo(pos).protection and pz then return false, true end
local n = not proj and 3 or 2
for i = 0, 255 do
pos.stackpos = i
local tile = getTileThingByPos(pos)
if tile.itemid ~= 0 and not isCreature(tile.uid) then
if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
return false
end
end
end
return true
end

[Error - Action Interface]
data/actions/scripts/../../lib/ps/profession/actions/collect/miner.lua:eek:nUse
Description:
data/lib/ProfessionBlock.lua:101: attempt to call global 'isWater' (a nil value)
stack traceback:
data/lib/ProfissionBlock.lua:101: in function 'isWalkableSnowTile'
data/lib/ProfissionBlock.lua:119: in function 'getRandomPosSnowTile'
data/lib/ProfissionBlock.lua:120: in function 'getRandomPosSnowTile'
data/lib/ProfissionBlock.lua:120: in function 'getRandomPosSnowTile'
data/lib/ProfissionBlock.lua:120: in function 'getRandomPosSnowTile'
data/lib/ProfissionBlock.lua:120: in function 'getRandomPosSnowTile'
data/lib/ProfissionBlock.lua:120: in function 'getRandomPosSnowTile'
data/lib/ProfissionBlock.lua:120: in function 'getRandomPosSnowTile'
data/lib/ProfissionBlock.lua:120: in function 'getRandomPosSnowTile'
data/lib/ProfissionBlock.lua:120: in function 'getRandomPosSnowTile'

Would be awesome if you could help me solve the issue :)

Best regards ^^
 
Its because you have no function 'isWater' in your engine, ctrl+shift+f using any file editor [vs code etc.] and search for this func
Post automatically merged:

i bet u should make func like

local water_ids = {1234,5678}
function isWater(itemid)
if table.contains(water_ids, itemid) then
return true
else
return false
end
end

and put correct water ids in this table
 
isWater(getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid) and water

To

water and isWater(getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid)

and add isWater func
 
Tried your solution, now getting table error
Description:
data/lib/012-table.lua:150: bad argument #1 to 'pairs' (table expected, got number)
stack traceback:
[C]: in function 'pairs'
data/lib/012-table.lua:150: in function 'contains'

table.lua
table.contains = function (txt, str)
for i, v in pairs(str) do
if(txt:find(v) and not txt:find('(%w+)' .. v) and not txt:find(v .. '(%w+)')) then
return true
end
end

return false
end
 
Back
Top