• 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 My script and table dont work

megachock

Member
Joined
Mar 12, 2009
Messages
115
Reaction score
7
Well i have made this script with a bit help from summ, now i tried to add some new functions and organize it on a table but i dont know why it dont works...
When 4 items is in a correct position this teleport you to a new position also the items came back to the position they was..

Im just new on scripting :/

UPDATE
I made the first table work but it dont send de message also the timer dont works
Lua:
             local red = {initalps = {x = 1912, y = 932, z = 10},
                          pos = {x = 1911, y = 935, z = 10, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE},
                          items = 9976
                           }
             local blue = {initalps = {x = 1912, y = 933, z = 10},
                           pos = {x = 1911, y = 932, z = 10, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE},
                           items = 9977
                           }
             local lightblue = {initalps = {x = 1912, y = 934, z = 10},
                                pos = {x = 1911, y = 934, z = 10, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE},
                                items = 9978
                                }
             local green = {initalps = {x = 1912, y = 935, z = 10},
                            pos = {x = 1911, y = 933, z = 10, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE},
                            items = 9979
                             }
local event = 0


    local pred = getThingFromPos(red.pos)
    local pblue = getThingFromPos(blue.pos)
    local plightblue = getThingFromPos(lightblue.pos)
    local pgreen = getThingFromPos(green.pos)

local function reset(leverPos)
        local lever = getTileItemById(leverPos, 1946).uid
	      doTransformItem(lever, 1945)
                   doRemoveItem(getTileItemById(pred,red.items).uid)
                   doRemoveItem(getTileItemById(pblue,blue.items).uid)
                   doRemoveItem(getTileItemById(plightblue,lightblue.items).uid)
                   doRemoveItem(getTileItemById(pgreen,green.items).uid)
		doCreateItem(red.items, 1, red.initalps)
		doCreateItem(blue.items, 1, blue.initialps)
		doCreateItem(lightblue.items, 1, lightblue.initialps)
		doCreateItem(green.items, 1, green.initialps)
               end

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


    if pred.itemid == red.items and pblue.itemid == blue.items and plightblue.itemid == lightblue.items and pgreen.itemid == green.items then
    doTeleportThing(cid, {x = 1917, y = 934, z = 10})
    doPlayerSendMessage(cid,21,"Nice calculation!")
    event = addEvent(reset, 7 * 1000, getThingPos(item.uid))
		doTransformItem(item.uid,item.itemid+1)
else
    doPlayerSendCancel(cid, "The position of the items is wrong!")
  end
  return true
end

- - - Updated - - -

Help me pls :/

- - - Updated - - -

buump
 
Last edited:
try this and see.

Lua:
local red = {
    initalps = {x = 1912, y = 932, z = 10},
    pos = {x = 1911, y = 935, z = 10, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE},
    items = 9976
}
local blue = {
    initalps = {x = 1912, y = 933, z = 10},
    pos = {x = 1911, y = 932, z = 10, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE},
    items = 9977
}
local lightblue = {
    initalps = {x = 1912, y = 934, z = 10},
    pos = {x = 1911, y = 934, z = 10, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE},
    items = 9978
}
local green = {
    initalps = {x = 1912, y = 935, z = 10},
    pos = {x = 1911, y = 933, z = 10, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE},
    items = 9979
}

local event = 0
 
local function reset(leverPos)
    local lever = getTileItemById(leverPos, 1946).uid
    doTransformItem(lever, 1945)
    doRemoveItem(getTileItemById(pred,red.items).uid)
    doRemoveItem(getTileItemById(pblue,blue.items).uid)
    doRemoveItem(getTileItemById(plightblue,lightblue.items).uid)
    doRemoveItem(getTileItemById(pgreen,green.items).uid)
    doCreateItem(red.items, 1, red.initalps)
    doCreateItem(blue.items, 1, blue.initialps)
    doCreateItem(lightblue.items, 1, lightblue.initialps)
    doCreateItem(green.items, 1, green.initialps)
end
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
  
local pred = getThingFromPos(red.pos)
local pblue = getThingFromPos(blue.pos)
local plightblue = getThingFromPos(lightblue.pos)
local pgreen = getThingFromPos(green.pos)

    if pred.itemid == red.items and pblue.itemid == blue.items and plightblue.itemid == lightblue.items and pgreen.itemid == green.items then
        doTeleportThing(cid, {x = 1917, y = 934, z = 10})
        doPlayerSendMessage(cid,21,"Nice calculation!")
        event = addEvent(reset, 7 * 1000, getThingPos(item.uid))
		doTransformItem(item.uid,item.itemid+1)
    else
        doPlayerSendCancel(cid, "The position of the items is wrong!")
    end
return true
end
 
