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
Eul
Wanderer


Joined: 30 Jun 2007
Posts: 53

PostPosted: Sun Feb 10, 2008 5:12 pm   

New to script writing
 
Hi there, I have recently taken a break from MUD's in general and I am going to get back into the whole thing.

I wanted to write a few scripts but I did not want to use someone elses code, even as a basis, because I am doing this for a sort of sence of achevement! I have a few questions for you all, if you don't mind, and if anyone would like to help please refrain from showing me code, just point me in the direction of the help file :)

I am going to start off by developong a section of code to gather some information about the room my charcter is standing in. I was thiking about the diferant ways to get this trigger to fire off and I think maybe one based on the colour of the line of text. The problem is that the only line that I could use (as only one has a diferant colour) is the line ABOVE the one where the NPC information is. Is there a way to pick up all the next line of information untill it see's a "." ?

So once i figure out how to get that chunk of information off the mud I will be checking it for usefull parts and putting them into a list, something like this;
Code:
 IF ismember (%ismember(("some stuff,some more stuff, and other things"),@NPCS)))


I think thats right anyway.

Of course if I am going about this the wrong way please speak up :)

Thanks,

E.
Reply with quote
Leitia
Adept


Joined: 04 May 2007
Posts: 292
Location: Boston

PostPosted: Sun Feb 10, 2008 7:08 pm   
 
Predefined Variables may be of interest, also anything on advanced triggers might be useful. As well there are web tutorials on the not so obvious.

Though I think originality, while an achievement, is surpassed by more useful creativity. So using scripts allows me to work on things that have not been done. After all, the functions were written by Zuggsoft and those are scripted. No one is an island

whatever is fun Smile

edit: Thought to add that I will be releasing plus 250 kb of code. Before anyone who could read this says I borrowed, Dharkael did post a 1000 times more cool formula then I thought of, I did use that, but none of the scripts I began with have any code lingering, simply because I couldn't use that, though I would have given credit. I did learn methods though and hopefully wrote new ones empowered by what was proven. Not that my code is all that, but after slaving over it I do want credit for anything good that it may do.


Last edited by Leitia on Sun Feb 10, 2008 8:49 pm; edited 2 times in total
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sun Feb 10, 2008 7:20 pm   
 
You don't need the brackets around your string in your %ismember function. Note that that'll look for a member of the list that's the string "some stuff,some more stuff, and other things" and not for three different items in the list.

Every time you use a command, you need to start that line with # - so your line must begin #IF and not IF. I'm not sure why you have the word ismember there - you'll be checking the value that the %ismember function returns, so that needs to be the first argument (which is the expression to check for true- or falseness).

So your final command will look like this:

#if %ismember("some stuff,some more stuff, and other things", @NPCS) {do something if true} {do something else if false}
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Eul
Wanderer


Joined: 30 Jun 2007
Posts: 53

PostPosted: Mon Feb 11, 2008 9:04 am   
 
Just been tinkering with this, and I think I was going the wrong way with this to be honest.

How can I get Zmud to capture the last line of text sent from the mud? It has various diferant discriptions so a trigger based on a set pattern would not work, and sadly the colour trigger I tried would also not work, I'll report back when I have another read of the advanced trigger guide and have a search for predifined varibles, although by this I think you mean just a standard trigger, with set variables, like match1|match2|match3

Bah, I'll be back later :)

E.
Reply with quote
Leitia
Adept


Joined: 04 May 2007
Posts: 292
Location: Boston

PostPosted: Mon Feb 11, 2008 9:42 am   
 
REGEX patterns are more versitile, but so clever I did not have a clue except to observe others use it.

I have seen many people use #if (@var) and I have seen #if in the help. None of that was a given when tonight I wrote:

#if (!%null( %2) or %number( %subregex( %2, %char( 64), 1))) to mean simply #if (%2)

That is not anyone's conclusion but mine but the only one that worked on my machine for all evolutions.

What I am saying is a person can not escape doing original scripts by reading others


Last edited by Leitia on Mon Feb 11, 2008 6:29 pm; edited 1 time in total
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Feb 11, 2008 2:53 pm   
 
Matching on every line is a bad idea. If you're going to have a trigger with a catch-all pattern like (*) you're going to need strict rules in your script about when the trigger is enabled (it should be disabled most of the time) or you'll see a lot of slowdown as the script runs on every single line. Most things that people think are difficult or impossible to match are actually quite easy with regexes, as Leitia says. If we knew what all the possible lines were, we could help you write a regex.

We really need more information about the exact problem you're trying to solve to help you with this.

@Leitia: You can learn regex syntax here as well as in many other places across the net. They're really not all that hard, especially if you already know zScript pattern syntax.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Leitia
Adept


Joined: 04 May 2007
Posts: 292
Location: Boston

PostPosted: Mon Feb 11, 2008 6:28 pm   
 
Thank you Fang Xianfu
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