Welcome to the Builder Academy

Question Trigger of the Day - Advanced

More
08 Feb 2018 23:33 #7567 by Fizban
The script below, as is, was written by Detta.
Code:
Name: '(11) Ridley responds to asking', VNum: [11867], RNum: [ 1565] Trigger Intended Assignment: Mobiles Trigger Type: Command , Numeric Arg: 100, Arg list: a Commands: if %cmd% == ask if %arg% /= Ridley if %arg% /= secret if %actor.varexists(zn118_ruthpearl)% if %actor.zn118_ruthpearl% == 1 wait 1 s emote blinks at you. wait 1 s say Was it Ruth who spoke to you of this? wait 2 s sigh wait 1 s say Well perhaps she is right to send you... wait 1 s say You have done much for us... here, take my most guarded secret. wait 2 s %load% obj 11859 set zn118_ruthpearl 2 remote zn118_ruthpearl %actor.id% give pearl %actor.name% drop pearl else tell %actor.name% I have already given you my secret. end else tell %actor.name% I have no desire to speak of it. end else return 0 end else return 0 end else return 0 end

It works, but the %arg% had to contain ridley and secret, not substrings or abbreviations of them.

I made the changes below to resolve this. It's a bit overkill, but..it works.
Code:
Name: '(11) Ridley responds to asking', VNum: [11867], RNum: [ 1565] Trigger Intended Assignment: Mobiles Trigger Type: Command , Numeric Arg: 100, Arg list: a if %cmd.mudcommand% == ask && %arg.cdr% set ridley 'ridley set secret 'secret while %arg.cdr% if %ridley.contains('%arg.car%)% set ridleyfound 1 end if %secret.contains('%arg.car%)% set secretfound 1 end set arg %arg.cdr% done if %ridley.contains('%arg.car%)% set ridleyfound 1 end if %secret.contains('%arg.car%)% set secretfound 1 end if %secretfound% && %ridleyfound% if %actor.varexists(zn118_ruthpearl)% if %actor.zn118_ruthpearl% == 1 wait 1 s emote blinks at you. wait 1 s say Was it Ruth who spoke to you of this? wait 2 s sigh wait 1 s say Well perhaps she is right to send you... wait 1 s say You have done much for us... here, take my most guarded secret. wait 2 s %load% obj 11859 set zn118_ruthpearl 2 remote zn118_ruthpearl %actor.id% give pearl %actor.name% drop pearl else tell %actor.name% I have already given you my secret. end else tell %actor.name% I have no desire to speak of it. end else return 0 end else return 0 end

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

More
09 Feb 2018 07:29 #7569 by JTP
Replied by JTP on topic Trigger of the Day - Advanced
What are these two Lines doing ?

set zn118_ruthpearl 2
remote zn118_ruthpearl %actor.id%

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

More
09 Feb 2018 20:27 #7570 by WhiskyTest
I think it creates a global variable called zn118_ruthpearl, gives it a value of two, and sticks it onto the character.

Then other triggers can reference the value when they fire

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

More
10 Feb 2018 02:43 - 10 Feb 2018 03:03 #7572 by Fizban
Whisky's explanation is accurate.

You can:
Code:
set var value remote var %actor.id%

To create a variable and save the value of it to the player.


You can then check whether the player has such a variable saved to them with:
Code:
if %actor.varexists(var)%

Similarly the value of the variable saved to them can be accessed with %actor.var%.

The meat of the script is fairly standard fare, the main reason I decided to post it was the changes I made to its firing conditions because that's not something I've seen other people do for the most part.

As an example.

It is common to check if 'a' is inside of 'b'.

ie. When seeking an abbreviation of a one word argument and wanting to allow abbreviations of either ridley or secret so they can type ask ri, or ask sec, etc.

This is super simple.

Most people will do it like this though:
Code:
if ridley /= %arg%

This is wrong.
Code:
ask rid
will work
Code:
ask idle

will also work.

This is because idle is inside of ridley.

If you want to make sure the pattern matching begins at the start of the word then either of the following solutions are superior.
Code:
if 'ridley /= '%arg%

or
Code:
set ridley 'ridley if %ridley.contains('%arg%)%

The reason these solutions are superior is because they use ' as a delimiter at the start of the terms forcing the matching to be at the beginning of the terms. ie. While idle is inside of Ridley, 'idle is not inside of 'Ridley.


What's far more complicated is to require vara to have multiple abbreviations inside of it.

You need each term in vara to be prefaced with a delimiter character like ', and then to check if each word in vara is an abbreviation of one of the required terms, and to ensure that all of the abbreviations are found.
Last edit: 10 Feb 2018 03:03 by Fizban.
The following user(s) said Thank You: thomas, WhiskyTest

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

More
17 Jun 2020 21:07 - 18 Jun 2020 14:20 #8781 by zi
Replied by zi on topic Trigger of the Day - Advanced
I've had a hard time with cmd and arguments, and this solution never works for me. Simple test:
the trigger's argument: *

if %cmd.mudcommand% == look && 'test /= '%arg%
%echo% WIN!
else
return 0
end

returns WIN! on look (or l)... but look south (or person,obj,etc.) returns what's expected.

when I put the argument in an if statement, it's worse:

set test 'test
if %cmd.mudcommand% == look
if %test.contains('%arg%)%
%echo% WIN!
else
return 0
end
else
return 0
end


same result. Look will return WIN but look south will return exit desc. yes, i'm testing with a mortal.

What's missing?!?!?!

_,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,_
Making 3M Great Again!
telnet://3m.funcity.org:3000
_,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,_
Last edit: 18 Jun 2020 14:20 by zi. Reason: copy/pasted incomplete. fixed

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

More
18 Jun 2020 14:15 - 18 Jun 2020 14:16 #8784 by zi
Replied by zi on topic Trigger of the Day - Advanced
any hints?

_,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,_
Making 3M Great Again!
telnet://3m.funcity.org:3000
_,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,_
Last edit: 18 Jun 2020 14:16 by zi.

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

Time to create page: 0.254 seconds