|
mawebr Newbie
Joined: 28 Oct 2009 Posts: 4
|
Posted: Tue Aug 20, 2013 11:32 am
%POP and CMUD Commands |
Hi!
I am wondering if there is a way to get CMUD to receive a command using %pop and a string list, as opposed to that command getting sent straight to the mud.
I have a string list variable that I preload with a set of directions and then use %pop to follow that path and it works great. My problem is if I want to include things like an alias or a command to change a variable in that stringlist it will get sent to the Mud instead of getting read as a CMUD command. I have an example below.
Code: |
%pop(Area1)
#VAR Area1 {e|e|#VAR ItemA Jar|e|e}
|
What I would like to happen...
You go east, you go east, variable ItemA gets changed to Jar, you go east, you go east.
What actually happens...
You go east, you go east, huh? (Mud does not recognize "#VAR ItemA Jar" command), you go east, you go east.
I have looked into doing a Loop but the problem is that different string list variables would need to have Cmud commands in different cells.
Anyways, any help would be awesome! Thanks.[/quote] |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Tue Aug 20, 2013 7:01 pm |
in this instance you would want to
#EXEC {%pop(Area1)} |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Anaristos Sorcerer
Joined: 17 Jul 2007 Posts: 821 Location: California
|
Posted: Wed Aug 21, 2013 1:08 am |
This also would work and perhaps is more idiomatic:
|
|
_________________ Sic itur ad astra. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Wed Aug 21, 2013 2:05 am |
#call would not do anything with the data though
the funtion would run, but the results thrown away
you need #EXEC for the results to be processed instead of treated as a literal string |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Anaristos Sorcerer
Joined: 17 Jul 2007 Posts: 821 Location: California
|
Posted: Fri Aug 23, 2013 2:53 am |
var = %pop( list ) retrieves the top item of a string list, places it in variable var and the item is removed from the list.
If a receiving variable is not specified the first item is simply discarded.
both
Code: |
#EXEC {%pop( Area1)}
|
and
archive the same result. The top item from the list is removed and discarded.
I don't understand what is it you mean by "being treated as a literal string". In the case above, Area1, using either idiom, remains a string list. |
|
_________________ Sic itur ad astra. |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Fri Aug 23, 2013 6:47 pm |
No, they don't achieve the same result. The first one will execute the top item of the list, while the second one won't. Using his specific example:
Code: |
#VAR Area1 {e|e|#VAR ItemA Jar|e|e}
#LOOP 5 {#EXEC {%pop(Area1)}} |
This will cause the string list items to be removed from the string list and executed in turn. The 4 e's will likely just be sent to the MUD verbatim, assuming there's no "e" alias, while the third will set the ItemA variable to "Jar".
Code: |
#VAR Area1 {e|e|#VAR ItemA Jar|e|e}
#LOOP 5 {#CALL %pop(Area1)} |
This will cause the string list items to be removed from the string list and immediately thrown away. Nothing will be sent to the MUD. The ItemA variable will not change. |
|
|
|
|
|