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
LordBudigert737
Beginner


Joined: 15 Jan 2015
Posts: 16

PostPosted: Wed Jan 21, 2015 5:00 pm   

Trouble creating a trigger with an alias - creating triggers, aliases, and vars
 
I am writing a simple buddy list that hightlights people based on the group you add them to and I decided that I wanted to make it even easier!

To create my list, I only needed: 1 variable, 3 aliases, and 1 trigger. For example, if I want a group called "Pals" I just need a @pals, addpal delpal showpal (3 aliases), and the trigger that colors them. Things were going great, until I tried get smart and create an addgroup alias.

Here is what I have at the moment:
Code:

#VARIABLE {%1} {%null} {_nodef} {Female Channeler|Buddy List}
#TRIGGER {@%1} {#cw %2} {Female Channeler|Buddy List}
#ALIAS {add%1} {
#ADDIT %1 %proper(%1)
#ECHO {%proper(%1) added to %proper(%2).}} {Female Channeler|Buddy List}
#ALIAS {del%1} {
#DELIT %1 %proper(%1)
#ECHO {%proper(%1) added to %proper(%2).}} {Female Channeler|Buddy List}
#ALIAS {show%1} {#SHOW @%1} {Female Channeler|Buddy List}


As I typed addgroup pals yellow, each of my 1 var 3 alia and 1 trigg were created but, as I'm sure you'll point out to me, there were issues - which ended up being more than what I originally came here for help on.

Embarassed

So. can anybody tell me how to do what I'm aiming for? I don't mind continuing to add groups manually, but if I know there's an easier way...

Much appreciated.
Reply with quote
shalimar
GURU


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

PostPosted: Thu Jan 22, 2015 5:39 am   
 
hmm, the issue seems to be in show alias, and the trigger
more specifically, you need to get the value of %1 to be evaluated before the new setting is made, instead of being passed literally
with some trial and error i managed to do it with %concat

Code:
$var=%concat( "@", %1)
#VARIABLE {%1} {%null} {_nodef} {Female Channeler|Buddy List}
#TRIGGER %concat( "{{", $var, "}}") {#cw %2} {Female Channeler|Buddy List}
#ALIAS {add%1} {
  #ADDIT %1 %proper( %1)
  #ECHO {%proper( %1) added to %proper( %2).}
  } {Female Channeler|Buddy List}
#ALIAS {del%1} {
  #DELIT %1 %proper( %1)
  #ECHO {%proper( %1) added to %proper( %2).}
  } {Female Channeler|Buddy List}
#ALIAS {show%1} {#SHOW $var} {Female Channeler|Buddy List}
_________________
Discord: Shalimarwildcat
Reply with quote
LordBudigert737
Beginner


Joined: 15 Jan 2015
Posts: 16

PostPosted: Thu Jan 22, 2015 12:43 pm   
 
Thanks for the reply, you definitely cleared up some of my issues and I was able to move a little further with my script... this just led me into more problems Shocked

Here is my current script for addgroup alias:
Code:

groupVar = %concat("@", %1)
groupsecVar = %1
colorVar = %2
addVar=%concat("add", %1)
showVar=%concat("show", %1)
colorVar=%concat("#cw ", %2)
#VARIABLE {%1} {%null} {String list} {Female Channeler|Buddy List}
#CALL %vartype(@groupsecVar, 4)
#ALIAS @addVar {#ADDIT %1 %proper(@charVar)
#ECHO {%proper(%1) added to %proper(@groupsecVar)}} {Female Channeler|Buddy List}
#ALIAS @showVar {#SHOW @groupVar} {Female Channeler|Buddy List}
#TRIGGER %concat( "{", @groupVar, "}" ) {@colorVar} {Female Channeler|Buddy List}


Using 'joe' as the group to be added, my issues are as follows:
1. addjoe alias issues:
- addjoe is not adding to @joe string list, it is making string list variables and placing them in the root folder instead. This also means that the %1 argument is not being added to the @joe string list, so @joe sits empty even after using addjoe xxx
2. deljoe alias issues:
- deleted references to delxxx for simplicity in debugging. I assume that any issues with addjoe, would also be reflected here as they are nearly the same alias.
3. showjoe alias appears to work fine, but can't actually tell because there is nothing in the @joe string list to populate and colorize.
4. The trigger is once again not printing correctly. It worked for awhile, but I don't know what I changed other than removing extra {}'s (only want one on each side)
-- I need it to be {@joe} instead of {{@joe}} which it is trying to do. With the code as it stands, I am getting a trigger pattern of {}. Nothing inside the brackets.

