• 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 getThingFromPos to get all the value's from an array?

Mummrik

Hey!
Joined
Oct 22, 2007
Messages
707
Solutions
28
Reaction score
126
Location
Sweden
Hey i want to know a good way to get "lavaremove" get all the tiles in the "lava" array if its possible,
im quite new to scripting.
I did make it work the way i want but that way i need to make lots of more code.
btw its used inside a onUse function
Code:
  local lava = {
     [1] = {x=32805, y=32339, z=11, stackpos=0},
     [2] = {x=32805, y=32338, z=11, stackpos=0},
     [3] = {x=32805, y=32337, z=11, stackpos=0},
     [4] = {x=32806, y=32339, z=11, stackpos=0},
     [5] = {x=32806, y=32338, z=11, stackpos=0},
     [6] = {x=32806, y=32337, z=11, stackpos=0},   
     [7] = {x=32807, y=32338, z=11, stackpos=0},
     [8] = {x=32807, y=32337, z=11, stackpos=0},
     [9] = {x=32807, y=32336, z=11, stackpos=0},
     [10] = {x=32807, y=32335, z=11, stackpos=0},
     [11] = {x=32807, y=32334, z=11, stackpos=0},   
     [12] = {x=32808, y=32338, z=11, stackpos=0},
     [13] = {x=32808, y=32337, z=11, stackpos=0},
     [14] = {x=32808, y=32336, z=11, stackpos=0},
     [15] = {x=32808, y=32335, z=11, stackpos=0},
     [16] = {x=32808, y=32334, z=11, stackpos=0},
     [17] = {x=32809, y=32339, z=11, stackpos=0},
     [18] = {x=32809, y=32338, z=11, stackpos=0},
     [19] = {x=32809, y=32337, z=11, stackpos=0},
     [20] = {x=32809, y=32336, z=11, stackpos=0},
     [21] = {x=32809, y=32335, z=11, stackpos=0},
     [22] = {x=32809, y=32334, z=11, stackpos=0},
     [23] = {x=32809, y=32333, z=11, stackpos=0},   
     [24] = {x=32810, y=32339, z=11, stackpos=0},
     [25] = {x=32810, y=32338, z=11, stackpos=0},
     [26] = {x=32810, y=32337, z=11, stackpos=0},
     [27] = {x=32810, y=32336, z=11, stackpos=0},
     [28] = {x=32810, y=32335, z=11, stackpos=0},
     [29] = {x=32810, y=32334, z=11, stackpos=0},
     [30] = {x=32810, y=32333, z=11, stackpos=0},   
     [31] = {x=32811, y=32338, z=11, stackpos=0},
     [32] = {x=32811, y=32337, z=11, stackpos=0},
     [33] = {x=32811, y=32336, z=11, stackpos=0},
     [34] = {x=32811, y=32335, z=11, stackpos=0},
     [35] = {x=32811, y=32334, z=11, stackpos=0},
     [36] = {x=32811, y=32333, z=11, stackpos=0},   
     [37] = {x=32812, y=32335, z=11, stackpos=0},
     [38] = {x=32812, y=32334, z=11, stackpos=0},
     [39] = {x=32812, y=32333, z=11, stackpos=0},   
     [40] = {x=32813, y=32335, z=11, stackpos=0},
     [41] = {x=32813, y=32334, z=11, stackpos=0},
     [42] = {x=32813, y=32333, z=11, stackpos=0},   
     [43] = {x=32814, y=32335, z=11, stackpos=0},
     [44] = {x=32814, y=32334, z=11, stackpos=0},
     [45] = {x=32814, y=32333, z=11, stackpos=0}
   }
   local lavaremove = getThingFromPos(lava[1]) -- make this pick 1  up to 45


   if (itemEx.itemid == 1304 and itemEx.actionid == 8000) then
     doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
     doTransformItem(itemEx.uid, 6267)
     doTransformItem(lavaremove.uid, 5815)

     return true
   end
 
you can do this in a more proper way.

