The Gemstone IV Players' Corner  

Go Back   The Gemstone IV Players' Corner > General GemStone IV > Scripting Discussion > The Lich Project
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-07-2008, 05:30 PM
Iamnaeth Iamnaeth is offline
Member
 
Join Date: May 2008
Posts: 59
Iamnaeth is just really niceIamnaeth is just really niceIamnaeth is just really niceIamnaeth is just really niceIamnaeth is just really niceIamnaeth is just really nice
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!
Reply With Quote
  #2  
Old 08-08-2008, 01:41 AM
Shaelun Shaelun is offline
Senior Member
 
Join Date: Nov 2004
Location: Upstate NY
Posts: 426
Shaelun is on a distinguished road
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.
__________________
Mohandas K. Gandhi often changed his mind publicly. An aide once asked him how he could so freely contradict this week what he had said just last week. The great man replied that it was because this week he knew better.

Last edited by Shaelun : 08-08-2008 at 01:42 AM.
Reply With Quote
  #3  
Old 08-08-2008, 11:49 AM
Iamnaeth Iamnaeth is offline
Member
 
Join Date: May 2008
Posts: 59
Iamnaeth is just really niceIamnaeth is just really niceIamnaeth is just really niceIamnaeth is just really niceIamnaeth is just really niceIamnaeth is just really nice
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!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 04:09 PM.


Powered by vBulletin Version 3.6.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.