Hello
Guest
Register
Login
1 Hour
1 Day
1 Week
1 Month
Forever
DiceBots moneypot app is online again!
https://dice.seuntjie.com
- Get rolling!
Menu
Home
Help
Search
Login
Register
go
Seuntjies DiceBot
DiceBot
Programmer Mode
avoiding a long serie of similar lines
« previous
next »
Print
Pages: [
1
]
avoiding a long serie of similar lines
4 Replies
202 Views
parisd
14
+0/-0
avoiding a long serie of similar lines
«
on:
November 26, 2020, 04:28:48 pm »
I am trying to escape from writing by hand a long number of similar lines like
Bet1 = 0;
Bet2 = 0;
...
Bet100 = 0;
using the equivalent of
for i=1 to 100
Beti = 0
next
or
for i=1 to 100
Bet(i) = 0
next
any proposal?
Thanks
Logged
Seuntjie
549
+14/-2
Re: avoiding a long serie of similar lines
«
Reply #1 on:
November 26, 2020, 05:05:07 pm »
What are yo trying to achieve?
Logged
parisd
14
+0/-0
Re: avoiding a long serie of similar lines
«
Reply #2 on:
November 26, 2020, 07:33:27 pm »
Quote from: Seuntjie on November 26, 2020, 05:05:07 pm
What are yo trying to achieve?
too long to explain here but trying to avoid to write by hand too many line of code, for example for the following
B13 = B12
B12 = B11
B11 = B10
B10 = B9
B9 = B8
B8 = B7
B7 = B6
B6 = B5
B5 = B4
B4 = B3
B3 = B2
B2 = B1
Logged
Seuntjie
549
+14/-2
Re: avoiding a long serie of similar lines
«
Reply #3 on:
November 27, 2020, 07:21:06 am »
It's impossible to give you a solution without knowing what you're trying to do with your script. It's quite possible that a simple sum, multiplication and/or modulu can solve your problem.
The best answer I can give now, without context, is to look into arrays and for loops.
https://www.lua.org/pil/11.1.html
Logged
parisd
14
+0/-0
Re: avoiding a long serie of similar lines
«
Reply #4 on:
November 29, 2020, 02:55:11 pm »
thanks you for the link, I did not know it was called array.
I tried the simplest one
b = {}
for i = 1,200 do
b[ i ] = 1
end
and I receives the following error in the console : Attempt to compare with nil ??
Tks
«
Last Edit: November 29, 2020, 04:01:53 pm by parisd
»
Logged
Print
Pages: [
1
]
« previous
next »