Code:
for x = lava.fromPos.x, lava.toPos.x do
          for y = lava.fromPos.y, lava.toPos.y do
                   for z = lava.fromPos.z, lava.toPos.z do
-- rest of script

This is just an example of how you'd do it.
 
you can do this in a more proper way.

Code:
for x = lava.fromPos.x, lava.toPos.x do
          for y = lava.fromPos.y, lava.toPos.y do
                   for z = lava.fromPos.z, lava.toPos.z do
-- rest of script

This is just an example of how you'd do it.

Ok, thank you for the fast replay.
I will test it
 
Code:
local lava = {
[1] = {x=32805, y=32339, z=11, stackpos=0},
[2] = {x=32805, y=32338, z=11, stackpos=0},
[3] = {x=32805, y=32337, z=11, stackpos=0},
[4] = {x=32806, y=32339, z=11, stackpos=0},
[5] = {x=32806, y=32338, z=11, stackpos=0},
[6] = {x=32806, y=32337, z=11, stackpos=0},
[7] = {x=32807, y=32338, z=11, stackpos=0},
[8] = {x=32807, y=32337, z=11, stackpos=0},
[9] = {x=32807, y=32336, z=11, stackpos=0},
[10] = {x=32807, y=32335, z=11, stackpos=0},
[11] = {x=32807, y=32334, z=11, stackpos=0},
[12] = {x=32808, y=32338, z=11, stackpos=0},
[13] = {x=32808, y=32337, z=11, stackpos=0},
[14] = {x=32808, y=32336, z=11, stackpos=0},
[15] = {x=32808, y=32335, z=11, stackpos=0},
[16] = {x=32808, y=32334, z=11, stackpos=0},
[17] = {x=32809, y=32339, z=11, stackpos=0},
[18] = {x=32809, y=32338, z=11, stackpos=0},
[19] = {x=32809, y=32337, z=11, stackpos=0},
[20] = {x=32809, y=32336, z=11, stackpos=0},
[21] = {x=32809, y=32335, z=11, stackpos=0},
[22] = {x=32809, y=32334, z=11, stackpos=0},
[23] = {x=32809, y=32333, z=11, stackpos=0},
[24] = {x=32810, y=32339, z=11, stackpos=0},
[25] = {x=32810, y=32338, z=11, stackpos=0},
[26] = {x=32810, y=32337, z=11, stackpos=0},
[27] = {x=32810, y=32336, z=11, stackpos=0},
[28] = {x=32810, y=32335, z=11, stackpos=0},
[29] = {x=32810, y=32334, z=11, stackpos=0},
[30] = {x=32810, y=32333, z=11, stackpos=0},
[31] = {x=32811, y=32338, z=11, stackpos=0},
[32] = {x=32811, y=32337, z=11, stackpos=0},
[33] = {x=32811, y=32336, z=11, stackpos=0},
[34] = {x=32811, y=32335, z=11, stackpos=0},
[35] = {x=32811, y=32334, z=11, stackpos=0},
[36] = {x=32811, y=32333, z=11, stackpos=0},
[37] = {x=32812, y=32335, z=11, stackpos=0},
[38] = {x=32812, y=32334, z=11, stackpos=0},
[39] = {x=32812, y=32333, z=11, stackpos=0},
[40] = {x=32813, y=32335, z=11, stackpos=0},
[41] = {x=32813, y=32334, z=11, stackpos=0},
[42] = {x=32813, y=32333, z=11, stackpos=0},
[43] = {x=32814, y=32335, z=11, stackpos=0},
[44] = {x=32814, y=32334, z=11, stackpos=0},
[45] = {x=32814, y=32333, z=11, stackpos=0}
}

for i =1, #lava do
local lavaremove = getThingFromPos(lava[i]) -- make this pick 1 up to 45
if (itemEx.itemid == 1304 and itemEx.actionid == 8000) then
doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
doTransformItem(itemEx.uid, 6267)
doTransformItem(lavaremove.uid, 5815)
end


return true
end
 
