• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Scarab coin teleport script

Evan

A splendid one to behold
Senator
Premium User
Joined
May 6, 2009
Messages
7,018
Solutions
1
Reaction score
1,040
Location
United States
I tried searching on this forum and I only see one from Quas~
I tried fixing it up to my own needs but it's not working.

What I have that is used:
- One talon
- One basin
- One mystical flame

You put the talon on the basin, then if you walk into the mystical flame, it teleports you to X-location. (it is a one-way teleport, there is no going back).

It's been awhile since I scripted, but I need some help that way I can get my mind refreshing.

Here's the script I currently have and it does not work:

talonteleport.lua:
PHP:
function onAddItem(moveitem, tileitem, pos, cid)
	local coins = {
			[30012] = {frompos = {x= 1034,y= 1025,z = 7}, topos = {x= 1057,y= 1017,z = 7}}
			}
    if moveitem.itemid == 2151 then 
		doRemoveItem(moveitem.uid)
		doSendMagicEffect(pos, 15)
		doSendMagicEffect(coins[tileitem.actionid].frompos, CONST_ME_TELEPORT)
		doSendMagicEffect(coins[tileitem.actionid].topos, CONST_ME_TELEPORT)
        doRelocate(coins[tileitem.actionid].frompos,coins[tileitem.actionid].topos)
    end
    return TRUE
end

Here is the movement.xml thing:

PHP:
<movevent type="AddItem" tileitem="1" actionid="30012" event="script" value="talonteleport.lua"/>


Thanks and ofc rep will be given
 
I tried taking your advice and still ain't working.
I overhauled everything from scratch.

talonteleport.lua:
PHP:
function onStepIn(cid, item, position, fromPosition)

	frompos = {x= 1034,y= 1025,z = 7}
	topos = {x= 1057,y= 1017,z = 7}
	basin_pos = {x=1035, y=1026, z=7, stackpos=1}  
 	basin = getThingfromPos(basin_pos) 

    if basin.itemid == 2151 then 
		doRemoveItem(basin.uid)
		doTeleportThing(cid, topos, TRUE)
		doSendMagicEffect(frompos, 10)
		doSendMagicEffect(topos, 10)
    end
    return TRUE
end

movements.xml:
PHP:
<movevent type="StepIn" actionid="30012" event="script" value="talonteleport.lua"/>

Other information:
I have the black tile floor under the mystical flame as actionid 30012.

That's it!

Hope someone can help me here! :)



EDIT: forgot the doTeleportThing part, but it's still not working after I put it in.
 
Eeeeeeeemmmmmm
LUA:
function onStepIn(cid, item, position, fromPosition)

    frompos = {x= 1034,y= 1025,z = 7}
    topos = {x= 1057,y= 1017,z = 7}
    basin_pos = {x=1035, y=1026, z=7, stackpos=1}  
     basin = getThingfromPos(basin_pos) 

    if basin.itemid == 2151 then 
        doRemoveItem(basin.uid, 1)
        doTeleportThing(cid, topos)
        doSendMagicEffect(frompos, 10)
        doSendMagicEffect(topos, 10)
    end
    return TRUE
end
Just guessing
 
urs stackpos sux. use
LUA:
getTileItemById(pos,id)


@Edit. ehhh..
LUA:
local topos = {x= 1057,y= 1017,z = 7}
local basin_pos = {x=1035, y=1026, z=7}  
function onStepIn(cid, item, position, fromPosition)
    basin = getTileItemById(basin_pos,2151) ;
    if basin.uid > 0 then 
        doRemoveItem(basin.uid, 1)
        doTeleportThing(cid, topos)
        doSendMagicEffect(position, 10)
        doSendMagicEffect(topos, 10)
    end
    return TRUE
end
 
Still got nothing working;

I got a picture for better explanation (hope it helps):
2wmgtxi.png


