Jump to content

Creating pickups in a table


Xeno

Recommended Posts

local locationsTable = 
    { 
        { 0, 0, 1 }, 
        { 0, 0, 2 }, 
        { 0, 0, 3 }, 
        { 0, 0, 4 }, 
        { 0, 0, 5 }, 
        { 0, 0, 6 }, 
        { 0, 0, 7 }, 
        { 0, 0, 8 }, 
        { 0, 0, 9 }, 
        { 0, 0, 10 }, 
        { 0, 0, 11 }, 
        { 0, 0, 12 }, 
        { 0, 0, 13 }, 
        { 0, 0, 14 }, 
        { 0, 0, 15 }, 
        { 0, 0, 16 }, 
        { 0, 0, 17 }, 
        { 0, 0, 18 }, 
        { 0, 0, 19 }, 
        { 0, 0, 20 } 
    } 
  
function getRandomLocations ( ) 
    local found = { } 
    for i = 1, 10 do 
        table.insert ( 
            found, 
            locationsTable [ math.random ( #locationsTable ) ] 
        ) 
    end 
  
    return found 
end 

for index, loc in ipairs ( getRandomLocations ( ) ) do 
    local x, y, z = unpack ( loc ) 
    -- Your pickup creating code here. 
end 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...