Action Pick using actionIDs

AGS

DeathSouls Owner
Joined
Oct 29, 2007
Messages
400
Best answers
0
Reaction score
8
Location
Mexico
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)
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:
OP
AGS

AGS

DeathSouls Owner
Joined
Oct 29, 2007
Messages
400
Best answers
0
Reaction score
8
Location
Mexico
Thanks! =D.. *cough* rep *cough*:rolleyes:

Update: Now It works on new ice tiles.
If you use it on a tile with id 7002, if it has the actionid you chose, it will create a hole.
If the tile has no actionid, it will turn it into a hole with water for ice fishing
 

Godely

Member
Joined
Aug 19, 2007
Messages
233
Best answers
0
Reaction score
15
very nice script.
btw,
"elseif item2.itemid == 7200 then
doTransformItem(item2.uid,7236)"
this item 7236 will return to normal? Cause I didn't get it =p
 

Xero

~¤+Mapeditor User+¤~ ™
Joined
Jun 11, 2007
Messages
301
Best answers
0
Reaction score
2
Location
Netherlands
Dude this pwns, I was searching it for 1 day xD!

U ish my hero for this minut ty.
 
OP
AGS

AGS

DeathSouls Owner
Joined
Oct 29, 2007
Messages
400
Best answers
0
Reaction score
8
Location
Mexico
@Godely: Yep, it will return to normal, so the hole will be closed.
 

Rudixx

New Member
Joined
Aug 3, 2007
Messages
246
Best answers
0
Reaction score
0
Location
England
doDecayItemTo(topos, 0, ticks) is not working on latest version of TFS isn't it?
 

Wojarade Ziro

New Member
Joined
Oct 25, 2007
Messages
39
Best answers
0
Reaction score
0
@up it should work if you add the first thing to actions.lua inside lib folder



Wojs~
 

Bulet

Knight of Apocalypse
Joined
Jul 12, 2009
Messages
183
Best answers
0
Reaction score
7
Location
Brazil
@Godely: Yep, it will return to normal, so the hole will be closed.
Yeap but you only will can make the quest one time because that script dont put actionid on hole back again need make that im try but im badly on script im study that ...
If any one can help me whats wrong ?
Whow change a item without lose your actionid ?
function onUse(cid, item, frompos, item2, topos)

aID = 60001 --Action Id the ground tile must have to turn into a hole.
ticks = 15 --How many seconds the hole will last before turning into a normal tile again
topos = {x=topos.x, y=topos.y, z=topos.z}
GRASS = {4526, 4527, 4528, 4529, 4530, 4531, 4532, 4533, 4534, 4535, 4536, 4537, 4538, 4529, 4540, 4541, 4567, 4568, 4569, 4756}
DIRT = {351, 352, 353, 354, 355}
SNOW = {671, 6683, 6684, 6685, 6686, 7002}

if item2.actionid == aID then
if isInArray(GRASS, item2.itemid) == 1 then
doTransformItem(item2.uid,470)
doDecayItemTo(topos, item2.itemid, ticks)
elseif isInArray(DIRT, item2.itemid) == 1 then
doTransformItem(item2.uid,383)
doDecayItemTo(topos, item2.itemid, ticks)
elseif item2.itemid == 231 then
doTransformItem(item2.uid,482)
doDecayItemTo(topos, item2.itemid, ticks)
elseif isInArray(SNOW, item2.itemid) == 1 then
doTransformItem(item2.uid,485)
doDecayItemTo(topos, item2.itemid, ticks)
else
doCreateItem(383, 1, topos)
doDecayItemTo(topos, item2.itemid, ticks)
doSetItemActionId(item2.itemid, aID)

end
elseif item2.itemid == 7200 then
doTransformItem(item2.uid,7236)
doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
return true
end

return false
end
 
Last edited:

Wooki

New Member
Joined
Aug 4, 2011
Messages
3
Best answers
0
Reaction score
0
I have this script on my pick but after the hole is closed the actionid is gone from the tile. Is there something I can do to fix this? I would gladly rep for any help.

