• 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 help with a movement script!!

Joined
Sep 1, 2008
Messages
226
Reaction score
2
Location
Sweden
I made this script and it worked as I wanted it to work except one thing, and thats what I need help with...
This script works like this:

When you step on a stone tile, a stair being created...
When you move from the stone tile the stair is still there and I want it to dissapear.

Can someone help me with that ?


Here is the script I made...

Code:
function onStepIn(cid, item, position, fromPosition)
	if(item.actionid == 3506) and (getPlayerLevel(cid) >= 100) then
		doCreateItem(411, 1, {x=608, y=771, z=9})
	else
		doPlayerSendCancel(cid, "Sorry, you are not level 100 or higher.")
	end
	return TRUE
end
 
you mean?

Lua:
local config = 
{
	time = 60, -- SECONDS
	wall = 411
}

local pos = {x=608, y=771, z=9}

function removewall(pos)
	if getThingfromPos(pos).itemid == config.wall then
		doRemoveItem(getThingfromPos(pos).uid)
	end
  return TRUE
end

function onStepOut(cid, item, pos, fromPosition)
			addEvent(removewall, config.time * 1000, pos)
  return TRUE
end
 
I tryed it and I got an error:

Code:
[06/05/2009 20:41:50] Lua Script Error: [MoveEvents Interface] 
[06/05/2009 20:41:50] data/movements/scripts/voc/stairs.lua:onStepOut

[06/05/2009 20:41:50] luaAddEvent(). callback parameter should be a function.
 
try
Lua:
 local config =
{
        time = 60, -- SECONDS
        wall = 411
}


local function removewall(pos)
        if getThingfromPos(pos).itemid == config.wall then
                doRemoveItem(getThingfromPos(pos).uid)
        end
  return TRUE
end

function onStepOut(cid, item, pos, fromPosition)
local pos = {x=608, y=771, z=9}
            addEvent(removewall, config.time * 1000, pos)
  return TRUE
end
 
try
Lua:
 local config =
{
        time = 60, -- SECONDS
        wall = 411
}


local function removewall(pos)
        if getThingfromPos(pos).itemid == config.wall then
                doRemoveItem(getThingfromPos(pos).uid)
        end
  return TRUE
end

function onStepOut(cid, item, pos, fromPosition)
local pos = {x=608, y=771, z=9}
            addEvent(removewall, config.time * 1000, pos)
  return TRUE
end

This one worked but still one problem...
After 60 secounds the stairs dissapears but the prevous tile
don't come back...
It's a black hole now :S
 
easy.
Lua:
 local config =
{
        time = 60, -- SECONDS
        wall = 411,
        tile = TILEIDHERE
}


local function removewall(pos)
        if getThingfromPos(pos).itemid == config.wall then
                doRemoveItem(getThingfromPos(pos).uid)
	        doCreateItem(config.tile, 1, pos)
        end
  return TRUE
end

function onStepOut(cid, item, pos, fromPosition)
local pos = {x=608, y=771, z=9}
            addEvent(removewall, config.time * 1000, pos)
  return TRUE
end
 
/\

lol you did not said that.

Lua:
function onStepOut(cid, item, pos, fromPosition)
local pos = {x=608, y=771, z=9}
  if getThingfromPos(pos) == 411 then
         doRemoveItem(getThingfromPos(pos).uid)
  end
  return TRUE
end
-.-
 
I tried but my English is not so good...

Should I just use...
function onStepOut(cid, item, pos, fromPosition)
local pos = {x=608, y=771, z=9}
if getThingfromPos(pos) == 411 then
doRemoveItem(getThingfromPos(pos).uid)
end
return TRUE
end
...or how do I make it work ?

I tried but I think I didn't do all right..
Should I use my and yours script or just yours or?
 
Code:
   <movevent type="StepIn" actionid="xxxx" event="script" value="scriptlua" />
    <movevent type="StepOut" actionid="xxxx" event="script" value="script.lua" />

Lua:
-- your
function onStepIn(cid, item, position, fromPosition)
	if(item.actionid == 3506) and (getPlayerLevel(cid) >= 100) then
		doCreateItem(411, 1, {x=608, y=771, z=9})
	else
		doPlayerSendCancel(cid, "Sorry, you are not level 100 or higher.")
                doTeleportThing(cid, fromPosition)
	end
	return TRUE
end
-- and mine u.u
function onStepOut(cid, item, pos, fromPosition)
local pos = {x=608, y=771, z=9}
  if getThingfromPos(pos).uid == 411 then
         doRemoveItem(getThingfromPos(pos).uid)
  end
  return TRUE
end
 
Lua:
-- and mine u.u
function onStepOut(cid, item, pos, fromPosition)
	thePos = {x=71, y=344, z=9, stackpos=1}
	getThing = getThingfromPos(thePos)
         doRemoveItem(getWall.uid, 1)
  return TRUE
end
 
Now I got this error message:

[06/05/2009 22:52:48] Lua Script Error: [MoveEvents Interface]
[06/05/2009 22:52:49] data/movements/scripts/voc/stairs2.lua:eek:nStepOut

[06/05/2009 22:52:49] luaGetThingFromPos(). Tile not found

[06/05/2009 22:52:49] Lua Script Error: [MoveEvents Interface]
[06/05/2009 22:52:49] data/movements/scripts/voc/stairs2.lua:eek:nStepOut

[06/05/2009 22:52:49] data/movements/scripts/voc/stairs2.lua:5: attempt to index global 'getWall' (a nil value)
[06/05/2009 22:52:49] stack traceback:
[06/05/2009 22:52:49] data/movements/scripts/voc/stairs2.lua:5: in function <data/movements/scripts/voc/stairs2.lua:2>
 
Lua:
  -- and mine u.u
function onStepOut(cid, item, pos, fromPosition)
        thePos = {x=71, y=344, z=9, stackpos=1}
        getThing = getThingfromPos(thePos)
         doRemoveItem(getThing.uid, 1)
  return TRUE
end
 
OK, this didn't work either...

This is how I have put it:
Code:
In the movements.xml
    <movevent type="StepOut" actionid="3506" event="script" value="voc/stairs2.lua" />
    <movevent type="StepIn" actionid="3506" event="script" value="voc/stairs2.lua" />

In the stairs2.lua
Code:
  -- your
function onStepIn(cid, item, position, fromPosition)
        if(item.actionid == 3506) and (getPlayerLevel(cid) >= 100) then
                doCreateItem(411, 1, {x=608, y=771, z=9})
        else
                doPlayerSendCancel(cid, "Sorry, you are not level 100 or higher.")
                doTeleportThing(cid, fromPosition)
        end
        return TRUE
end
  -- and mine u.u
function onStepOut(cid, item, pos, fromPosition)
        thePos = {x=71, y=344, z=9, stackpos=1}
        getThing = getThingfromPos(thePos)
         doRemoveItem(getThing.uid, 1)
  return TRUE
end
(I don't know how to make it Lua Code)

Is that how I should put it?
*****************************************************************
Btw, I got an error:
Code:
[06/05/2009 23:49:32] Lua Script Error: [MoveEvents Interface] 
[06/05/2009 23:49:32] data/movements/scripts/voc/stairs2.lua:onStepOut

[06/05/2009 23:49:32] luaGetThingFromPos(). Tile not found

[06/05/2009 23:49:32] Lua Script Error: [MoveEvents Interface] 
[06/05/2009 23:49:32] data/movements/scripts/voc/stairs2.lua:onStepOut

[06/05/2009 23:49:32] luaDoRemoveItem(). Item not found
 
Back
Top