Storing, displaying, and changing variables

KresslackKresslack Florida, United States
So I've been reading up on how to use variables, and how to add them tables which can then be displayed with an alias. I was wondering if there is a way to update these values from the command line.

For example, I want to have my equipment displayed in one table, such as my dirk, but if the dirk were to decay and I get a new one, is there a way to quickly update the value of the variable in the command line, as opposed to going into the actual script location and changing it there?


Best Answer

Answers

  • AustereAustere Tennessee
    edited March 2015
    Permanently? On a table?  Not that i know of.  You could temporarily do it, but once you quit mudlet, it would default to whatever the script has.  Might look into using gmcp to track the numbers. .

    At the rate dirks decay, just manually change it until you save up enough for artie dirk.  
  • You can apparently save and load tables into files.

    Or you could do database stuff, but that might be a bit overly complicated.
  • You can use table.save and table.load to save tables to disk and load them later, so you could make a table like
    equipment={dirk=1234,...}
    and save it with
    table.save(equipment, getMudletHomeDir().."\equipment.txt").
    Then you can have a script that loads it when you log in, with
    table.load(equipment,getMudletHomeDir().."\equipment.txt").
    You can make an alias to set the values when something changes, or do it from an alias that runs arbitrary lua code (like the "lua..." alias that comes with svo), and have a trigger or alias to save the table when you qq.

    You should check the manual for the order of arguments for the save and load functions, I might have them backward.
  • KresslackKresslack Florida, United States
    I know they can be saved; the Mudlet manual is where I started reading. I'm wondering if they can be updated on-the-fly via the command bar, using Lua.


  • KresslackKresslack Florida, United States
    Eld said:
    There's not a built-in way to do so, but you can make an alias to do it, or use an alias that runs lua code to do it like you would in a script, like
    lua equipment.dirk = 1234

    Will give this a try later tonight. Thank you.


  • Mudlet 3.0 has a variables view that allows doing this as well.
  • KresslackKresslack Florida, United States
    I need to see if I've updated my Mudlet yet.


Sign In or Register to comment.