Trying to make a counter, but when I run it i get this error.
I try to initialize my variable wholistcounter with this trigger.
I try to count the number of people on the who list with this trigger.
I then get this error.
The wholist looks like this normally.
The reason it is important to me. Is because I want to make and array with all the names of the players online.
Use the array to see if another player is in the room with me.
If room is clear perform an action. If not clear leave the room and move onto another room.
But first I need figure out why i am getting the error and how to fix it.
I looked at this
from:http://www.lua.org/pil/4.2.html
and I don't see the problem. Thanks for any help you can offer in fixing my issue.
Error number: 0
Event: Run-time error
Description: [string "Trigger: "]:1: attempt to perform arithmetic on global 'wholistcounter' (a nil value)
stack traceback:
[string "Trigger: "]:1: in main chunk
Called by: Immediate execution
I try to initialize my variable wholistcounter with this trigger.
<triggers>
<trigger
enabled="y"
match="*[pri sec ter qua qui hex sep oct]*"
send_to="9"
sequence="100"
variable="wholistcounter"
>
<send>wholistcounter = 0</send>
</trigger>
</triggers>
I try to count the number of people on the who list with this trigger.
<triggers>
<trigger
enabled="y"
expand_variables="y"
group="Solo"
match="[*] * *"
send_to="12"
sequence="100"
>
<send>wholistcounter = wholistcounter + 1
Send("Say there are @wholistcounter ")
</send>
</trigger>
</triggers>
I then get this error.
Error number: 0
Event: Run-time error
Description: [string "Trigger: "]:1: attempt to perform arithmetic on global 'wholistcounter' (a nil value)
stack traceback:
[string "Trigger: "]:1: in main chunk
Called by: Immediate execution
The wholist looks like this normally.
*Immortals of SlothMUD*
--------------------------------
[ *Creator* ] Splork www.wintin.org vote vote
[ *God* ] Tox #sub Nia Kolbor :)~
[pri sec ter qua qui hex sep oct] Players
--------------------------------
[ *Seer* Ma:7.38 ] Tuk !=kuT<<M.A.G.I>> HAS ICQ ADD ME!
[ *Bandit* Th:4.38 ] Burl ~Dragonsworn~
[ *Myrmidon* Wa:4.24 ] Linx ..
[40t 38w 21c 12m| 3n 12b 4d 0 ] Nookie wtb mu-jen doll and hexes
[20w 20t 20o 17b|11d 12n 9c 8m ] Warbit ...
[20t 20w 20c 10m| 0 0 0 0 ] Spuk da stabbing machine
[20w 20c 20m 10n|10b 6d 5t 4o ] Tonto saw winning as a good idea at the time.
[13m 2d 3c 1b| 1w 0 0 0 ] Emme ~
[11o 11w 11b 11t|11n 11d 11m 11c ] Alyhs the reverse
[ 9t 9o 9c 9m| 9w 9d 9n 9b ] Nassi ol thief
There are 12 visible players.
Highest total since last bootup: 38.
The reason it is important to me. Is because I want to make and array with all the names of the players online.
Use the array to see if another player is in the room with me.
If room is clear perform an action. If not clear leave the room and move onto another room.
But first I need figure out why i am getting the error and how to fix it.
I looked at this
4.2 - Local Variables and Blocks
Besides global variables, Lua supports local variables. We create local variables with the local statement:
j = 10 -- global variable
local i = 1 -- local variable
from:http://www.lua.org/pil/4.2.html
and I don't see the problem. Thanks for any help you can offer in fixing my issue.