Alias declaring a table

Post Reply
Dyron
Posts: 14
Joined: Thu Jul 28, 2016 5:02 pm

Alias declaring a table

Post by Dyron »

I've currently got an alias that looks like such:

Code: Select all

^srec (.+)$
I want it to do the following:

Code: Select all


local itemslist = matches[2]
local storeditems = { "tin", "silver", "gold" }

for _,v in ipairs(storeditems) do
	table.insert(itemslist, v)
end

display(itemslist)

table.save(getMudletHomeDir() .. "/" .. itemslist, itemslist)
echo(string.format("Variables saved in: '%s'", getMudletHomeDir() .. itemslist))

My goal is to declare a variable by srec. In this case it'd be srec mining

itemslist would then get set to mining
I would then loop through stored items and add them to mining

I then would take the mining list and save it so I can use it as a persistent variable.

Currently it saves as a string, so I tried different code to convert it to a table but it saves over the local variable.

Code: Select all

local itemslist = matches[2]
local itemslist = {}
Any help would be appreciated.

Jor'Mox
Posts: 1146
Joined: Wed Apr 03, 2013 2:19 am

Re: Alias declaring a table

Post by Jor'Mox »

local itemslist = {matches[2]}

Post Reply