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

Need some quick help, should be easy

Humpasaur

New Member
Joined
Dec 7, 2009
Messages
18
Reaction score
0
Hey, I'm trying to get into LUA and all, but I'm having trouble with a simple script...

Basically, I'm making a little elevator in my depot. There is a tile in the back with the item ID of 426 and a unique ID of 4266. I'm trying to make it to where when I walk on the tile, it teleports me to a certain spot on the upper level of the depot... It's not working at all, I've been reading tutorials for a while, I just want to get this down.

I put the dptele.lua file into data/movements/scripts. I hope that's right, because I don't exactly know where to place my scripts... Anyways, here is my code.


Code:
local topdp1 = {x=1022, y=983, 6}
function onStepIn(cid, item, position, fromPosition)
if item.uid == 4266 then
doTeleportThing(cid,topdp1)
end

Any help would be appreciated, I imagine its pretty simple for some of you guys. Thanks.
 
I think your problem is that you forgot to end the function and also return true:

Lua:
local topdp1 = {x = 1022, y = 983, 6}

function onStepIn(cid, item, position, fromPosition)
	if item.uid == 4266 then
		doTeleportThing(cid, topdp1)
	end
return TRUE
end

Also, did you register it on movements.xml? You need to add it there, like this:
PHP:
<movevent type="StepIn" itemid="xxxx" event="script" value="dptele.lua"/>

:peace:
 
Last edited:
I think your problem is that you forgot to end the function and also return true:

Lua:
local topdp1 = {x = 1022, y = 983, 6}

function onStepIn(cid, item, position, fromPosition)
	if item.uid == 4266 then
		doTeleportThing(cid, topdp1)
	end
return TRUE
end

Also, did you register it on movements.xml? You need to add it there, like this:
PHP:
<movevent type="StepIn" itemid="xxxx" event="script" value="dptele.lua"/>

:peace:

Thanks for responding, I did all of that, still does nothing when I walk on the tile... I'm using the new TFS if that helps.
 
Yeah, I got further though... I'll tell you the error my GUI gives me, then I'll post my new script...

Code:
[08/12/2009 19:04:03] Testy has logged in.

[08/12/2009 19:04:10] Lua Script Error: [MoveEvents Interface] 
[08/12/2009 19:04:10] data/movements/scripts/dptele.lua:onStepIn

[08/12/2009 19:04:10] data/movements/scripts/dptele.lua:5: attempt to concatenate a boolean value
[08/12/2009 19:04:10] stack traceback:
[08/12/2009 19:04:10] 	data/movements/scripts/dptele.lua:5: in function <data/movements/scripts/dp

Heres what I have in movements.
Code:
<movevent type="StepIn" itemid="426" event="script" value="dptele.lua"/>

Here is whats in dptele.lua.
Code:
function onStepIn(cid, item, position, fromPosition)
	if item.uid == 4266 then
		local topdp1 = {x = 1022, y = 983, 6}
		doTeleportThing(cid, topdp1)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are the newest resident of " .. getTownName(townId) .. ".")
	end

	return true
end

I borrowed the script from Citizen.lua and messed with it a bit.

Thanks again
 
Ahhhh I see whats wrong, dont know how I missed it before!

This:
Lua:
		local topdp1 = {x = 1022, y = 983, 6}

We forgot the little "z"! :p It should be:

Lua:
		local topdp1 = {x = 1022, y = 983, z = 6}

Stuff that happens :rolleyes:
 
Lol, thanks man, I would of never seen that. It's working now.
Here's the final script for any future humans who got stuck with the same thing.

local place = {x=XXX, y=XXX, z=X}
function onStepIn(cid, item, position, fromPosition)
if item.uid == XXXX then
doTeleportThing(cid, place)
end
end
 
You don't need to check if item.uid == number because the script is only registered to item with uniqueid specified in actions.xml, unless you have actions that share the same script.
 
Back
Top