Code:
local lava = {
[1] = {x=32805, y=32339, z=11, stackpos=0},
[2] = {x=32805, y=32338, z=11, stackpos=0},
[3] = {x=32805, y=32337, z=11, stackpos=0},
[4] = {x=32806, y=32339, z=11, stackpos=0},
[5] = {x=32806, y=32338, z=11, stackpos=0},
[6] = {x=32806, y=32337, z=11, stackpos=0},
[7] = {x=32807, y=32338, z=11, stackpos=0},
[8] = {x=32807, y=32337, z=11, stackpos=0},
[9] = {x=32807, y=32336, z=11, stackpos=0},
[10] = {x=32807, y=32335, z=11, stackpos=0},
[11] = {x=32807, y=32334, z=11, stackpos=0},
[12] = {x=32808, y=32338, z=11, stackpos=0},
[13] = {x=32808, y=32337, z=11, stackpos=0},
[14] = {x=32808, y=32336, z=11, stackpos=0},
[15] = {x=32808, y=32335, z=11, stackpos=0},
[16] = {x=32808, y=32334, z=11, stackpos=0},
[17] = {x=32809, y=32339, z=11, stackpos=0},
[18] = {x=32809, y=32338, z=11, stackpos=0},
[19] = {x=32809, y=32337, z=11, stackpos=0},
[20] = {x=32809, y=32336, z=11, stackpos=0},
[21] = {x=32809, y=32335, z=11, stackpos=0},
[22] = {x=32809, y=32334, z=11, stackpos=0},
[23] = {x=32809, y=32333, z=11, stackpos=0},
[24] = {x=32810, y=32339, z=11, stackpos=0},
[25] = {x=32810, y=32338, z=11, stackpos=0},
[26] = {x=32810, y=32337, z=11, stackpos=0},
[27] = {x=32810, y=32336, z=11, stackpos=0},
[28] = {x=32810, y=32335, z=11, stackpos=0},
[29] = {x=32810, y=32334, z=11, stackpos=0},
[30] = {x=32810, y=32333, z=11, stackpos=0},
[31] = {x=32811, y=32338, z=11, stackpos=0},
[32] = {x=32811, y=32337, z=11, stackpos=0},
[33] = {x=32811, y=32336, z=11, stackpos=0},
[34] = {x=32811, y=32335, z=11, stackpos=0},
[35] = {x=32811, y=32334, z=11, stackpos=0},
[36] = {x=32811, y=32333, z=11, stackpos=0},
[37] = {x=32812, y=32335, z=11, stackpos=0},
[38] = {x=32812, y=32334, z=11, stackpos=0},
[39] = {x=32812, y=32333, z=11, stackpos=0},
[40] = {x=32813, y=32335, z=11, stackpos=0},
[41] = {x=32813, y=32334, z=11, stackpos=0},
[42] = {x=32813, y=32333, z=11, stackpos=0},
[43] = {x=32814, y=32335, z=11, stackpos=0},
[44] = {x=32814, y=32334, z=11, stackpos=0},
[45] = {x=32814, y=32333, z=11, stackpos=0}
}

for i =1, #lava do
local lavaremove = getThingFromPos(lava[i]) -- make this pick 1 up to 45
if (itemEx.itemid == 1304 and itemEx.actionid == 8000) then
doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
doTransformItem(itemEx.uid, 6267)
doTransformItem(lavaremove.uid, 5815)
end


return true
end

It did not work as i wanted, it did only pick the first position and not the other ones

Edit: btw i do use an old tfs 0.3.6 (Crying Damson)
 
