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
Kison
Beginner


Joined: 02 Aug 2004
Posts: 18
Location: Right Here!

PostPosted: Thu Aug 05, 2004 6:30 pm   

Adding Newlines to String Arrays
 
Hey all,

Is it possible to add a newline "\n" to a string array? For example, I want to have an array that will store a walk cycle, and sometimes I will have the guy stop and do something else, therefore I need to have one item of the array contain more than one walk directions, which requires a newline.

However, I think that someone else would have done something or needed something similar to this and there might be a more efficient way to do this. If you all don't understand what I'm asking, let me know and I'll try to make my question make a little more sense.

Thanks.
_________________
Try me, yet remember the price of failure.
Reply with quote
jessew
Apprentice


Joined: 03 Mar 2003
Posts: 141

PostPosted: Thu Aug 05, 2004 8:19 pm   
 
Not positive what you mean but to add a newline to a string you could use the %crlf function.
But if you mean you want to have an alias that will walk somewhere, maybe knock on gates to open them then continue walking you'd want to use the semicolon to seperate commands like
Code:

#ALIAS gotostore {.2ne;knock east;.2en}

or to store it as a string to execute
Code:

#VARIABLE storedirs ".2ne;knock east;.2en"
#EXEC @storedirs


Maybe one of those is what your after, Cheers
_________________
I love deadlines. I like the whooshing sound they make as they fly by.
Reply with quote
Kison
Beginner


Joined: 02 Aug 2004
Posts: 18
Location: Right Here!

PostPosted: Thu Aug 05, 2004 8:43 pm   
 
What I mean is this.

I have an array, and each member of the array is a direction or some other kind of command. The problem is, I have another script that will call ONE command from that array after such and such amount of time. That leads to the problem of me needing it to move multiple rooms without the pause in between, which is why I am asking about the newline. If I can stick a newline in one member of the array, I can have two commands going before it pauses again.

Semicollon didn't work ;).
_________________
Try me, yet remember the price of failure.
Reply with quote
Kison
Beginner


Joined: 02 Aug 2004
Posts: 18
Location: Right Here!

PostPosted: Thu Aug 05, 2004 8:47 pm   
 
Ok, let me make it clear what I mean by two commands in one member of the array.

Let's say we have an array like this:

Code:

0: north
1: east
2: east
3: north
4: west
5: rest


What I need is for my array do have something like:

Code:

1: east
2: west;south;open door;west
3: north
4: open door;west


Where the ";" is a multiple command inside one member. Making more sense now? :)
_________________
Try me, yet remember the price of failure.
Reply with quote
jessew
Apprentice


Joined: 03 Mar 2003
Posts: 141

PostPosted: Thu Aug 05, 2004 8:57 pm   
 
Yep thats what my 3rd version was for when you add the string in array write it with the semicolons just surround it with quotes for example "open door;west"

Cheers
_________________
I love deadlines. I like the whooshing sound they make as they fly by.
Reply with quote
Kison
Beginner


Joined: 02 Aug 2004
Posts: 18
Location: Right Here!

PostPosted: Thu Aug 05, 2004 9:51 pm   
 
jessew wrote:
Yep thats what my 3rd version was for when you add the string in array write it with the semicolons just surround it with quotes for example "open door;west"

Cheers


There is still a problem. When I use #EXEC, it will add in the "|"s when it puts in the input. By that I mean, it will put in something like "west|north|east" until it reaches a semicolon. Now the problem with NOT using #EXEC is that Zmud doesn't recognize semicolon as a newline, yet it does when you use #EXEC.

Any way around it?
_________________
Try me, yet remember the price of failure.
Reply with quote
jessew
Apprentice


Joined: 03 Mar 2003
Posts: 141

PostPosted: Thu Aug 05, 2004 10:09 pm   
 
Well yes because your using #exec on a list and the | is the list seperator, probably just want to use a string.

Intstead of this list:
1: east
2: west;south;open door;west
3: north
4: open door;west

You could just make a string "east;west;south;open door;west;north;open door;west"

But if you want to keep it as a list you will have to loop through your list with #forall
like so

#FORALL @YOURDIRLIST {#EXEC %i}
_________________
I love deadlines. I like the whooshing sound they make as they fly by.
Reply with quote
Kison
Beginner


Joined: 02 Aug 2004
Posts: 18
Location: Right Here!

PostPosted: Thu Aug 05, 2004 10:53 pm   
 
By looping through a list, it'd go through everything though, right?

I'm trying to access one row of the array at a time, so if I have semicolons in there, they'll go off, but ONLY those.

So:

1: North
2: South
3: east;north;open door;east
4: south

When I get to number 3, I want it to set off east, north, open door, east. But NOTHING else until another trigger increases the variable that keeps track of what I am on.

So by using #FORALL, what all does that do? Because I don't want this to loop through the list and set everything off at the same time.
_________________
Try me, yet remember the price of failure.
Reply with quote
jessew
Apprentice


Joined: 03 Mar 2003
Posts: 141

PostPosted: Thu Aug 05, 2004 11:20 pm   
 
Oh ok gotya, yeah forall would do all at once.
All you have to do is use %item to execute the step your on.

Here's your list of steps we'll say its in variables @Directions
1: North
2: South
3: east;north;open door;east
4: south

And let's say you have a variable @step that keeps track of the step your on

then you could just #EXEC {%item(@Directions,@step)}
_________________
I love deadlines. I like the whooshing sound they make as they fly by.
Reply with quote
Kison
Beginner


Joined: 02 Aug 2004
Posts: 18
Location: Right Here!

PostPosted: Fri Aug 06, 2004 12:59 am   
 
That works. Thanks man, very much appreciated.
_________________
Try me, yet remember the price of failure.
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