• 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 help] Translating lua into english

KingWit

('_')
Joined
Jan 3, 2008
Messages
62
Reaction score
0
Location
Sweden
Well since I'm a newbie on scripting and such there is always things that is hard to figure out by myself. I'm sure there is someone out there that has the same problem, that's why I decided to make this thread.

Before I use any script, I'd like to understand it first to learn it and maybe someday I'll make a similar script or something. But there is a lot of things that I dont understand and I hope some people can help me out.

I'm going to post some random scripts here from OTland and I'd like people who already knows how to script help me out with translating [more explaining] some things for me.

Here is a script from Mock
Code:
--- Perfect refine system by Mock the bear (MTB).
--- Email: [email][email protected][/email]
local gain = {
gainArmor='&p+1',loseArmor='&p-1',
gainShield='&s+#',loseShield='&s-(#+1)',
gainAttack='&a+#+1',loseAttack='&a-(#+1)-1',
gainDefense='&d+#+2',loseDefense='&d-(#+1)-2',
chance='100/((#*(1/(@/2)))*(@/2))',  -- This equation its good to use items 0-7.
--- This equation must need return chance in % (0-100) 100 = always, 0 = never.
maxlvl = 7,
blocked_ids = {2488,8881}
}
-- &a = weapon attack
-- &d = weapon defense
-- &s = shield defense
-- &p = armor defense
-- # = weapon curr level
-- @ = max level
function isArmor(uid) -- Function by Mock the bear.
         uid = uid or 0
         if getItemArmor(uid) > 0 and getItemAttack(uid) == 0 and getItemDefense(uid) == 0 and getItemWeaponType(uid) == 0 then
             return TRUE
         end
         return FALSE
end
function isWeapon(uid) -- Function by Mock the bear.
         uid = uid or 0
         local f = getItemWeaponType(uid)
[COLOR="Red"][SIZE="4"]         if f == 1 or f == 2 or f == 3 then[/SIZE][/COLOR]
             return TRUE
         end
         return FALSE        
end
function isShield(uid) -- Function by Mock the bear.
         uid = uid or 0
         if getItemWeaponType(uid) == 4 then
             return TRUE
         end
         return FALSE        
end

function getWeaponLevel(uid) -- Function by Mock the bear.
   uid = uid or 0
   local name = getItemName(uid)
   local _,_,lvl = string.find(name,'+(%d+)')
   return tonumber(lvl) or 0
