Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ Table, Array or Variable

Table, Array or Variable

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Bummer   (14 posts)  Bio
Date Tue 16 Feb 2010 09:33 PM (UTC)
Message
Hello there,


I have been working on the Trivia script for some time now, and it is very close to finished. I am having trouble finding the correct way to track the score during the game. I want to have two differnt scores tracked. One is 'all time' score (your total score saved for the WHOLE year) and the other score is that of the current game/trivia quiz.


When a player gets an answer correct, here is my trigger.

<triggers>
<trigger
enabled="y"
expand_variables="y"
group="trivia"
keep_evaluating="y"
match="Joe says, 'Congratulations, *! You are correct!'"
send_to="12"
sequence="100"
>
<send>SetVariable ("%1", (GetVariable ("%1") or 0) + 1)
SetVariable ("%1alltime", (GetVariable ("%1alltime") or 0) + 1)</send>
</trigger>
</triggers>



The "%1alltime" variable seems to work great. It will keep their saved score until I reset it.

I need a better way to track their 'current' score so I can display a small score board at the end of a quiz.

Also when I start the game and end the game, I will need to wipe this temporary score board, as my other saved variables will keep the scored from day to day.

My all time score might need to be replaced, as I would like to get it into some sortable table so that I could easily report the top ten players, and so forth.

In a nut shell...

Thank you
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 16 Feb 2010 11:29 PM (UTC)
Message
You might be better using a Lua table rather than MUSHclient variables, at least for the current score.

eg. At start of game:


scores = {}  -- wipe all scores


When someone gets something right:


scores ["%1"] = (scores ["%1"] or 0) + 1


That adds 1 to the score for player %1.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Bummer   (14 posts)  Bio
Date Reply #2 on Wed 17 Feb 2010 02:43 AM (UTC)
Message
Can I place this in the trigger?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 17 Feb 2010 03:39 AM (UTC)
Message
Yes, why not? It is just Lua code.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


12,547 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.