Building & Scripting > Scripting Board
Trigger of the .... something
Kvetch:
I found this over at TBA and thought it was useful. We probably have the help file in 4D as well, but I'm too lazy to look right now and I know I've needed this info before. So, for everyone else:
Text Variable Fields
These fields pertain to any variable that contains a string of text. These
are often the variables, such as %speech%, which are provided to a trigger, but
can also be variables that have been created by the trigger, such as
%room.north%
When using field - The variable returns
strlen - Returns the number of characters in the string.
trim - Returns the string without any leading or trailing whitespace.
This is used to trim extra spaces from the beginning or end of a
string.
car - Returns the first word of the string. For %text%="this is the
string"; %text.car% will yield "this".
cdr - Returns all but the first word of the string, trimmed. For %text%=
"this is the string"; %text.cdr% will yield "is the string".
contains() - Used to check if a string contains the subfield text.
mudcommand - Returns the mud command the string is shorthand for. Used to make
sure the command you react to is the one you want: For %text%="o"
%text.mudcommand% will yield "open".
charat - set new variable %text/var.charat(index)% i.e. set phrase testing,
set var1 %phrase.charat(2)% now %var1% == e
Kvetch:
Name: 'Napalm bomb - 317', VNum: [ 337], RNum: [ 258]
Trigger Intended Assignment: Objects
Trigger Type: Command , Numeric Arg: 2, Arg list: nap
Commands:
if napalm /= %cmd%
if %actor.fighting% && !%arg%
set arg %actor.fighting%
end
if !%arg%
%send% %actor% Throw it at Who?
halt
end
if %arg.room% != %actor.room%
%send% %actor% Throw it at who?
halt
end
%send% %actor% You throw the napalm at %arg.name%, it strikes %arg.himher% and shatters, exploding into a ball of fire consuming %arg.himher% completely.
%echoaround% %actor% %actor.name% throws the napalm at %arg.name%. It shatters and explodes into a ball of fire consuming %arg.himher%.
%asound% A large explosion is heard close by.
set stunned %arg.hitp%
%damage% %arg% %stunned%
wait 5 sec
%echoaround% %arg% %arg.name% collapses to the ground as the flames die down. %arg.heshe% seems to still be alive, but barely.
End
** I found this script interesting for a couple of reasons. First, the ability to set an arg when it isn't explicitly given and the fact you can find out the himher on that arg. Also, who doesn't like a Napalm bomb? **
Kvetch:
Name: 'Mob Act - 98 Teleporter Give', VNum: [ 398], RNum: [ 265]
Trigger Intended Assignment: Mobiles
Trigger Type: Act , Numeric Arg: 0, Arg list: has entered the game.
Commands:
if !(%actor.inventory(82)%)
wait 1s
say You are not prepared to travel these realms to their fullest.
wait 1s
say Maybe I can help you.
%load% obj 82
give teleporter %actor.name%
*could actor carry the weight?
if !%actor.inventory(82)%
drop teleporter
end
wait 2s
say With this you may teleport to areas that may not be accessible in
any other way.
wait 2 sec
say HELP AREAS
end
** I chose this script because I've always wondered what an ACT script actually was – since there never seems to be much detail behind any of them anywhere. Looking at the Arg list, I can then assume that this script reacts to any time it sees “has entered the game”
Kvetch:
Just a short trigger to keep this up as often as possible.
Name: 'Mob Greet direction', VNum: [ 302], RNum: [ 223]
Trigger Intended Assignment: Mobiles
Trigger Type: Greet , Numeric Arg: 20, Arg list: None
Commands:
* By Rumble of The Builder Academy tbamud.com 9091
if %actor.is_pc%
wait 1 sec
if %direction% == none
* if the character popped in (word of recall) this will be hit
say Where did YOU come from, %actor.name%?
else
say Hello, %actor.name%, how are things to the %direction%?
end
end
Kvetch:
Name: 'Panning for gold', VNum: [ 700], RNum: [ 280]
Trigger Intended Assignment: Rooms
Trigger Type: Command , Numeric Arg: 100, Arg list: p
Commands:
* Don't let someone spam the trigger to make money Take some movement points away every round and stop when they get to 10
if %actor.move% <= 10
%send% %actor% You are too exhausted to continue.
halt
end
* Fire on pan gold or abbreviations of each word
if %cmd% /= pan && %arg% /= gold
eval heldobj %actor.eq(hold)%
* Make sure they picked up the gold pan in room 703 and are holding it
if %heldobj.vnum% == 717
%send% %actor% You dip your pan into the river and scoop up some of the river bed and begin swirling it in the water.
%echoaround% %actor% %actor.name% dips a pan into the river and begins panning for gold.
* Take 10 movement points away, wait 3 seconds and give a 1 in 10 chance of success.
nop %actor.move(-10)%
wait 3 sec
if %random.10% == 1
%send% %actor% You find a small gold nugget in the bottom of your pan.
%echoaround% %actor% %actor.name% picks something out of %actor.hisher% pan.
* Give them a nugget
%load% obj 718 %actor% inv
else
%send% %actor% You find nothing of value.
end
else
%send% %actor% You need a pan for that.
end
end
** This would be an interesting script for an area in the Old West – if we don't already have it **
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version