--Pick script using action ids by AGS or God Lord
function onUse(cid, item, frompos, item2, topos)

aID = 777 --Action Id the ground tile must have to turn into a hole.
ticks = 30 --How many seconds the hole will last before turning into a normal tile again
topos = {x=topos.x, y=topos.y, z=topos.z}
GRASS = {4526, 4527, 4528, 4529, 4530, 4531, 4532, 4533, 4534, 4535, 4536, 4537, 4538, 4529, 4540, 4541, 4567, 4568, 4569, 4756}
DIRT = {351, 352, 353, 354, 355}
SNOW = {671, 6683, 6684, 6685, 6686, 7002}

if item2.actionid == aID then
if isInArray(GRASS, item2.itemid) == 1 then
doTransformItem(item2.uid,470)
doDecayItemTo(topos, item2.itemid, ticks)
elseif isInArray(DIRT, item2.itemid) == 1 then
doTransformItem(item2.uid,383)
doDecayItemTo(topos, item2.itemid, ticks)
elseif item2.itemid == 231 then
doTransformItem(item2.uid,482)
doDecayItemTo(topos, item2.itemid, ticks)
elseif isInArray(SNOW, item2.itemid) == 1 then
doTransformItem(item2.uid,485)
doDecayItemTo(topos, item2.itemid, ticks)
else
doCreateItem(3324, 1, topos)
doDecayItemTo(topos, 0, ticks)
end
elseif item2.itemid == 7200 then
doTransformItem(item2.uid,7236)
end
end
 

Xoriak

New Member
Joined
Jan 2, 2009
Messages
10
Best answers
0
Reaction score
0
I have a similar problem like Bulet and I copied the exact code from AGS but the actionID disappears when the hole is normal ground again. Any ideas? I appreciate any help. Is there something that should be added to the original script?
 
OP
AGS

AGS

DeathSouls Owner
Joined
Oct 29, 2007
Messages
400
Best answers
0
Reaction score
8
Location
Mexico
I'm going to test, and see what I can do, it is a really old script.

EDIT:
I tested it now, and I didn't had any problems, I'm using TFS 0.3/0.4 rev 4510
I'm not sure if I have edited something in my script since I posted that, so I updated the first post with the script

I tested using grass, the hole kept the actionid, then when it turned back to grass, it still had the actionid.
I tested using any other tile with the actionid
16:39 You see pavement.
ItemID: [10402], ActionID: [777].
Position: [X: 1183] [Y: 1244] [Z: 7].
And when I used the pick on it, a hole appeared, WITHOUT the actionid
16:41 You see a pitfall.
ItemID: [3324].
Position: [X: 1183] [Y: 1244] [Z: 7].
But that's normal, because that hole is just an item placed over the ground tile.
After 30 seconds, the hole dissapears, and the ground still has the actionid.
16:42 You see pavement.
ItemID: [10402], ActionID: [777].
Position: [X: 1183] [Y: 1244] [Z: 7].


Try copying the script again, maybe I had edited something that fixed it, and test it again.
 
Last edited:

Zerity

New Member
Joined
Jul 7, 2009
Messages
89
Best answers
0
Reaction score
0
It does not go back to normal for me? any ideas why? i copied everything and just changed the actionid to another number

[20/03/2013 21:39:24] [Error - Action Interface]
[20/03/2013 21:39:24] data/actions/scripts/pick.lua:eek:nUse
[20/03/2013 21:39:24] Description:
[20/03/2013 21:39:24] data/actions/scripts/pick.lua:26: attempt to call global 'doDecayItemTo' (a nil value)
[20/03/2013 21:39:24] stack traceback:
[20/03/2013 21:39:24] data/actions/scripts/pick.lua:26: in function <data/actions/scripts/pick.lua:8>
 
Last edited:

bzium1994

New Member
Joined
Mar 31, 2013
Messages
5
Best answers
0
Reaction score
0
When i use a pick on a created hole i have a bug:
 
Top