Sorry i need to request this one :/
im lacking in knowledge, im spending to much time away from lua, i wrote a script just b4 went to run in ptokax realised id wrote it in a few differ languages :/
well anyways
i want to randomise a some lines in a file
eg
line1
line2
line3
line4
i very lacking here :/
easyest is 2 1st stuff the file into an associative array (table), by numbering the keys.
table = {["1"]=line1, etc....
for example you get 15 keys.
then you do tmp = random(15)
now you can call vallue's (lines) from the table by using table[tmp].
plop
QuoteOriginally posted by plop
easyest is 2 1st stuff the file into an associative array (table), by numbering the keys.
table = {["1"]=line1, etc....
for example you get 15 keys.
then you do tmp = random(15)
now you can call vallue's (lines) from the table by using table[tmp].
plop
hmm not exactly what im after tho :))))
just simple read stright from file and grab each line one by one, then randomize the outcome
you have this file
line1
line2
line3
line4
and want 2 make it like this?
line1
line4
line3
line2
or do you wanne pick a random like from the file?
plop
yep grab a random line, but directly from the file
never done it like that, i rather store stuff in memory as that is much faster.
but the next skips a random number of lines with a max of 15.
have the idea that this might skip the 1st line but it's up 2 you 2 solve that (easy do).
for i=1,random(15) do
read("*l")
end
line = read()
plop
QuoteOriginally posted by plop
never done it like that, i rather store stuff in memory as that is much faster.
but the next skips a random number of lines with a max of 15.
have the idea that this might skip the 1st line but it's up 2 you 2 solve that (easy do).
for i=1,random(15) do
read("*l")
end
line = read()
plop
thx plop i will give it a shot :))