Welcome to the Builder Academy

Question Ascii in triggers

More
16 Sep 2018 15:13 #8206 by Parnassus
Ascii in triggers was created by Parnassus
I'm working on a fishing trigger and I decided to make some cute lil waves to indicate the passing time as you fish. As always, I tested this trigger in speech form first.

1) Name : test trigger
2) Intended for : Rooms
3) Trigger types: Speech
4) Numeric Arg : 100
5) Arguments : test
6) Commands:
%send% %actor% You cast your line into the waters.
wait 1 second
%echo% @c ~~ ~~ ~ ~ @n
....
/t
/fi

This shows as:
You cast your line into the waters.
~~ ~~ ~ ~ (except in cyan)

Then I switch to an object trigger:
1) Name : Fishing
2) Intended for : Objects
3) Trigger types: Command
4) Numeric Arg : 4
5) Arguments : fish
6) Commands:
%send% %actor% You cast your line into the waters.
wait 1 second
%echo% @c ~~ ~~ ~ ~ @n
....
/t
/fi

This shows as:
You cast your line into the waters.
someonesomeonesomeonesomeonesomeonesomeone

I can get around this by inputting it this way:
%echo% @c \~ \~\~ \~ \~ @n

But I'm just wondering...um, why?

Please Log in or Create an account to join the conversation.

More
16 Sep 2018 21:14 #8207 by thomas
Replied by thomas on topic Ascii in triggers
Internally, %echo% do some substitutions.
github.com/tbamud/tbamud/blob/master/src/dg_comm.c#L47
Code:
static void sub_write_to_char(char_data *ch, char *tokens[], void *otokens[], char type[]) { char sb[MAX_STRING_LENGTH]; int i; strcpy(sb,""); for (i = 0; tokens[i + 1]; i++) { strcat(sb,tokens[i]); switch (type[i]) { case '~': if (!otokens[i]) strcat(sb,"someone"); else if ((char_data *)otokens[i] == ch) strcat(sb,"you"); else strcat(sb,PERS((char_data *)otokens[i], ch)); break; ...
This will replace in the name or personal pronoun, depending on the token and the trigger type.
I'm unsure if this is documented anywhere...

Please Log in or Create an account to join the conversation.

More
17 Sep 2018 22:32 #8208 by Parnassus
Replied by Parnassus on topic Ascii in triggers
Actually, I'm not so surprised at someonesomeonesone, I'm surprised that the speech trigger doesn't do it. The room speech does exactly what *I* told it to but it shouldn't have, should it? The object command does as the *code* tells it and substitutes someone unless an escape...um, code? sequence? So what is in that room speech trigger that doesn't need the escape? Is it this part?

thomas wrote:

Code:
else strcat(sb,PERS((char_data *)otokens[i], ch)); break; ...


In my weird non-coder way, I'm seeing: if there's a token, substitute someone and if there isn't, substitute you. And maybe: if there isn't a token and there isn't not a token don't do anything? Um, what's a token, please?

Please Log in or Create an account to join the conversation.

Time to create page: 0.399 seconds