Table / Array in Mush

Posted by Tkl1129 on Fri 08 Jul 2011 02:02 AM — 5 posts, 25,206 views.

Hong Kong #0
Is me again~~~ :D

I'm learning about Array / Table function right now :D..
there are few questions about that. As I learn about that is very powerful, can store many data just like Cmuds database variables (.dbvar), in different format...list inside a list....but...I have few questions about that.

1. I want to manage a large database just like a room_name, room_directions, path of comming, path of leaving, npc's name in this room, room type, area name...zone name...
there were over 10+ tittle and the content of each tittle are strings, may be more than 1 string, many strings....also over 1000+ records...
i. many tittle
ii.long contents of each tittle
iii. over 1000+ records.

in this case, do array still good? I think it can use but very hard to manage...-.-"...in this case do I'm able to look SQL database?

2. If I want make some Global stored record in table, am I able to write it to script file?

3. actually...my question I think is asking for a database table like cmud's DB...XD...any plugin can make this easily?

USA #1
Lua tables are both arrays and "databases" rolled into one.

-- Table used as an array
local arr = {"hi", "hmm", "foobar"}

-- Table used as a hash
local hash = {
  foo = 42,
  bar = 200,
  twisol = 1337,
}

-- Table used as both!
local mixed = {
  "a", "b", "c",
  stuff = 50,
}


Array entries (items in a table with no key =) are automatically given a numeric key, so in mixed above you'd use mixed[3] to get "c", and mixed["stuff"] to get 50.

I'm not sure what you mean in your second question, can you explain?
USA Global Moderator #2
Quote:
"databases"

I think you mean dictionaries.
USA #3
Hence the quotes. I was using his term because that's what he's familiar with, and tables are a passable analog to zmud databases anyways.
Australia Forum Administrator #4
Tkl1129 said:

in this case, do array still good? I think it can use but very hard to manage...-.-"...in this case do I'm able to look SQL database?



1000 records isn't large. 10,000 or 100,000 can easily be handled by tables.

However you can also use SQLite3 databases (that is SQL). There is a lot of support for that in the client, see:

http://mushclient.com/db

http://mushclient.com/sql