Help using Lua tables.

Posted by Thanubrius_Black on Mon 21 Aug 2006 07:57 PM — 3 posts, 14,941 views.

#0
Hi. I'm very new to this. Just in my second week of learning Lua (and programming in general) and I'm trying to create a combat system for the MUD, Aetolia.

Say I'd like to create a table, called "herb_affs", that stores afflictions (various ailments, etc that my character can receive which could lead to his death) along with their corresponding cures, and have in that table a list of all known afflictions in Aetolia that are curable by herbs.


I'd like for this list to be prioritized, first off.

e.g.

herb_affs = {}

herb_affs.paralysis = bloodroot
herb_affs.stupidity = goldenseal


I'd want my system to cure paralysis before stupidity.

Also, how would I go about making a stringlist of the afflictions my character currently possesses?

How would I go about removing items from that stringlist?
How would I go about adding items to it?


I know I'm asking a bit, so thanks in advance to anyone kind enough to post a reply.
Amended on Mon 21 Aug 2006 07:58 PM by Thanubrius_Black
Australia Forum Administrator #1
There has been a bit of work on an afflictions table in the past. Check out these posts:

http://www.gammon.com.au/forum/?id=5514

http://www.gammon.com.au/forum/?id=6457

http://www.gammon.com.au/forum/?id=6074

The third one in particular has a lengthy treatment of handling afflictions in Lua, prioritizing them and so on.
Amended on Mon 21 Aug 2006 10:13 PM by Nick Gammon
#2
Thank you, Nick.