DiegoRulez
Member
TFS 1.2
With this script, when using shovel in the desert (231) there is a chance to create scarab coins or to summon a scarab.
But I would like that when using on floor 231, but that has an action id (which in my case (actionid = 100) would execute the action of opening a hole that would open a time and then return to normal.
I found a function that does this in actions.lua, but I would like this function to be inside the shovel script itself.
I'll be posting the script, and the function. But you do not need to use this function, if you write the code in any other way it works, it helps a lot.
shovel.lua
Code in actions.lua
With this script, when using shovel in the desert (231) there is a chance to create scarab coins or to summon a scarab.
But I would like that when using on floor 231, but that has an action id (which in my case (actionid = 100) would execute the action of opening a hole that would open a time and then return to normal.
I found a function that does this in actions.lua, but I would like this function to be inside the shovel script itself.
I'll be posting the script, and the function. But you do not need to use this function, if you write the code in any other way it works, it helps a lot.
shovel.lua
Code:
local holes = {468, 481, 483}
local pools = {2016, 2017, 2018, 2019, 2020, 2021, 2025, 2026, 2027, 2028, 2029, 2030}
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
if isInArray(holes, target.itemid) then
target:transform(target.itemid + 1)
target:decay()
elseif isInArray(pools, target.itemid) then
local hole = 0
for i = 1, #holes do
local tile = Tile(target:getPosition()):getItemById(holes[i])
if tile then
hole = tile
end
end
if hole ~= 0 then
target:remove(1)
hole:transform(hole:getId() + 1)
hole:decay()
end
elseif target.itemid == 231 then
local randomValue = math.random(1, 100) --random number, do 1 ate 100
if randomValue <= 10 then --o random e 1
Game.createItem(2159, 1, toPosition) --cria o scarab coin
elseif randomValue > 95 then--random e maior do 95
Game.createMonster("Scarab", toPosition)--cria um scarab
end
toPosition:sendMagicEffect(CONST_ME_POFF)
else
return false
end
return true
end
Code in actions.lua
Code:
local groundId = ground:getId()
elseif groundId == 231 then
if (ground:getActionId() == 100) then
ground:transform(482)
addEvent(remove, 10000, 231, toPosition
return true
end
Last edited: