Variables saving from one session to the next

Posted by Cericoe17 on Mon 25 Oct 2010 02:56 AM — 7 posts, 20,408 views.

#0
I'm very new to mushclient, just left Cmud.

I'm trying to write a script that will manage using Portals on Aardwolf.

I can't get the table to save from one session the next. I serialize the table with


SetVariable("PortalString",serialize.save ("Portals"))


and reload it with


assert (loadstring (GetVariable ("PortalString") or "")) ()


None of my other variables will save either.


<variables>
  <variable name="numPortals">0</variable>
  <variable name="drinkCon">None</variable>
  <variable name="portBag">None</variable>
  <variable name="pLevel">0</variable>
  <variable name="pTier">0</variable>
  <variable name="haveWish">0</variable>
  <variable name="portback">NotSet</variable>
  <variable name="heldItem">None</variable>
  <variable name="PortalString"></variable>
</variables>

USA #1
Is this in a plugin? Make sure you have save_state="y" set in the <plugin> tag.

Where did you get the <variables> part from? Did you copy it from a file, or did you export them from the Variables dialog?
#2
Yea, it's a plugin and the variables are copy and pasted from the xml file. That's the my heading for it.


<plugin
   name="aaPortalScript"
   author="Jon"
   id="0f5715779c39a44919e4bf85"
   language="Lua"
   purpose="To run my Portals"
   save_state="y"
   date_written="2010-10-11 20:29:37"
   requires="4.59"
   version="1.0"
   >
USA #3
I think your problem is that the variables in a <variables> block always overwrite any variables loaded in from the plugin's state file. You'll need to find some other way to load the defaults.
#4
I'll try that. Thank you.
#5
Awesome that was the problem. Thank you so so much!
USA #6
You're welcome!