end
function doTransform(s,uid) -- Function by Mock the bear.
    local c = string.gsub(s,'@',gain.maxlvl)
    local c = string.gsub(c,'&a',getItemAttack(uid))
    local c = string.gsub(c,'&d',getItemDefense(uid))
    local c = string.gsub(c,'&s',getItemDefense(uid))
    local c = string.gsub(c,'&p',getItemArmor(uid))
    local c = string.gsub(c,'#',getWeaponLevel(uid))
    local q,err = loadstring('return '..c)
    assert(q,err)
    return assert(q())
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
         toPosition.stackpos = 255
         if isInArray(gain.blocked_ids, itemEx.itemid) == TRUE
          or getItemWeaponType(itemEx.uid) > 4
           or (getItemWeaponType(itemEx.uid) == 0
            and isArmor(itemEx.uid) == FALSE)
             or itemEx.itemid == 0 then
                doPlayerSendTextMessage(cid, 24,"You cant refine this item.")
                return TRUE
         end
         if isCreature(itemEx.uid) == TRUE then
            return FALSE
         end
        local level = getWeaponLevel(itemEx.uid)
        local chance = doTransform(gain.chance,itemEx.uid)
        if chance >= math.random(0,100) or item.actionid >= 1000 then
           if level+1 > gain.maxlvl then
              doSendMagicEffect(toPosition, 2)
              return doPlayerSendTextMessage(cid, 24,"Your item is on max level, you can't upgrade it.")
           else
              setItemName(itemEx.uid, getItemNameById(itemEx.itemid)..' +'..(level+1))
              doPlayerSendTextMessage(cid, 24,"Your item has been upgrated to +"..(level+1)..".")
              doSendMagicEffect(toPosition, 12)
              if isArmor(itemEx.uid) == TRUE then
                 local get = doTransform(gain.gainArmor,itemEx.uid)
                 setItemArmor(itemEx.uid,get)
              elseif isWeapon(itemEx.uid) == TRUE then
                  setItemAttack(itemEx.uid, doTransform(gain.gainAttack,itemEx.uid))
                  setItemDefense(itemEx.uid, doTransform(gain.gainDefense,itemEx.uid))              
              elseif isShield(itemEx.uid) == TRUE then
                  setItemDefense(itemEx.uid, doTransform(gain.gainShield,itemEx.uid))  
              end
           end
        else
           
           if level == 0 then
               doPlayerSendTextMessage(cid, 24,"No effect.")
               doSendMagicEffect(toPosition, 2)
           elseif level == gain.maxlvl then
                  doSendMagicEffect(toPosition, 2)
                  return doPlayerSendTextMessage(cid, 24,"Your item is on max level, you can't upgrade it.")
           elseif level > 0 then
               if level == 1 then
                   setItemName(itemEx.uid, getItemNameById(itemEx.itemid))
                   doPlayerSendTextMessage(cid, 24,"Your item back to normal.")
               else
                   setItemName(itemEx.uid, getItemNameById(itemEx.itemid)..' +'..(level-1))
                   doPlayerSendTextMessage(cid, 24,"Your item back to +"..(level-1)..".")
               end
              if isArmor(itemEx.uid) == TRUE then
                 setItemArmor(itemEx.uid,doTransform(gain.loseArmor,itemEx.uid))
              elseif isWeapon(itemEx.uid) == TRUE then
                  setItemAttack(itemEx.uid, doTransform(gain.loseAttack,itemEx.uid))
                  setItemDefense(itemEx.uid, doTransform(gain.loseDefense,itemEx.uid))              
              elseif isShield(itemEx.uid) == TRUE then
                  setItemDefense(itemEx.uid, doTransform(gain.loseShield,itemEx.uid))  
              end
           end
           doSendMagicEffect(toPosition, 9)
        end
     doRemoveItem(item.uid,1)  
     return TRUE

Code:
 if f == 1 or f == 2 or f == 3

This one, Ive never understood that. I mean f? means?
Sometimes I see scripts that is similar but instead of having:

PHP:
f == ~~

It has:

Code:
i = ~~

Anyone got a good explanation?

Ill rep++

Thanks

PS, this thread is to everyone who need helps with understanding things. If you have something to ask, would be good if you post it here so people doesn't have to search around for simple explanation.
 
Last edited:
The f is a variable, look at the line before if f ...
local f = getItemWeaponType(uid)
So the f means getItemWeaponType(uid) so instead of if f he could also type:
if getItemWeaponType(uid) == 1 or getItemWeaponType(uid) == 2 etc...

You can give a variable whatever value you wanna give it. Example
Code:
local sypher = "Pro"
if sypher == "Pro" then
     doPlayerSendTextMessage(cid, 22, "Sypher is a pro")
else
     doPlayerSendTextMessage(cid, 22, "Sypher is not a pro")
end

That might not be the best explanation but I hope you get it xd

You should also take a look in the Programming & Scripting Tutorials
 
Last edited:
Aha, I see.