Here's the script I use (the one you gave me):
PHP:
local topos = {x= 1057,y= 1017,z = 7}
local basin_pos = {x=1035, y=1026, z=7}  
function onStepIn(cid, item, position, fromPosition)
    basin = getTileItemById(basin_pos,2151) ;
    if basin.uid > 0 then 
        doRemoveItem(basin.uid, 1)
        doTeleportThing(cid, topos)
        doSendMagicEffect(position, 10)
        doSendMagicEffect(topos, 10)
    end
    return TRUE
end

Here is what is in movements.xml:
PHP:
<movevent type="StepIn" actionid="30012" event="script" value="talonteleport.lua"/>

I am using the 8.62 version of TALATUREN's distro, not Elfs, I don't if that means anything, I just couldn't find an 8.62 version of Elf's distro, but I guess it doesn't matter much in the time being.
 
2 reasons of not working. a talons id is not 2151

Talaturens distro doesn't has getTileItemById

LUA:
function getTileItemById(pos,id)
local thing;
for i = 1,255 do
pos.stackpos = i;
thing = getThingFromPos(pos);
if(thing.itemid == id)then
return thing;
end
end
return {uid = 0, itemid = 0};
end
 
19:04 You see a talon.
It weighs 0.20 oz.
There are many rumours about these magic gems.
ItemID: [2151].
Position: [X: 1114] [Y: 1021] [Z: 7].

About that script:
I suppose you add that to data/global.lua, right?
If so, still doesn't work.
 
Try this.

Code:
function onStepIn(cid, item, position)
	local pos = {x = 100, y = 100, z = 7, stackpos = 2}
	local talon = getThingfromPos(pos).itemid
	if talon == 2151 then
		doTeleportThing(cid, {x = 100, y = 100, z = 7})
		doSendMagicEffect({x = 100, y = 100, z = 7}, CONST_ME_MAGIC_BLUE)
                doRemoveItem(talon, 1)
	end
	
	return true
end
 
Try this.

Code:
function onStepIn(cid, item, position)
	local pos = {x = 100, y = 100, z = 7, stackpos = 2}
	local talon = getThingfromPos(pos).itemid
	if talon == 2151 then
		doTeleportThing(cid, {x = 100, y = 100, z = 7})
		doSendMagicEffect({x = 100, y = 100, z = 7}, CONST_ME_MAGIC_BLUE)
                doRemoveItem(talon, 1)
	end
	
	return true
end

Everytime I step onto the mystical flame:

[12/01/2011 19:20:38] Lua Script Error: [Action Interface]
[12/01/2011 19:20:38] data/actions/scripts/other/matrixlever.lua:onUse

[12/01/2011 19:20:38] data/global.lua:705: attempt to call global 'getThingFromPos' (a nil value)
[12/01/2011 19:20:38] stack traceback:
[12/01/2011 19:20:38] data/global.lua:705: in function 'getTileItemById'
[12/01/2011 19:20:38] data/actions/scripts/other/matrixlever.lua:20: in function <data/actions/scripts/other/matrixlever.lua:17>
 
Make the action/unique id on the flame. Then use this script.

LUA:
local coin, pos = 0, 0
function onStepIn(cid, item, position, fromPosition)
	pos = {
		{x = 100, y = 100, z = 7}, -- Where the flame is.
		{x = 100, y = 100, z = 7}, -- Where player gets teleported.
		{x = 100, y = 100, z = 7, stackpos = 2} -- Where item goes on basin.
	}
	coin = getThingfromPos(pos[3])
	if coin.itemid == 2151 then
		doRemoveItem(coin.uid, 1)
		doSendMagicEffect(pos[1], CONST_ME_PUFF)
		doSendMagicEffect(pos[2], CONST_ME_TELEPORT)
		doTeleportThing(cid, pos[2])
		doSendMagicEffect(pos[3], CONST_ME_HITBYFIRE)
	end
	
	return TRUE
end
 
edit: works now!

There was a pooper in the movements.xml, thanks JDB rep++
 
Last edited:
Back
Top