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