I got another one, script by JDB

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
[COLOR="Red"][SIZE="4"]	local cfg = {
		p = {[/SIZE][/COLOR]
			wall_ = { x = 100, y = 100, z = 7 }, -- Where the wall is.
			tp = { x = 100, y = 100, z = 7 }, -- Where the teleport creates.
			to = { x = 100, y = 100, z = 7 }, -- Where the teleport takes the player.
			lever = { x = 100, y = 100, z = 7 } -- Where the lever is.
		},
		time = 10, -- Time the teleport remains open.
		level = 100, -- Level to pull the lever.
		wall_id = 1445, -- Wall item id.
		msg = "Success!" -- Message given after lever is pulled.
	}
	if(item.itemid == 1945) then
		local h = cfg.p
		if(getPlayerLevel(cid) >= cfg.level) then
			local function resetQuest()
				doCreateItem(cfg.wall_id, 1, h.wall_)
				doRemoveItem(getTileItemById(h.tp, 1387).uid)
				doTransformItem(getTileItemById(h.lever, 1946).uid, 1945)
				return true
			end
			doCreateTeleport(1387, h.to, h.tp)
			doRemoveItem(getTileItemById(h.wall_, cfg.wall_id).uid)
			doCreatureSay(cid, cfg.msg, TALKTYPE_ORANGE_1)
			addEvent(resetQuest, cfg.time * 1000)
			doTransformItem(item.uid, 1946)
		else
			doPlayerSendCancel(cid, "You must be level " .. cfg.level .. ".")
		end
	elseif(item.itemid == 1946) then
		doPlayerSendCancel(cid, "Sorry, not possible.")
		doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
	end
	return true
end

Code:
local cfg = {
	    p = {

This one is the same as the other one, but why is he using local cfg = { then under is p= { when there is no function. Why isnt cfg= { enought? He had to put another one [p= {] under it.


I also never understood Return true/false thing. Why do people use it?

Edit: I've been camping that section for a while now. Most of the threads tells the same, more basics. I think I need more than basics to gain experience :p
 
Last edited:
Lua: demo < A nice sandbox that can also be used to learn Lua.
I also never understood Return true/false thing. Why do people use it?
  • In action scripts, returning anything other than true (or nothing at all) would result in player receiving cancel message "You cannot use this object.
  • In movement scripts, it wouldn't make a difference.
  • In talkaction scripts, returning true would prevent the player from saying the talkaction words in default channel
  • In creature events, returning true would make the player login successfully if it's an onLogin script, drop loot/corpse for the creature if it's an onKill script, and vice versa.
 
Last edited:
Aha, I see.

I got another one, script by JDB

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
[COLOR=Red][SIZE=4]    local cfg = {
        p = {[/SIZE][/COLOR]
            wall_ = { x = 100, y = 100, z = 7 }, -- Where the wall is.
            tp = { x = 100, y = 100, z = 7 }, -- Where the teleport creates.
            to = { x = 100, y = 100, z = 7 }, -- Where the teleport takes the player.
            lever = { x = 100, y = 100, z = 7 } -- Where the lever is.
        },
        time = 10, -- Time the teleport remains open.
        level = 100, -- Level to pull the lever.
        wall_id = 1445, -- Wall item id.
        msg = "Success!" -- Message given after lever is pulled.
    }
    if(item.itemid == 1945) then
        local h = cfg.p
        if(getPlayerLevel(cid) >= cfg.level) then
            local function resetQuest()
                doCreateItem(cfg.wall_id, 1, h.wall_)
                doRemoveItem(getTileItemById(h.tp, 1387).uid)
                doTransformItem(getTileItemById(h.lever, 1946).uid, 1945)
                return true
            end
            doCreateTeleport(1387, h.to, h.tp)
            doRemoveItem(getTileItemById(h.wall_, cfg.wall_id).uid)
            doCreatureSay(cid, cfg.msg, TALKTYPE_ORANGE_1)
            addEvent(resetQuest, cfg.time * 1000)
            doTransformItem(item.uid, 1946)
        else
            doPlayerSendCancel(cid, "You must be level " .. cfg.level .. ".")
        end
    elseif(item.itemid == 1946) then
        doPlayerSendCancel(cid, "Sorry, not possible.")
        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
    end
    return true
end
Code:
local cfg = {
        p = {
This one is the same as the other one, but why is he using local cfg = { then under is p= { when there is no function. Why isnt cfg= { enought? He had to put another one [p= {] under it.


I also never understood Return true/false thing. Why do people use it?

Edit: I've been camping that section for a while now. Most of the threads tells the same, more basics. I think I need more than basics to gain experience :p

cfg is an array and p is another array inside cfg, you can name em as you wish.
 
Oww, that was something new. Didnt have a clue about the return true/false thing.

Alright, I got a new one. Script by masteuszx

Code:
function onSay(cid, words, param)
if(param == "") then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Use: \"!hunt [prize],[nick]\" where prize is for example 1(k).")
		return TRUE
	end
	local t = [COLOR="Red"][SIZE="4"]string.explode(param, ",")[/SIZE][/COLOR]
	if(not t[2]) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Use: \"!hunt [prize],[nick]\" where prize is for example 1(k).")
		return TRUE
	end
	
	local sp_id = getPlayerGUIDByName(t[2])
	if sp_id == nil then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] This player doesn't exists.")		
		return TRUE
	end
	
    local result_plr = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` = "..sp_id.." AND `killed` = 0;")
    if(result_plr:getID() ~= -1) then
		is = tonumber(result_plr:getDataInt("sp_id"))
		result_plr:free()
    else
		is = 0
    end
    prize = tonumber(t[1])

	if(prize == nil or prize < 1) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Use: \"!hunt [prize],[nick]\" where prize is for example 1(k).")
		return TRUE
	end
	
	if(prize >= 100000000000000000000) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Sorry, you typed too big number!")
		return TRUE
	end

	if is ~= 0 then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] This player has already hunted.")	
		return TRUE
	end
	
		if doPlayerRemoveMoney(cid, prize*1000) == TRUE then
		    db.executeQuery("INSERT INTO `bounty_hunters` VALUES (NULL,"..getPlayerGUID(cid)..","..sp_id..",0," .. os.time() .. ","..prize..",0,0);")
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Hunt has been added!")			
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] You haven't got enough money!")			
		end
	
	
	return 1
end

Code:
string.explode(param, ",")

Anyone? xD
 
Returns a table that consists of the parameter being split to several values, example:

Code:
> param = "One, two, three"
> ret = string.explode(param, ",")
> return ret
... would return a table that looks like this:
Code:
ret = { [1] = "One", [2] = "two", [3] = "three" }
If we want to call the first value, we would do:
Code:
> return ret[1]
which returns:
Code:
One
 
I see I see, not hard actually :eek: You deserv a rep++ from me Cykotitan, thanks.

I got a new one, from Shawaks thread.

Code:
        -- Annihilator by Shawak v2.1

        -- CONFIG --

        local room = {     -- room with demons
        fromX = 870,
        fromY = 1035,
        fromZ = 7,
        --------------
        toX = 875,
        toY = 1039,
        toZ = 7
        }

        local monster_pos = {
        [1] = {pos = {870, 1035, 7}, monster = "Demon"},
        [2] = {pos = {872, 1035, 7}, monster = "Demon"},
        [3] = {pos = {871, 1039, 7}, monster = "Demon"},
        [4] = {pos = {873, 1039, 7}, monster = "Demon"},
        [5] = {pos = {874, 1037, 7}, monster = "Demon"},
        [6] = {pos = {875, 1037, 7}, monster = "Demon"}
        }

        local players_pos = {
        {x = 895, y =1037, z = 7, stackpos = 253},
        {x = 895, y =1038, z = 7, stackpos = 253},
        {x = 895, y =1039, z = 7, stackpos = 253},
        {x = 895, y =1040, z = 7, stackpos = 253}
        }

        local new_player_pos = {
        {x = 873, y = 1037, z = 7},
        {x = 872, y = 1037, z = 7},
        {x = 871, y = 1037, z = 7},
        {x = 870, y = 1037, z = 7}
        }

        local playersOnly = "no"
        local questLevel = 101

        ------------------------------------------------------
        --- CONFIG END ---------------------------------------
        ------------------------------------------------------

function onUse(cid, item, fromPosition, itemEx, toPosition)
        local all_ready, monsters, player, level = 0, 0, {}, 0
        if item.itemid == 1945 then
                for i = 1, #players_pos do
                        table.insert(player, 0)
                end
                [COLOR="Red"][SIZE="3"]for i = 1,[/SIZE][/COLOR] #players_pos do
                        player[i] = getThingfromPos(players_pos[i])
                        if player[i].itemid > 0 then
                                if string.lower(playersOnly) == "yes" then
                                        if isPlayer(player[i].uid) == TRUE then
                                                all_ready = all_ready+1
                                        else
                                                monsters = monsters+1
                                        end
                                else
                                        all_ready = all_ready+1
                                end
                        end
                end
                if all_ready == #players_pos then
                        for i = 1, #players_pos do
                                player[i] = getThingfromPos(players_pos[i])
                                if isPlayer(player[i].uid) == TRUE then
                                        if getPlayerLevel(player[i].uid) >= questLevel then
                                                level = level+1
                                        end
                                else
                                        level = level+1
                                end
                        end
                        if level == #players_pos then
                                if [COLOR="Red"][SIZE="4"]string.lower[/SIZE][/COLOR](playersOnly) == "yes" and monsters == 0 or string.lower(playersOnly) == "no" then
                                        for [COLOR="Red"][SIZE="4"]_[/SIZE][/COLOR], area in pairs(monster_pos) do
                                                        doSummonCreature(area.monster,{x=area.pos[1],y=area.pos[2],z=area.pos[3]})
                                        end
                                        for i = 1, #players_pos do
                                                doSendMagicEffect(players_pos[i], CONST_ME_POFF)
                                                doTeleportThing(player[i].uid, new_player_pos[i], FALSE)
                                                doSendMagicEffect(new_player_pos[i], CONST_ME_ENERGYAREA)
                                                doTransformItem(item.uid,1946)
                                        end
                                else
                                        doPlayerSendTextMessage(cid,19,"Only players can do this quest.")
                                end
                        else
                                doPlayerSendTextMessage(cid,19,"All Players have to be level "..questLevel.." to do this quest.")
                        end
                else
                        doPlayerSendTextMessage(cid,19,"You need "..table.getn(players_pos).." players to do this quest.")
                end
        elseif item.itemid == 1946 then
                local player_room = 0
                for x = room.fromX, room.toX do
                        for y = room.fromY, room.toY do
                                for z = room.fromZ, room.toZ do
                                        local pos = {x=x, y=y, z=z,stackpos = 253}
                                        local thing = getThingfromPos(pos)
                                        if thing.itemid > 0 then
                                                if isPlayer(thing.uid) == TRUE then
                                                        player_room = player_room+1
                                                end
                                        end
                                end
                        end
                end
                if player_room >= 1 then
                        doPlayerSendTextMessage(cid,19,"There is already a team in the quest room.")          
                elseif player_room == 0 then
                        for x = room.fromX, room.toX do
                                for y = room.fromY, room.toY do
                                        for z = room.fromZ, room.toZ do
                                                local pos = {x=x, y=y, z=z,stackpos = 253}
                                                local thing = getThingfromPos(pos)
                                                if thing.itemid > 0 then
                                                        doRemoveCreature(thing.uid)
                                                end
                                        end
                                end
                        end
                        doTransformItem(item.uid,1945)
                end
        end
        return TRUE
end

Code:
for i = 1,
This one, i is used for??

and

Code:
for {_}
what is that for?

And this one too

Code:
string.lower
this one probably means if the player is lower or? xD
 
It teleports all who are in the array it's checking, in this case "players." That is probably the easiest way I can explain it, maybe someone else can explain it better.

Code:
if item.itemid = 1945 then
        local pos = { x = 100, y = 100, z = 7 }
	for i = 1, #players do
		doTeleportThing(getThingFromPos(players[i]).uid, pos)
	end
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your team has been teleported.")
	return true
end

string.lower in that anni script, is checking to see if all the players are on the correct spot, so they can be teleported.

I am short on time atm. Hope it helped some...
 
Last edited:
Didn't understand what you mean.

Code:
 i = 1, #players
is just a shorter name for players?

Is it possible to make a script like this

Code:
             local cfg {
player_pos = { x = 1000, y = 1000, z = 7 }
teleport_pos = { x = 1002, y = 1002, z = 7 }
teleport_pos2 = { x = 1003, y = 1003, z = 7 }

}

function onUse(cid, item, fromPosition, itemEx, toPosition)
for = i, #player_pos
if item.itemuid = xxxx and isPlayer(player_pos[i].uid) then
         doTeleportThing(getThingFromPos(teleport_pos]).uid, pos)

Ofcourse I have to put something before teleporting, like level req and such things, then there is cancel msg. But is it possible that this script will work?
 
Example

I doubt this works, but it's just an example.


Code:
local players = {
	{ x = 100, y = 100, z = 7, stackpos = 253 }, -- Player 1
	{ x = 100, y = 100, z = 7, stackpos = 253 } -- Player 2
}
local new_pos = { x = 100, y = 100, z = 7 }
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid = 1945 then
	for i = 1, #players do
		doTeleportThing(getThingFromPos(players[i]).uid, new_pos)
	end
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your team has been teleported.")
	return true
end
 
Aha, okej I got it now.

But now I wonder what you use:

Code:
 local players = {
	{ x = 100, y = 100, z = 7, [COLOR="Red"][B]stackpos = 253 [/B][/COLOR]},

Code:
 stackpos = 253
for? xD

EDIT: Just noticed your edit, you've helped me and thank you for that. And I'm sorry if I toke some of your time.
 
Aha, okej I got it now.

But now I wonder what you use:

Code:
 local players = {
    { x = 100, y = 100, z = 7, [COLOR=Red][B]stackpos = 253 [/B][/COLOR]},
Code:
 stackpos = 253
for? xD

EDIT: Just noticed your edit, you've helped me and thank you for that. And I'm sorry if I toke some of your time.

stackpos 253 means player or creature on tile item, stackpos 1 = first item on tile item, stackpos 2 = second item on tile item, etc ... 254 = magic field items, 255 top item or creature, stackpos 0 = ground item.
 
Alright, I got it now.

I tried to make a script that removes wall then puts it back again after x time, but unfortunately it didn't work.

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

	local wallPos = {x= 1157,y= 1291,z= 9,stackpos= 1}
	local wall = getThingFromPos(wallPos)
	local wallId = 1354
	
	if (item.itemid == 1945 and wall.itemid == wallId) then
		doRemoveItem(wall.uid, 1)
		doTransformItem(item.uid, item.itemid + 1)
		                addEvent(onTimer, 1*60*1000)
	end
	return true
end

function onTimer()             
                doCreateItem(wallId,1,wallPos)
		doTransformItem(item.uid, item.itemid-1)
end

It worked, but the addEvent was wrong or something, dont know how to make it work.
Anyone sees the problem that i made and can explain how addEvent with timer works?
 
Code:
local wallPos = {x = 1157, y = 1291, z = 9}
local wallId = 1354

local function reset(leverPos)
	doCreateItem(wallId, 1, wallPos)
	doTransformItem(getTileItemById(leverPos, 1946).uid, 1945)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)	
	if item.itemid == 1945 then
		doRemoveItem(getTileItemById(wallPos, wallId).uid)
		doTransformItem(item.uid, 1946)
		addEvent(event, 1 * 60 * 1000, toPosition)
	end
	return true
end
 
explain to me plx?

What did you change and why if you mind. Still dont get the things you made, like;
Code:
local function reset(leverPos)

Never seen that before :eek:
 
explain to me plx?

What did you change and why if you mind. Still dont get the things you made, like;
Code:
local function reset(leverPos)

Never seen that before :eek:
That wasn't really neccessary.

Okay, in your script, these values:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

[B][COLOR="Red"]	local wallPos = {x= 1157,y= 1291,z= 9,stackpos= 1}
	local wall = getThingFromPos(wallPos)
	local wallId = 1354[/COLOR][/B]
	
	if (item.itemid == 1945 and wall.itemid == wallId) then
		doRemoveItem(wall.uid, 1)
		doTransformItem(item.uid, item.itemid + 1)
		                addEvent(onTimer, 1*60*1000)
	end
	return true
end

function onTimer()             
                doCreateItem(wallId,1,wallPos)
		doTransformItem(item.uid, item.itemid-1)
end
were NOT accessible in function onTimer1, because they're local - that means they're only available within their current scope (in this case, current function because they're not inside an IF statement)

I've put them outside the function, and also fixed the event.
 
Back
Top