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

Lua Can you make a tile when you step in, and remove it when you step out?

Slatera

Active Member
Joined
Mar 6, 2009
Messages
521
Reaction score
46
Location
Sweden
Hi, im new to Lua, and I wonder, if you can make a new tile when you step on a allready existing tile, and remove it and restore the normal tile when you step out?

I was thinking
Code:
doPlayerAddItem(uid, 406)
doPlayerRemoveItem(cid, 406)

But I dont know how to return the item that was there from the start.
And then, I would like to know how you make it repeat this all the time, make the item when you step in, and remove when you step out, untill you want it to stop.

Help would be really good. :)

Using TFS 0.3.6pl1
 
Rep++
Lua:
local uniqueID = 10225 --Tile uniqueID
function onStepIn(cid, item, frompos, item2, topos) 
	wall1 = {x=461, y=1374, z=10, stackpos=1} --Position
	getwall1 = getThingfromPos(wall1)
	if item.uid == uniqueID then
		doTransformItem(item.uid, item.itemid - 1)
		doCreateItem(1386,1,wall1) --Item id of created item
end
end

function onStepOut(cid, item, frompos, item2, topos)
	wall1 = {x=461, y=1374, z=10, stackpos=1} --Same position
	getwall1 = getThingfromPos(wall1)
	if item.uid == uniqueID then
		doTransformItem(item.uid, item.itemid + 1)
		doRemoveItem(getwall1.uid,1)
	end
	return 1
end
Works for me :)
 
Yeah, but I want it to NOT be just 1 pos, I want it to be all over the place, so it comes under you wherever you walk, so if i stand at 1000x 1000y 7z, i want to move 999x 1000y 7z, and add a tile, and step out, and then walk 998x 100y 7z and add a new one, so it keeps comming under you untill you dont want it to anymore. :p

Down to one small sentance: Add a tile under you wherever you walk. :p
 
Yeah, but I want it to NOT be just 1 pos, I want it to be all over the place, so it comes under you wherever you walk, so if i stand at 1000x 1000y 7z, i want to move 999x 1000y 7z, and add a tile, and step out, and then walk 998x 100y 7z and add a new one, so it keeps comming under you untill you dont want it to anymore. :p

Down to one small sentance: Add a tile under you wherever you walk. :p

Try this :p
Lua:
local uniqueID = 10225 --Tile uniqueID
local pos = getCreaturePosition(cid)
function onStepIn(cid, item, frompos, item2, topos) 
	getwall1 = getThingfromPos(pos)
	if item.uid == uniqueID then
		doTransformItem(item.uid, item.itemid - 1)
		doCreateItem(1386,1,pos) --Item id of created item
end
end
 
function onStepOut(cid, item, frompos, item2, topos)
	getwall1 = getThingfromPos(pos)
	if item.uid == uniqueID then
		doTransformItem(item.uid, item.itemid + 1)
		doRemoveItem(getwall1.uid,1)
	end
	return 1
end

just add the uid on every tile you want to use it on :p in the map.
 
Try this :p
Lua:
local uniqueID = 10225 --Tile uniqueID
local pos = getCreaturePosition(cid)
function onStepIn(cid, item, frompos, item2, topos) 
	getwall1 = getThingfromPos(pos)
	if item.uid == uniqueID then
		doTransformItem(item.uid, item.itemid - 1)
		doCreateItem(1386,1,pos) --Item id of created item
end
end
 
function onStepOut(cid, item, frompos, item2, topos)
	getwall1 = getThingfromPos(pos)
	if item.uid == uniqueID then
		doTransformItem(item.uid, item.itemid + 1)
		doRemoveItem(getwall1.uid,1)
	end
	return 1
end

just add the uid on every tile you want to use it on :p in the map.

I dont want to add uids all over my map.. :(
 
Im trying to make a fly system, thats why. :p

your not the one making (A) xD ur requesting but jaja, try this :p

Lua:
local pos = getCreaturePosition(cid)
local areaPosition =
{
    {x=33400, y=31183, z=8, stackpos = 255}, --topleft
    {x=33400, y=31183, z=8, stackpos = 255} --bottomright
}
function onStepIn(cid, item, frompos, item2, topos) 
	getwall1 = getThingfromPos(pos)
	if isInRange(getCreaturePosition(cid), areaPosition[1], areaPosition[2]) then
		doTransformItem(item.uid, item.itemid - 1)
		doCreateItem(1386,1,pos) --Item id of created item
end
end
 
function onStepOut(cid, item, frompos, item2, topos)
	getwall1 = getThingfromPos(pos)
	if isInRange(getCreaturePosition(cid), areaPosition[1], areaPosition[2]) then
		doTransformItem(item.uid, item.itemid + 1)
		doRemoveItem(getwall1.uid,1)
	end
	return 1
end
 
Last edited:
Actually, im trying to make, I just wanted to know what exactly u should type to make the item appear under you, and then dissappear when you walk out, and I couldve built myself from there. :)
 
Back
Top