- Posts: 157
- Thank you received: 17
Trigger of the Day - Advanced
- Fizban
- Topic Author
- Offline
- Administrator
-
Less
More
4 years 3 months ago #7567
by Fizban
Trigger of the Day - Advanced was created by Fizban
The script below, as is, was written by Detta.
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.
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.
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.
- JTP
- Offline
- Platinum Member
-
Less
More
- Posts: 937
- Thank you received: 17
4 years 3 months ago #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%
set zn118_ruthpearl 2
remote zn118_ruthpearl %actor.id%
Please Log in or Create an account to join the conversation.
- WhiskyTest
-
- Offline
- Platinum Member
-
Less
More
- Posts: 345
- Thank you received: 73
4 years 3 months ago #7570
by WhiskyTest
Replied by WhiskyTest on topic Trigger of the Day - Advanced
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
Then other triggers can reference the value when they fire
Please Log in or Create an account to join the conversation.
- Fizban
- Topic Author
- Offline
- Administrator
-
Less
More
- Posts: 157
- Thank you received: 17
4 years 3 months ago - 4 years 3 months ago #7572
by Fizban
Replied by Fizban on topic Trigger of the Day - Advanced
Whisky's explanation is accurate.
You can:
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:
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:
This is wrong.
will work
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.
or
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.
You can:
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:
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:
if ridley /= %arg%
This is wrong.
ask rid
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.
if 'ridley /= '%arg%
or
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: 4 years 3 months ago by Fizban.
The following user(s) said Thank You: thomas, WhiskyTest
Please Log in or Create an account to join the conversation.
- zi
-
- Offline
- New Member
-
Less
More
- Posts: 13
- Thank you received: 1
1 year 11 months ago - 1 year 11 months ago #8781
by zi
_,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,_
Making 3M Great Again!
telnet://3m.funcity.org:3000
_,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,_
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?!?!?!
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: 1 year 11 months ago by zi. Reason: copy/pasted incomplete. fixed
Please Log in or Create an account to join the conversation.
- zi
-
- Offline
- New Member
-
Less
More
- Posts: 13
- Thank you received: 1
1 year 11 months ago - 1 year 11 months ago #8784
by zi
_,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,_
Making 3M Great Again!
telnet://3m.funcity.org:3000
_,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,_
Replied by zi on topic Trigger of the Day - Advanced
any hints?
_,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,_
Making 3M Great Again!
telnet://3m.funcity.org:3000
_,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,_
Last edit: 1 year 11 months ago by zi.
Please Log in or Create an account to join the conversation.
- Parnassus
- Offline
- Administrator
-
Less
More
- Posts: 366
- Thank you received: 54
1 year 11 months ago #8785
by Parnassus
Replied by Parnassus on topic Trigger of the Day - Advanced
I'm not understanding the problem. You didn't want to be able to to look south?
Please Log in or Create an account to join the conversation.
- zi
-
- Offline
- New Member
-
Less
More
- Posts: 13
- Thank you received: 1
1 year 11 months ago #8787
by zi
_,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,_
Making 3M Great Again!
telnet://3m.funcity.org:3000
_,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,_
Replied by zi on topic Trigger of the Day - Advanced
look without an argument returns WIN
it SHOULD return the room desc, etc.
now, when i type look in a direction, at an object, at a character, etc. i see that description. but look, without any argument, returns WIN
it SHOULD return the room desc, etc.
now, when i type look in a direction, at an object, at a character, etc. i see that description. but look, without any argument, returns WIN
_,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,_
Making 3M Great Again!
telnet://3m.funcity.org:3000
_,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,_
Please Log in or Create an account to join the conversation.
- rhade
- Offline
- New Member
-
Less
More
- Posts: 1
- Thank you received: 0
1 year 10 months ago #8789
by rhade
Replied by rhade on topic Trigger of the Day - Advanced
When %arg% is empty, then ' is still a substring of 'test, which is why your trigger is firing. Change your if condition to be:
if %cmd.mudcommand% == look && %arg% && 'test /= '%arg%
if %cmd.mudcommand% == look && %arg% && 'test /= '%arg%
Please Log in or Create an account to join the conversation.
- zi
-
- Offline
- New Member
-
Less
More
- Posts: 13
- Thank you received: 1
1 year 10 months ago #8790
by zi
_,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,_
Making 3M Great Again!
telnet://3m.funcity.org:3000
_,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,_
Replied by zi on topic Trigger of the Day - Advanced
THIS works...
if %cmd.mudcommand% == look
switch %arg%
case compass
%echo% WIN!
break
default
return 0
halt
break
done
else
return 0
end
it allows a mortal to look at the object (magic compass) and get WIN, allows him to look without argument and just see the room, allows him to look at anything specific and see the description..
the IF with the %keyword.contains('%arg%)% still triggers the command (or mud command) without the argument... try this bad boy::
set compass 'compass
if %cmd.mudcommand% == look && %compass.contains('%arg%)%
%echo% WIN!
else
return 0
end
type look with your mortal and you'll get WIN! am I missing something in my if statement?
and no, i'm not using the /= %arg% logic, that stinks
if %cmd.mudcommand% == look
switch %arg%
case compass
%echo% WIN!
break
default
return 0
halt
break
done
else
return 0
end
it allows a mortal to look at the object (magic compass) and get WIN, allows him to look without argument and just see the room, allows him to look at anything specific and see the description..
the IF with the %keyword.contains('%arg%)% still triggers the command (or mud command) without the argument... try this bad boy::
set compass 'compass
if %cmd.mudcommand% == look && %compass.contains('%arg%)%
%echo% WIN!
else
return 0
end
type look with your mortal and you'll get WIN! am I missing something in my if statement?
and no, i'm not using the /= %arg% logic, that stinks
_,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,_
Making 3M Great Again!
telnet://3m.funcity.org:3000
_,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,_
Please Log in or Create an account to join the conversation.
- Parnassus
- Offline
- Administrator
-
Less
More
- Posts: 366
- Thank you received: 54
1 year 10 months ago #8791
by Parnassus
Replied by Parnassus on topic Trigger of the Day - Advanced
Sorry, I hadn't realized that Rhade's message hadn't gone through.
But, yes, this is one that catches me every time! I love what I call "Fizban's Fix" especially since I've been in a room with a mob looking for /=king. If you tried talking in this room, the mob would talk about the king if you mentioned asking, talking, walking, killing or many other things.
However, as Rhade says, when you change "look {noarg}" to "look '{noarg}", you've now changed that noarg to an arg that matches your criteria since "look ' " is part of "look 'compass".
For more info on this matter:
Trigger of the Day - Mob Command Example
and /= .
But, yes, this is one that catches me every time! I love what I call "Fizban's Fix" especially since I've been in a room with a mob looking for /=king. If you tried talking in this room, the mob would talk about the king if you mentioned asking, talking, walking, killing or many other things.
However, as Rhade says, when you change "look {noarg}" to "look '{noarg}", you've now changed that noarg to an arg that matches your criteria since "look ' " is part of "look 'compass".
For more info on this matter:
Trigger of the Day - Mob Command Example
and /= .
Please Log in or Create an account to join the conversation.
Time to create page: 0.127 seconds