Thank you again, very much, for your time and assistance. :)
Reply with quote
shalimar
GURU


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

PostPosted: Thu Jan 22, 2015 2:06 pm   
 
The trigger should want the double brackets.
That's how it knows to expand an array out to match all the members.

Why do you want only single?
_________________
Discord: Shalimarwildcat
Reply with quote
LordBudigert737
Beginner


Joined: 15 Jan 2015
Posts: 16

PostPosted: Thu Jan 22, 2015 2:28 pm   
 
shalimar wrote:
The trigger should want the double brackets.
That's how it knows to expand an array out to match all the members.

Why do you want only single?


I wish I had a better answer than it simply doesn't work when I do that :P

Reply with quote
shalimar
GURU


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

PostPosted: Thu Jan 22, 2015 2:49 pm   
 
aha.... but to get that you would need a triple bracket at runtime
_________________
Discord: Shalimarwildcat
Reply with quote
LordBudigert737
Beginner


Joined: 15 Jan 2015
Posts: 16

PostPosted: Thu Jan 22, 2015 2:50 pm   
 
Easy now! Remember, I'm a newb at this stuff!
Reply with quote
LordBudigert737
Beginner


Joined: 15 Jan 2015
Posts: 16

PostPosted: Thu Jan 22, 2015 2:53 pm   
 
Implying that:

#trigg {{{@variable}}} {#cw %2}

would work without messing with the others? Would just be for that instance?
Reply with quote
shalimar
GURU


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

PostPosted: Thu Jan 22, 2015 3:03 pm   
 
The trigger you have highlighted in the GUI, showing a double bracket would take a triple bracket at runtime.
To get the single bracket, like the trigger on {@friends} requires a double bracket at runtime.

One set of brackets encapsulates the pattern.
The second set of brackets unwraps the variable in contains into a string list.

I can think of no coded reason to ever 'need' triple brackets, i only mention them in explanation.

Did you try the code i had posted originally?
If so, how was it failing you?
_________________
Discord: Shalimarwildcat
Reply with quote
LordBudigert737
Beginner


Joined: 15 Jan 2015
Posts: 16

PostPosted: Thu Jan 22, 2015 3:33 pm   
 
Pasting in your original code as is, gave me a pattern with double brackets. That's why I originally took one of the brackets off of each side in the %concat within the trigger, which fixed my problem as far as the pattern is concerned. Then, I noticed that the value for that trigger was %2, which would be fine if entering in manually, but because of the create-a-group nature of the script, I thought this %2 needed to be a variable to reflect the color scheme wanted for the group. I.e., addgroup joe yellow --- the value for that trigger, after using addgroup alias, should be #CW xxxx. xxxx being whatever color used with addgroup.

One other issue with your code I noticed that got me started butchering it :P was that the variable created with addgroup was not a string list, thus I can't add multiple people to it.. That's where the #call command came in.

From there, I just started rolling with creating variables and trying to call them and then frustration. :)
Reply with quote
shalimar
GURU


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

PostPosted: Thu Jan 22, 2015 3:53 pm   
 
Hmm... maybe the use of %concat removed the need for the second set of brackets... Interesting.
As for the color, use %concat on the value half of the trigger as well: %concat("#CW ", %2)
As to the variable... you should be able to add members to it, if the type is an issue well, you can change the type via script as well
#CALL %vartype(varName, 4)

4 is the type for a string list, make sure not to include the @ in varName
_________________
Discord: Shalimarwildcat
Reply with quote
LordBudigert737
Beginner


Joined: 15 Jan 2015
Posts: 16

PostPosted: Thu Jan 22, 2015 4:15 pm   
 
For whatever reason, I simply can NOT get local variables to work for me. So, I switched them all over to regular variables, and now the trigger pattern is showing as {} again. I'm thinking that this just can't be done, so I guess I'm just going to stick to doing them manually.
Reply with quote
shalimar
GURU


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

PostPosted: Thu Jan 22, 2015 9:31 pm   
 
ahhh as for local variables.
if they are being used inside another setting (like an #IF command) prior to being defined, you will get an error
if you need to define one with no value, do:
#LOCAL $var1 $var2 $var3 $etc
That will prevent them from tossing out errors
_________________
Discord: Shalimarwildcat
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