• 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 nil value. replacing a portal

soul4soul

Intermediate OT User
Joined
Aug 13, 2007
Messages
1,875
Solutions
3
Reaction score
128
Location
USA
Code:
    portalPos = {
        {x=141, y=856, z=8, stackpos=1},
        {x=150, y=864, z=8, stackpos=1},
        {x=143, y=872, z=8, stackpos=1},
        {x=133, y=864, z=8, stackpos=1}
    }

line 105 to 107
Code:
            local port = math.random(1,4)
            doRemoveItem(getThingFromPos(portalPos[port]).uid, 1)
            escape = doCreateTeleport(1387, {x=142, y=857, z=4}, portalPos[port])
code is suppose to remove the randomly chosen portal and create a new one in its place

error:
Code:
[31/10/2010 19:12:12] [Error - Action Interface] 
[31/10/2010 19:12:12] data/actions/scripts/quests/bquest.lua:onUse
[31/10/2010 19:12:12] Description: 
[31/10/2010 19:12:12] data/actions/scripts/quests/bquest.lua:106: attempt to index global 'portalPos' (a nil value)
[31/10/2010 19:12:12] stack traceback:
[31/10/2010 19:12:12]     data/actions/scripts/quests/bquest.lua:106: in function <data/actions/scripts/quests/bombquest.lua:89>

portalqc.png


let me know if you need to see more code
 
Last edited:
what are you trying to do?

@Tauku
dam man ur signature wtf is he doing to that girl first time he saw a chick or some thing?
 
its suppose to select a random portal. then it removes that portal and in the same place a new one is created
escape = doCreateTeleport(1387, {x=142, y=857, z=4}, portalPos[port])
creates a portal id 1387 leads to pos {142,857,4}, and the position of this new portal will be selected from the table portalPos
 
try this
Lua:
    portalPos = {
        portal1 = {x=141, y=856, z=8, stackpos=1},
        portal2 = {x=150, y=864, z=8, stackpos=1},
        portal3 =  {x=143, y=872, z=8, stackpos=1},
        portal4 =   {x=133, y=864, z=8, stackpos=1}
    }

Lua:
      local port = math.random(1, 4)
            doRemoveItem(getThingFromPos(portalPos.portal""..port..""))
            escape = doCreateTeleport(1387, {x=142, y=857, z=4},portalPos.portal""..port.."")
 
Last edited:
REP ++ please !!

replace lines 105 to 107 to this code:

local portalPos = {
{x=141, y=856, z=8, stackpos=1},
{x=150, y=864, z=8, stackpos=1},
{x=143, y=872, z=8, stackpos=1},
{x=133, y=864, z=8, stackpos=1}
}

local port = math.random(1,4)
doRemoveItem(getThingFromPos(portalPos[port]).uid, 1)
escape = doCreateTeleport(1387, {x=142, y=857, z=4}, portalPos[port])
 
try this
Lua:
    portalPos = {
        portal1 = {x=141, y=856, z=8, stackpos=1},
        portal2 = {x=150, y=864, z=8, stackpos=1},
        portal3 =  {x=143, y=872, z=8, stackpos=1},
        portal4 =   {x=133, y=864, z=8, stackpos=1}
    }

Lua:
      local port = math.random(1, 4)
            doRemoveItem(getThingFromPos(portalPos.portal""..port..""))
            escape = doCreateTeleport(1387, {x=142, y=857, z=4},portalPos.portal""..port.."")
thanks for the idea. when i was looking at your code i realized my mistake rep++ (acutally it wont let me rep you maybe i already did? says i need to spread some)
REP ++ please !!

replace lines 105 to 107 to this code:
you didnt change anything
 
Back
Top