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
Llohr
Apprentice


Joined: 17 May 2005
Posts: 108

PostPosted: Tue Feb 02, 2016 5:47 pm   

Explicit Pathing
 
Any reason I shouldn't do something like this:
Code:
#execute {//%char/class/varname=value}

I've had a lot of trouble in the past with using variable paths when explicitly pathing things. My hacky workarounds function 99% of the time, but I want that other 1%.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4578
Location: Pensacola, FL, USA

PostPosted: Tue Feb 02, 2016 6:57 pm   
 
Using #EXECUTE is only frowned upon because it takes more system resources.
I have never noticed a speed performance hit myself.
_________________
Discord: Shalimar#3679
Reply with quote
Llohr
Apprentice


Joined: 17 May 2005
Posts: 108

PostPosted: Tue Feb 02, 2016 10:01 pm   
 
Excellent, the old hack
Code:
#addkey %expand(//%char/Affects/ACStart, 1) %char 1

works, but if things go bad, that sort of thing tends to quit working before anything else. It also doesn't reliably work on packages people download from the library.

Looks like I DO need to make one amendment to the syntax though.

Code:
#execute {//%char/class/variable={value}}


Will clear the value if it's left blank, which is generally what I want.
Reply with quote
Llohr
Apprentice


Joined: 17 May 2005
Posts: 108

PostPosted: Wed Feb 03, 2016 1:05 am   
 
If anybody's keeping score at home, this doesn't work:
Code:
#execute {//%char/class/variable={key1=val1|key2=val2}}


but this does:
Code:
$Somevar={key1=val1|key2=val2}
#execute {//%char/class/variable={$Somevar}}
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4578
Location: Pensacola, FL, USA

PostPosted: Wed Feb 03, 2016 2:50 am   
 
Yes, the use of local variables is recommended when dealing with database variables, or anything with a complicated variable name.
Given that you want to use full path names, you might want to consider making a setter alias to make such declarations easier
_________________
Discord: Shalimar#3679
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