Results 1 to 3 of 3

Thread: Lich Script Settings

  1. Default Lich Script Settings

    How do I have character specific containers running the same script?

    I added a setup aspect to my scripts like this:

    def setup()
    toggle_echo; toggle_unique; toggle_echo
    echo "Reply to the following questions by typing \";s to sell <answer>\""
    echo "There is no checking for those questions but if you mess up the script likely won't operate."
    echo
    clear

    echo "Where do you store gems and alchemy?"
    Settings["lootsack"] = unique_get
    Settings.save
    exit
    end

    Settings.load

    if variable[1] =~ /setup/i then setup(); end

    What I've run into is that if character 1 denotes that he keeps his gems in his jacket, when character 2 runs the script, he tries to get the gems from the jacket even though when he ran the script he specified cloak.

    Any tips? Thanks!

  2. #2
    Join Date
    Nov 2004
    Location
    Upstate NY
    Posts
    428

    Default

    Use a second hash with the character name as the key for the first hash, and "lootsack" (or whatever) as the key for the second hash. It would require a little extra checking to make sure you don't erase all the values already in the second hash.

    ... God this stuff can be difficult to express verbally. Here:

    Code:
    def setup
      Settings.load
      Settings[Char.name] = Hash.new unless Settings[Char.name].kind_of? Hash
    
      echo "Your container selection, user?"
    
      Settings[Char.name]["lootsack"] = unique_get
      Settings.save
      exit
    end
    The Settings[Char.name] = Hash.new unless Settings[Char.name].kind_of? Hash makes sure that if a Hash object already exists for the current character's name, it's just left alone -- but if there isn't one already stored (which would probably only happen the first time the current char ran the script), an empty one is created and stuck in.

    The reason you need Settings[Char.name]["lootsack"] (two dereferences instead of one) is because the first bracketed reference, Char.name, dereferences the hash tied to the current character's name. Then that hash has to be dereferenced by a second set of brackets, just as you were doing originally.
    Last edited by Shaelun; 08-08-2008 at 01:42 AM.
    I visualize a time when we will be to robots what dogs are to humans, and I'm rooting for the machines. -- Claude Shannon

  3. Default

    Thanks for the detailed reply! I'm going to be honest though, it's WAY over my head. I'm gonna give a little time to playing and experimenting with it though. Again, thanks so much!

Similar Threads

  1. Lich - ;settings ;var error
    By SashaFierce in forum The Lich Project
    Replies: 4
    Last Post: 09-07-2015, 12:48 PM
  2. Transferring lich settings to another character
    By Dugoar in forum The Lich Project
    Replies: 0
    Last Post: 04-25-2015, 07:03 PM
  3. Replies: 2
    Last Post: 01-06-2014, 07:14 PM
  4. Replies: 9
    Last Post: 10-29-2012, 09:05 PM
  5. Lich script help
    By Flessen in forum The Lich Project
    Replies: 6
    Last Post: 01-28-2008, 09:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •