Hi! This is a simple script but may be useful to someone.
With this you don't need to add each hole to the script, you just use a actionid for all scripts.
First you need to add this function to actions\lib\actions.lua(made by 4220niller, I think I edited something, can't remember)
Now, here's the code, add this to actions\scripts\pick.lua
Now add this to actions\actions.xml
And that's it!
If you like it, you can give me rep =)
With this you don't need to add each hole to the script, you just use a actionid for all scripts.
First you need to add this function to actions\lib\actions.lua(made by 4220niller, I think I edited something, can't remember)
Lua:
function decayItem(itempos, toitem)
local item = getThingFromPos(itempos)
if (not toitem) or toitem == 0 then
doRemoveItem(item.uid,1)
else
doTransformItem(item.uid,toitem)
end
end
function doDecayItemTo(itempos, toitem, timer)
addEvent(decayItem, timer*1000, itempos, toitem)
return true
end
Now, here's the code, add this to actions\scripts\pick.lua
Lua:
--Pick script using action ids by AGS or God Lord
local aID = 777 --Action Id the ground tile must have to turn into a hole.
local ticks = 30 --How many seconds the hole will last before turning into a normal tile again
local GRASS = {4526, 4527, 4528, 4529, 4530, 4531, 4532, 4533, 4534, 4535, 4536, 4537, 4538, 4529, 4540, 4541, 4567, 4568, 4569, 4756} --grass tiles it can be used on
local DIRT = {351, 352, 353, 354, 355} --dirt tiles it can be used on
local SNOW = {671, 6683, 6684, 6685, 6686, 7002} --snow tiles it can be used on
function onUse(cid, item, fromPosition, itemEx, toPosition)
local toPosition = {x=toPosition.x, y=toPosition.y, z=toPosition.z, stackpos=0} --do not edit this
if itemEx.actionid == aID then
if isInArray(GRASS, itemEx.itemid) then
doTransformItem(itemEx.uid,470)
doDecayItemTo(toPosition, itemEx.itemid, ticks)
elseif isInArray(DIRT, itemEx.itemid) then
doTransformItem(itemEx.uid,392)
doDecayItemTo(toPosition, itemEx.itemid, ticks)
elseif itemEx.itemid == 231 then
doTransformItem(itemEx.uid,482)
doDecayItemTo(toPosition, itemEx.itemid, ticks)
elseif isInArray(SNOW, itemEx.itemid) then
doTransformItem(itemEx.uid,485)
doDecayItemTo(toPosition, itemEx.itemid, ticks)
else
doCreateItem(3324, 1, toPosition)
doDecayItemTo({x=toPosition.x, y=toPosition.y, z=toPosition.z, stackpos=1}, 0, ticks)
end
elseif itemEx.itemid == 7200 then
doTransformItem(itemEx.uid,7236)
end
return true
end
Now add this to actions\actions.xml
XML:
<action itemid="2553" event="script" value="tools/pick.lua"/>
And that's it!
If you like it, you can give me rep =)
Last edited: