[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Var Module Doesn't Update Plugin Variables
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Var Module Doesn't Update Plugin Variables

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Xvordan   (25 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] 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
[Go to top] 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.


1,807 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]