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
apfinger
Novice


Joined: 19 Nov 2006
Posts: 40

PostPosted: Mon Feb 02, 2015 6:39 am   

A couple cross session variable issues
 
Assuming Joe is my session name for my tank, I've got the following:

Code:
#ALIAS km {
  #IF (!%null(%1)) { mobIs %1 }
  #IF (%ismember(%db(@tankInfo,name),@multiMembers) {
    #ECHO %db(@tankInfo,name) @attackType %db(@mobInfo,name)
    :%db(@tankInfo,name):@attackType %db(@mobInfo,name)
}


mobIs is an alias that sets @mobInfo.name to %1
tankInfo has various tank related properties, like name, hp, low-HP heal amount, etc
multiMembers is a list of my characters (same as their session names)
attackType is a session specific variable. In Joe's case, it is ambush
mobInfo has various mob related properties. Currently just name, though

Problem 1:
:%db(@tankInfo,name): does not send the command to the session. Neither does @tankInfo.name
If I do
Code:
#VAR tn %db(@tankInfo,name)
:@tn:@attackType %db(@mobInfo,name)

The command gets sent to Joe. Is there a reason I would need this workaround?

Problem 2:
Code:
#ECHO :@tn:@attackType %db(@mobInfo,name)
:@tn:@attackType %db(@mobInfo.name)

The echo will show ":Joe:ambush fido"
The command will be ":Joe:ambushfido"

Any reason why the whitespace separating @attackType and %db(@mobInfo.name) gets lost?
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Mon Feb 02, 2015 11:39 am   
 
I don't think the : syntax was really designed with variables in mind, you'd probably have better luck with the #execwin command.
Reply with quote
apfinger
Novice


Joined: 19 Nov 2006
Posts: 40

PostPosted: Mon Feb 02, 2015 1:58 pm   
 
Thanks! I've been checking out all the %functions and #commands, but somehow missed this one. I have a feeling this one will do just fine.

Code:

#ALIAS km {
  #IF (!%null(%1)) { mobIs %1 }
  #IF (%ismember(%db(@tankInfo,name),@multiMembers)) {
    #EXECWIN %db(@tankInfo,name) { %concat(@attackType," ",%db(@mobInfo,name)) }
  }
}


This works well. execwin allowed me to add the %concat in there so I could space the two variables, as well.
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