Last edited:
Code:
local lava = {
    [1] =  {x = 32805, y = 32339, z = 11, stackpos = 0},
    [2] =  {x = 32805, y = 32338, z = 11, stackpos = 0},
    [3] =  {x = 32805, y = 32337, z = 11, stackpos = 0},
    [4] =  {x = 32806, y = 32339, z = 11, stackpos = 0},
    [5] =  {x = 32806, y = 32338, z = 11, stackpos = 0},
    [6] =  {x = 32806, y = 32337, z = 11, stackpos = 0},  
    [7] =  {x = 32807, y = 32338, z = 11, stackpos = 0},
    [8] =  {x = 32807, y = 32337, z = 11, stackpos = 0},
    [9] =  {x = 32807, y = 32336, z = 11, stackpos = 0},
    [10] = {x = 32807, y = 32335, z = 11, stackpos = 0},
    [11] = {x = 32807, y = 32334, z = 11, stackpos = 0},  
    [12] = {x = 32808, y = 32338, z = 11, stackpos = 0},
    [13] = {x = 32808, y = 32337, z = 11, stackpos = 0},
    [14] = {x = 32808, y = 32336, z = 11, stackpos = 0},
    [15] = {x = 32808, y = 32335, z = 11, stackpos = 0},
    [16] = {x = 32808, y = 32334, z = 11, stackpos = 0},
    [17] = {x = 32809, y = 32339, z = 11, stackpos = 0},
    [18] = {x = 32809, y = 32338, z = 11, stackpos = 0},
    [19] = {x = 32809, y = 32337, z = 11, stackpos = 0},
    [20] = {x = 32809, y = 32336, z = 11, stackpos = 0},
    [21] = {x = 32809, y = 32335, z = 11, stackpos = 0},
    [22] = {x = 32809, y = 32334, z = 11, stackpos = 0},
    [23] = {x = 32809, y = 32333, z = 11, stackpos = 0},  
    [24] = {x = 32810, y = 32339, z = 11, stackpos = 0},
    [25] = {x = 32810, y = 32338, z = 11, stackpos = 0},
    [26] = {x = 32810, y = 32337, z = 11, stackpos = 0},
    [27] = {x = 32810, y = 32336, z = 11, stackpos = 0},
    [28] = {x = 32810, y = 32335, z = 11, stackpos = 0},
    [29] = {x = 32810, y = 32334, z = 11, stackpos = 0},
    [30] = {x = 32810, y = 32333, z = 11, stackpos = 0},  
    [31] = {x = 32811, y = 32338, z = 11, stackpos = 0},
    [32] = {x = 32811, y = 32337, z = 11, stackpos = 0},
    [33] = {x = 32811, y = 32336, z = 11, stackpos = 0},
    [34] = {x = 32811, y = 32335, z = 11, stackpos = 0},
    [35] = {x = 32811, y = 32334, z = 11, stackpos = 0},
    [36] = {x = 32811, y = 32333, z = 11, stackpos = 0},  
    [37] = {x = 32812, y = 32335, z = 11, stackpos = 0},
    [38] = {x = 32812, y = 32334, z = 11, stackpos = 0},
    [39] = {x = 32812, y = 32333, z = 11, stackpos = 0},  
    [40] = {x = 32813, y = 32335, z = 11, stackpos = 0},
    [41] = {x = 32813, y = 32334, z = 11, stackpos = 0},
    [42] = {x = 32813, y = 32333, z = 11, stackpos = 0},  
    [43] = {x = 32814, y = 32335, z = 11, stackpos = 0},
    [44] = {x = 32814, y = 32334, z = 11, stackpos = 0},
    [45] = {x = 32814, y = 32333, z = 11, stackpos = 0}
}

-- function onUse???
    -- is this only supposed to check the original tile?
    -- like use bucket of water on lava, and make all 'hardened lava'?..
    -- well here's hoping.
    if itemEx.itemid == 1304 and itemEx.actionid == 8000 then
        doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
        doTransformItem(itemEx.uid, 6267)
        for i = 1, #lava do
            doTransformItem(getThingFromPos(lava[i]).uid, 5815)
        end
    end

    return true
end
 
