to elaborate, how would i get the missile to use a random mesh and texture id from an table i really dont know where to start, ive read the wiki, tried googling for a solution and probably some more. this is what i have right now
local mesh = {55,33,16,4} local texture = {22,6,11,5}
so yeah i want the meshid to match the textureid lets say that the meshid is 55, then i want the textureid to be 22 meshid is 33, textureid is 6 and so on
One really simple way to do this is to use a numeric for
loop:
local mesh = {55, 33, 16, 4} local texture = {22, 6, 11, 5} local Storage = {} -- Make a table to store patterns for i = 1, #mesh do -- This doesn't really matter because I'm assuming that your tables are going to have equal lengths anyway table.insert(Storage, mesh[i]) table.insert(Storage, texture[i]) end
If you otherwise want it to be completely randomized, I would use math.random()
:
local mesh = {55, 33, 16, 4} local texture = {22, 6, 11, 5} local Storage = {} -- Make a table to store randomized patterns local ChosenMesh = mesh[math.random(1, #mesh)] local ChosenTexture = texture[math.random(1, #texture)] table.insert(Storage, ChosenMesh) table.insert(Storage, ChosenTexture)
Using a for
loop to get the values by index places them in a table so that for every 2 values in a table the pattern is mesh[i]
followed by texture[i]
. Using math.random()
randomly selects them from the tables and stores them in random patterns.