Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Asilient_1
Apprentice


Joined: 26 Apr 2007
Posts: 113

PostPosted: Wed Jul 06, 2011 7:03 pm   

Json variables?
 
Hey, guys. I recently updated to V3 and am having troubles with one of my scripts that should work fine in theory. However, I think I have pinned down why it is failing.

Quite simply, I check for blind through GMCP on Aetolia, however: I run a simple check- (@blind_defense=0) however, it doesn't appear to be working, and I think it's due to the variable which doesn't match any of my other curing variables in form through the #VARIABLE output. For example:

Variable: + blind_defense (Auto) 1
json: 1 (string)
Variable: + asthma (Auto) 0

I've no idea why this is happening, I've tried deleting and recreating the variable, manually resetting it, etc, but it is simply not working as intended. After adding some simply debugging output to the script in question, I found it was failing on the check for blind_defense=0, so I'm pretty sure it is this variable issue.

Any idea how I can fix it/avoid it happening again?

Thanks for any help.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Jul 07, 2011 3:29 pm   
 
How are you setting the value of the variable? How are you testing the value of the variable? To help, we will need to see your actual code.
Reply with quote
Asilient_1
Apprentice


Joined: 26 Apr 2007
Posts: 113

PostPosted: Thu Jul 07, 2011 5:09 pm   
 
Rahab wrote:
How are you setting the value of the variable? How are you testing the value of the variable? To help, we will need to see your actual code.



<trigger type="GMCP" param="200" priority="12" trigontrig="false" newline="false" prompt="true" id="9331">
<pattern>^char.vitals</pattern>
<value>#VARIABLE sileris_defense %gmcp.char.vitals.fangbarrier
#VARIABLE cloak_defense %gmcp.char.vitals.cloak
#VARIABLE blind_defense %gmcp.char.vitals.blind
#VARIABLE deaf_defense %gmcp.char.vitals.deaf</value>
</trigger>

The check is in a simple #SWITCH statement #SWITCH (@blind_defense=0) {#CALL @eat_bayberry()} which calls a simple outc/eat command.

I've found that testing the GMCP value directly seems to work without fail: i.e. (%gmcp.char.vitals.blind=0) {#CALL @eat_bayberry()} which makes no sense as they're testing the same value, just in different methods.

Hope this helps.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Jul 07, 2011 8:29 pm   
 
Is this #SWITCH defined in a different package or window than @blind_defense? And have you verified that @blind_defense is being set to the correct value? The difference you noted in your #VARIABLE output should be irrelevant to whether this works.
Reply with quote
Asilient_1
Apprentice


Joined: 26 Apr 2007
Posts: 113

PostPosted: Thu Jul 07, 2011 8:41 pm   
 
Rahab wrote:
Is this #SWITCH defined in a different package or window than @blind_defense? And have you verified that @blind_defense is being set to the correct value? The difference you noted in your #VARIABLE output should be irrelevant to whether this works.


The #SWITCH is defined in a different module, yes. I have tried moving the variable to the same module (The whole script, even) but not to any difference.

@blind_defense is being set to the correct value, I've checked through #SHOW, #VAR blind_defense and comparing it to the GMCP value (They should be the same). I know the difference in the variable output should be irrelevant, but it's the only thing I could come up with.

Like I said earlier, I use #SWITCH (@blind_defense=0) and it doesn't work, but using #SWITCH (%gmcp.char.vitals.blind=0) works just fine in all cases, despite them being exactly the same check.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Jul 08, 2011 4:09 pm   
 
Make sure the @blind_defense variable is somewhere the other module can see it. The #SWITCH in another module won't be able to see a variable stored within a window (windows are private). You should probably move the variable into your other module and mark the module as Global.

The reason %gmcp works but the @var doesn't is that the %gmcp is a global array within CMUD and does not use the normal scoping rules that variables do. Your module can only see the @blind_defense variable if it is visible within the current context scope, whereas the %gmcp array is always visible anywhere since it's a system variable.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net