Code:
local lava = {
    [1] =  {x = 32805, y = 32339, z = 11, stackpos = 0},
    [2] =  {x = 32805, y = 32338, z = 11, stackpos = 0},
    [3] =  {x = 32805, y = 32337, z = 11, stackpos = 0},
    [4] =  {x = 32806, y = 32339, z = 11, stackpos = 0},
    [5] =  {x = 32806, y = 32338, z = 11, stackpos = 0},
    [6] =  {x = 32806, y = 32337, z = 11, stackpos = 0},
    [7] =  {x = 32807, y = 32338, z = 11, stackpos = 0},
    [8] =  {x = 32807, y = 32337, z = 11, stackpos = 0},
    [9] =  {x = 32807, y = 32336, z = 11, stackpos = 0},
    [10] = {x = 32807, y = 32335, z = 11, stackpos = 0},
    [11] = {x = 32807, y = 32334, z = 11, stackpos = 0},
    [12] = {x = 32808, y = 32338, z = 11, stackpos = 0},
    [13] = {x = 32808, y = 32337, z = 11, stackpos = 0},
    [14] = {x = 32808, y = 32336, z = 11, stackpos = 0},
    [15] = {x = 32808, y = 32335, z = 11, stackpos = 0},
    [16] = {x = 32808, y = 32334, z = 11, stackpos = 0},
    [17] = {x = 32809, y = 32339, z = 11, stackpos = 0},
    [18] = {x = 32809, y = 32338, z = 11, stackpos = 0},
    [19] = {x = 32809, y = 32337, z = 11, stackpos = 0},
    [20] = {x = 32809, y = 32336, z = 11, stackpos = 0},
    [21] = {x = 32809, y = 32335, z = 11, stackpos = 0},
    [22] = {x = 32809, y = 32334, z = 11, stackpos = 0},
    [23] = {x = 32809, y = 32333, z = 11, stackpos = 0},
    [24] = {x = 32810, y = 32339, z = 11, stackpos = 0},
    [25] = {x = 32810, y = 32338, z = 11, stackpos = 0},
    [26] = {x = 32810, y = 32337, z = 11, stackpos = 0},
    [27] = {x = 32810, y = 32336, z = 11, stackpos = 0},
    [28] = {x = 32810, y = 32335, z = 11, stackpos = 0},
    [29] = {x = 32810, y = 32334, z = 11, stackpos = 0},
    [30] = {x = 32810, y = 32333, z = 11, stackpos = 0},
    [31] = {x = 32811, y = 32338, z = 11, stackpos = 0},
    [32] = {x = 32811, y = 32337, z = 11, stackpos = 0},
    [33] = {x = 32811, y = 32336, z = 11, stackpos = 0},
    [34] = {x = 32811, y = 32335, z = 11, stackpos = 0},
    [35] = {x = 32811, y = 32334, z = 11, stackpos = 0},
    [36] = {x = 32811, y = 32333, z = 11, stackpos = 0},
    [37] = {x = 32812, y = 32335, z = 11, stackpos = 0},
    [38] = {x = 32812, y = 32334, z = 11, stackpos = 0},
    [39] = {x = 32812, y = 32333, z = 11, stackpos = 0},
    [40] = {x = 32813, y = 32335, z = 11, stackpos = 0},
    [41] = {x = 32813, y = 32334, z = 11, stackpos = 0},
    [42] = {x = 32813, y = 32333, z = 11, stackpos = 0},
    [43] = {x = 32814, y = 32335, z = 11, stackpos = 0},
    [44] = {x = 32814, y = 32334, z = 11, stackpos = 0},
    [45] = {x = 32814, y = 32333, z = 11, stackpos = 0}
}

-- function onUse???
    -- is this only supposed to check the original tile?
    -- like use bucket of water on lava, and make all 'hardened lava'?..
    -- well here's hoping.
    if itemEx.itemid == 1304 and itemEx.actionid == 8000 then
        doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
        doTransformItem(itemEx.uid, 6267)
        for i = 1, #lava do
            doTransformItem(getThingFromPos(lava[i]).uid, 5815)
        end
    end

    return true
end

This is a part in my pick script, thats why it didnt list function onUse since i didnt want to post everything in the script.
This is to break a stone after the oil lever in poi and get hardened lava where it use to be lava.

Yes its supposed to get the tile itemid from all the locations so doTransfromItem() will know what it should transform

I will try your code and reply if it works

Edit: It did work as it should. Thank you for helping, and letting me know how to use arrays in a new way :)
 
Last edited:

Similar threads

Back
Top