How to send a random command
How to send a random command
How to send a random command each time in an alias:
Re: How to send a random command
One of my biggest troubles with programming are new symbols. In the quote following quote:
What is the # doing? I've made a lot of lua scripts that have all sorts of functionality but I've never used or even seen # in lua.local which = math.random(#commands)
Re: How to send a random command
http://www.lua.org/manual/5.1/manual.html#2.5.5
for indexed tables, it's how many elements are there (holes are accounted for), for strings, it's usually how many characters
so #commands in this example is 3
for indexed tables, it's how many elements are there (holes are accounted for), for strings, it's usually how many characters
so #commands in this example is 3
Re: How to send a random command
It's the length operator. It returns the number of entries in a table, the number of characters in a string or (I think) the number of digits in a number.
Re: How to send a random command
Oh wow, that's useful. Thanks! I'll have to use it now so I can remember it!
Re: How to send a random command
Not really:
Code: Select all
> =#5
stdin:1: attempt to get length of a number value
stack traceback:
stdin:1: in main chunk
[C]: ?
>
Re: How to send a random command
Yeah, I wasn't sure about numbers.
Re: How to send a random command
It will of course work fine if you do #tostring(5)
Re: How to send a random command
No it doesn't count holes.Vadi wrote:http://www.lua.org/manual/5.1/manual.html#2.5.5
for indexed tables, it's how many elements are there (holes are accounted for), for strings, it's usually how many characters
so #commands in this example is 3