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
➜ Var Module Doesn't Update Plugin Variables
|
Var Module Doesn't Update Plugin Variables
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Xvordan
(29 posts) Bio
|
| Date
| Tue 01 Jul 2014 09:36 AM (UTC) Amended on Tue 01 Jul 2014 10:33 PM (UTC) by Nick Gammon
|
| Message
| 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:
<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. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Tue 01 Jul 2014 10:34 PM (UTC) |
| Message
| | MUSHclient world variables are not case-sensitive, so when the var module get/sets them it will ignore case. |
- 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.
11,099 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top