The event reset dont works, i think the event make the items came back to the initialps and the lever dont transform to 1946 :/, also i get this error
Lua:
[01/03/2013 22:38:22] [Error - Action Interface] 
[01/03/2013 22:38:22] data/actions/scripts/secretdg/weas1.lua:onUse
[01/03/2013 22:38:22] Description: 
[01/03/2013 22:38:22] data/actions/scripts/secretdg/weas1.lua:46: attempt to call global 'doPlayerSendMessage' (a nil value)
[01/03/2013 22:38:22] stack traceback:
[01/03/2013 22:38:22] 	data/actions/scripts/secretdg/weas1.lua:46: in function <data/actions/scripts/secretdg/weas1.lua:37>

PD: Porfin alguien me responde y lo mejor que hablas español :D
 
try this and see.

Lua:
local red = {
    initalps = {x = 1912, y = 932, z = 10},
    pos = {x = 1911, y = 935, z = 10, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE},
    items = 9976
}
local blue = {
    initalps = {x = 1912, y = 933, z = 10},
    pos = {x = 1911, y = 932, z = 10, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE},
    items = 9977
}
local lightblue = {
    initalps = {x = 1912, y = 934, z = 10},
    pos = {x = 1911, y = 934, z = 10, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE},
    items = 9978
}
local green = {
    initalps = {x = 1912, y = 935, z = 10},
    pos = {x = 1911, y = 933, z = 10, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE},
    items = 9979
}

local event = 0
 
local function reset(leverPos)
    local lever = getTileItemById(leverPos, 1946).uid
    doTransformItem(lever, 1945)
    doRemoveItem(getTileItemById(pred,red.items).uid)
    doRemoveItem(getTileItemById(pblue,blue.items).uid)
    doRemoveItem(getTileItemById(plightblue,lightblue.items).uid)
    doRemoveItem(getTileItemById(pgreen,green.items).uid)
    doCreateItem(red.items, 1, red.initalps)
    doCreateItem(blue.items, 1, blue.initialps)
    doCreateItem(lightblue.items, 1, lightblue.initialps)
    doCreateItem(green.items, 1, green.initialps)
end
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
  
local pred = getThingFromPos(red.pos)
local pblue = getThingFromPos(blue.pos)
local plightblue = getThingFromPos(lightblue.pos)
local pgreen = getThingFromPos(green.pos)

    if pred.itemid == red.items and pblue.itemid == blue.items and plightblue.itemid == lightblue.items and pgreen.itemid == green.items then
        doTeleportThing(cid, {x = 1917, y = 934, z = 10})
        doPlayerSendMessage(cid,21,"Nice calculation!")
        event = addEvent(reset, 7 * 1000, getThingPos(item.uid))
		doTransformItem(item.uid,item.itemid+1)
    else
        doPlayerSendCancel(cid, "The position of the items is wrong!")
    end
return true
end

According to his errors, doPlayerSendMessage is nil and

Lua:
local pred = getThingFromPos(red.pos)
local pblue = getThingFromPos(blue.pos)
local plightblue = getThingFromPos(lightblue.pos)
local pgreen = getThingFromPos(green.pos)
doesn't work, try using isInArray
 
i made it work!! but it dont send any message to the player also how i add effects, i try but dont works
Lua:
local ppos = {x = 1917, y = 934, z = 10}
local red = {
    inips = {x = 1912, y = 932, z = 10, stackpos=1},
    pos = {x = 1911, y = 935, z = 10, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE},
    items = 9976
}
local blue = {
    inips = {x = 1912, y = 933, z = 10, stackpos=1},
    pos = {x = 1911, y = 932, z = 10, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE},
    items = 9977
}
local lblue = {
    inips = {x = 1912, y = 934, z = 10, stackpos=1},
    pos = {x = 1911, y = 934, z = 10, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE},
    items = 9978
}
local green = {
    inips = {x = 1912, y = 935, z = 10, stackpos=1},
    pos = {x = 1911, y = 933, z = 10, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE},
    items = 9979
}
 
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
local pred = getThingFromPos(red.pos)
local pblue = getThingFromPos(blue.pos)
local plblue = getThingFromPos(lblue.pos)
local pgreen = getThingFromPos(green.pos)
 
    if pred.itemid == red.items and pblue.itemid == blue.items and plblue.itemid == lblue.items and pgreen.itemid == green.items then
          doSendMagicEffect(ppos,2)
          doTeleportThing(cid, ppos)
    doRemoveItem(getTileItemById(red.pos,red.items).uid)
     doCreateItem(red.items, 1, red.inips)
    doRemoveItem(getTileItemById(blue.pos,blue.items).uid)
     doCreateItem(blue.items, 1, blue.inips)
    doRemoveItem(getTileItemById(lblue.pos,lblue.items).uid)
     doCreateItem(lblue.items, 1, lblue.inips)
    doRemoveItem(getTileItemById(green.pos,green.items).uid)
     doCreateItem(green.items, 1, green.inips)

          doPlayerSendMessage(cid,21,"Nice calculation!")
  

    else
        doPlayerSendCancel(cid, "The position of the items is wrong!")
    end
return true
end
 
Back
Top