I'm writing a plugin for a mud which lets me automate the process of investing items with power. The plugin has variables for source and destination containers, among others.
I'm using var to write the arrays back into the plugin file so that players don't have to specify it every time they load the game. However, when I do a save state, I neither get a save state file in my state folder, nor do the variables get updated in the plugin. Any clue? Be kind, as I am new to scripting. :)
Below is one of the offending blocks of code:
-- Update: I think I figured it out. For one, the var module dispenses with lua's case sensitivity -- SB_Source_Container becomes sb_source_container, for example. For another, I apparently couldn't use the same variable name for the world file as the lua arrays they would be imported into.
I know this is very much simplistic compared to serialization, but it makes more sense to my beginner's brain.
[EDIT] Updated code to "escape" square brackets.
I'm using var to write the arrays back into the plugin file so that players don't have to specify it every time they load the game. However, when I do a save state, I neither get a save state file in my state folder, nor do the variables get updated in the plugin. Any clue? Be kind, as I am new to scripting. :)
Below is one of the offending blocks of code:
<trigger
enabled="y"
group="SB_Variable"
match="^Destination\_Container\_You insult (.+)\.$"
omit_from_output="y"
regexp="y"
send_to="14"
sequence="100"
>
<send>require "var"
SB_Destination_Container = utils.split("%1", " ") -- Create table of keywords for the destination container
var.SB_Destination_Container" = "%1" -- Assign %1 to Mushclient Variable
-- Convoluted, but this next block lets the player see the list of keywords in the table to verify correct setup.
_i = ""
for i = 1, #SB_Destination_Container-1, 1 do
_i = _i.." "..SB_Destination_Container[i]
end
_i = Trim(_i)
Note("Destination container: ".._i)
_i = nil
SaveState()</send>
</trigger>-- Update: I think I figured it out. For one, the var module dispenses with lua's case sensitivity -- SB_Source_Container becomes sb_source_container, for example. For another, I apparently couldn't use the same variable name for the world file as the lua arrays they would be imported into.
I know this is very much simplistic compared to serialization, but it makes more sense to my beginner's brain.
[EDIT] Updated code to "escape" square brackets.