Log In  
Follow
ZKMC
[ :: Read More :: ]

When setting 2 table elements to the same function it returns the same output, I am trying to figure out how to "refresh" the function so it will generate a new random string each time I need to set a variable to that function. Provide below is said code; hopefully the comments make sense. Thanks In advance.

idtable={"aaaaaa","aaaaaa"}
id=""
i=0
x=0

function idgen()
 if i!= 3 then --i loop to generate 3 random numbers
  x=flr(rnd(16)) --picks a number between 0-15
  if (x<10) then --ensures single digits have 0 appended to the front to maintain fixed string length
   id=id.."0"..x
  else
   id=id..x
  end
  i+=1
 end    
return id
end

function _update()
end

function _draw()
cls()
idtable[1]=idgen(id) 
idtable[2]=idgen(id) --doesn't generate new random string

print(idtable[1],0,0,7)
print(idtable[2],0,8,7)
end
P#62972 2019-03-23 08:11

Follow Lexaloffle:          
Generated 2024-04-18 23:08:13 | 0.069s | Q:5