CastorFlynn
Member
- Joined
- Aug 29, 2021
- Messages
- 88
- Reaction score
- 8
It is not possible to use the machete in wild growth if it is over a rope climb hole.
function onUseMachete(player, item, fromPosition, target, toPosition, isHotkey)
local targetId = target.itemid
if not targetId then
return true
end
for _,tileItem in pairs(Tile(toPosition):getItems()) do
if table.contains(wildGrowth, tileItem:getId()) then
toPosition:sendMagicEffect(CONST_ME_POFF)
tileItem:remove()
return true
end
end
local grass = jungleGrass[targetId]
if grass then
target:transform(grass)
target:decay()
player:addAchievementProgress("Nothing Can Stop Me", 100)
return true
end
return destroyItem(player, target, toPosition)
end
function onUseMachete(player, item, fromPosition, target, toPosition, isHotkey)
local targetId = target.itemid
if not targetId then
return true
end
for _,tileItem in pairs(Tile(toPosition):getItems()) do
if table.contains(wildGrowth, tileItem:getId()) then
toPosition:sendMagicEffect(CONST_ME_POFF)
tileItem:remove()
return true
end
end
local grass = jungleGrass[targetId]
if grass then
target:transform(grass)
target:decay()
player:addAchievementProgress("Nothing Can Stop Me", 100)
return true
end
return destroyItem(player, target, toPosition)
end
Worked, thanks!Change your onUseMachete function to this:
*Not tested btwLua:function onUseMachete(player, item, fromPosition, target, toPosition, isHotkey) local targetId = target.itemid if not targetId then return true end for _,tileItem in pairs(Tile(toPosition):getItems()) do if table.contains(wildGrowth, tileItem:getId()) then toPosition:sendMagicEffect(CONST_ME_POFF) tileItem:remove() return true end end local grass = jungleGrass[targetId] if grass then target:transform(grass) target:decay() player:addAchievementProgress("Nothing Can Stop Me", 100) return true end return destroyItem(player, target, toPosition) end
Change your onUseMachete function to this:
*Not tested btwLua:function onUseMachete(player, item, fromPosition, target, toPosition, isHotkey) local targetId = target.itemid if not targetId then return true end for _,tileItem in pairs(Tile(toPosition):getItems()) do if table.contains(wildGrowth, tileItem:getId()) then toPosition:sendMagicEffect(CONST_ME_POFF) tileItem:remove() return true end end local grass = jungleGrass[targetId] if grass then target:transform(grass) target:decay() player:addAchievementProgress("Nothing Can Stop Me", 100) return true end return destroyItem(player, target, toPosition) end
Lua Script Error: [Action Interface]
data/actions/scripts/tools/machete.lua:onUse
data/actions/lib/actions.lua:568: attempt to index a nil value
stack traceback:
[C]: in function '__index'
data/actions/lib/actions.lua:568: in function <data/actions/lib/actions.lua:562>
if Tile(toPosition) then
for _,tileItem in pairs(Tile(toPosition):getItems()) do
if table.contains(wildGrowth, tileItem:getId()) then
toPosition:sendMagicEffect(CONST_ME_POFF)
tileItem:remove()
return true
end
end
end
Lua Script Error: [Action Interface]
data/actions/scripts/tools/machete.lua:onUse
data/actions/lib/actions.lua:550: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
[C]: at 0x004ff7d0
[C]: in function 'pairs'
data/actions/lib/actions.lua:550: in function <data/actions/lib/actions.lua:543>
if Tile(toPosition) and Tile(toPosition):getItems() then
for _,tileItem in pairs(Tile(toPosition):getItems()) do
if table.contains(wildGrowth, tileItem:getId()) then
toPosition:sendMagicEffect(CONST_ME_POFF)
tileItem:remove()
return true
end
end
end
I will try that! Thanks!Lua:if Tile(toPosition) and Tile(toPosition):getItems() then for _,tileItem in pairs(Tile(toPosition):getItems()) do if table.contains(wildGrowth, tileItem:getId()) then toPosition:sendMagicEffect(CONST_ME_POFF) tileItem:remove() return true end end end