Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Calabrel
Newbie


Joined: 06 Apr 2012
Posts: 2

PostPosted: Fri Apr 06, 2012 2:24 pm   

zMUD target script help please.
 
I have most of it done, I just need help with one other thing I want

The ability to alias set a target to whatever/whomever I'm currently engaged with:

I want to create an alias, say #alias i

What I want it to do is, if possible, look at the most first (starting from the bottom) instance of

Code:


^* HP:{Healthy|Scratched|Hurt|etc...} MV:{Fresh|Full|Strong|etc...|}

Then if

^* S HP:{Healthy|Scratched|Hurt|etc...|} MV:{Fresh|Full|Strong|etc...| - %1: {Healthy|Scratched|etc... >

#alias i {#VAR target %1;#ECHO %1 is now your target.}

if not

#alias i {#ECHO target is not changed.}



So basically if I'm engaged, the alias will set my target and echo that it set it. If I'm not engaged, it will echo that no target is set. Both cases I don't want commands sent to the mud.

I'm pretty sure zMUD is able to do this, but I'm not up and up and logic statements or if this is better done a different way.

Any help is appreciated.
Reply with quote
shalimar
GURU


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

PostPosted: Fri Apr 06, 2012 3:01 pm   
 
I would make two prompt triggers (assuming that is a prompt message), one for when its just your stuff, and another for when you are in combat

On the one where it has a target, %1 is not supposed to be used in the pattern
You should use pattern matching symbols instead.
Given how you have either side well defined '(*)' should work instead of '%1'.

then the trigger would perform something like...

#IF (@target!=%1) {#VAR target %1;#ECHO {%1 is now your target.}} {#ECHO {Target is unchanged}}

You could put that in an alias, but unless you plan on using it to manually set a target, there is no point.
_________________
Discord: Shalimarwildcat
Reply with quote
Calabrel
Newbie


Joined: 06 Apr 2012
Posts: 2

PostPosted: Fri Apr 06, 2012 5:00 pm   
 
Thanks, Shalimar. What are the advantages of using '(*)' over '%1'?

I'm not sure that's what I want exactly, or maybe I'm not understanding its full capability. But what you said got me thinking about this differently. Allow me to elaborate:

Here is an actual log of the game I play, I'll bold the prompt I'm interested in:

Quote:


* HP:Healthy MV:Strong >
w
The Lane
This dirt path that leads off the main road is hard-packed by the passage of many
feet. To the south you see a rough structure, and the sound and smell of horses
makes its purpose clear. To the east is a small building with the sign of a
courier pigeon painted above the door. The bank is just to the north.
[ obvious exits: N E S W ]
A hanging lantern lights the path.
A Shienaran guard patrols here, watching you carefully.
A black cat meanders to an unknown destination.
An old woman weaves a pattern on her loom.

* HP:Healthy MV:Strong > A black cat leaves north.
Main Road
The main road leads north further into town, and south toward the outer gates.
Everything around you is built extremely simple, solely for the purpose of
survival, with little or no creature comforts. The towers and walls of the
Keep can be seen on a hill north of here, and a small lane leads off to the
east.
[ obvious exits: N E S ]
An oil lamp, set in a steel cage, hangs from a high wooden pole.


Now in that case, I wouldn't want my var target to change, nor do I want an echo. A trigger would work best for that.

Now here's a situation where I want the IF/THAN statement to succeed. Again I've bolded only the prompt that I'm interested in for the IF/THAN statement to be true.

edit: See below, it seems I may not need an IF/THAN statement for this portion at all.

Quote:


* R HP:Hurt MV:Strong >
n
x
b
Dusty Road by Fal Dara
The road branches here, the main route leading north and south while a
wider offshoot leads up a hill to the west, approaching the gates of Fal
Dara. Despite the terrain, the ground appears well trodden and in good
repair, obviously worn down by constant use.
[ obvious exits: N S ]
A bruised and bloody leg lies on the ground, torn from its socket. [2]
An iron lantern hangs from the wall above the gate.
A warhorse is here, stamping his feet impatiently, being ridden by you.
*Ryak* is standing here.

* R HP:Hurt MV:Strong > [k dark]
You smite *Ryak*'s body.

* R HP:Hurt MV:Strong - Ryak: Hurt > *Ryak* barely blasts your right hand.
You tickle *Ryak*'s right foot with your smite.



Now in this example I'd like the trigger to prep my target variable for Ryak, but not set it. I also don't want an echo prompt.

Lastly, I need an alias that will call my target variable that the IF trigger set, and set that to another variable, let's call it target2.

So, help me out a bit here... but:

Code:

#Trigger {^* HP:{Healthy|Scratched|Hurt|etc...} MV:{Fresh|Full|Strong|etc...} - %1: {Healthy|Scratched|etc...} > } {#VAR target %1}
#Alias i {#VAR target2 @target;#ECHO @target is now your target.}


You know, I think that will work, I think like that I don't even need an IF statement. Then I could just use target2 for my macros/aliases for kill commands and other things.

I guess my only concern at that point could be the potential lag associated with constantly setting @target each time that prompt happens, could happen up to multiple times a second. Or no?

I just wish I was at home to test it now...
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Mon May 14, 2012 11:25 am   
 
By using %1 in a trigger pattern, you open yourself to vulnerabilities and abuse by others. Basically, using %1 matches everything, including special characters. Someone can abuse your triggers in-game by echoing patterns and hiding commands within the pattern that is matched by %1. You will then execute those commands.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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