Two problems (variables I guess)

Posted by Noideas on Tue 14 May 2013 11:40 PM — 5 posts, 18,983 views.

#0
Hello,

I've been using MUSH for a bit and so far I enjoy it. I'm not a coder, I just love playing text-games.

I've tried to deal with this myself for quite a while now. The first problem I've almost managed to solve, but something is missing. The second one I have no idea how to even start and hope for some input and help.

1st problem:

Every room in the MUD I play, Imperian, has a number. You can view it by hitting ROOMNUM and then you get a display that looks like this:

Quote:
Room #13092 - 'Looking out over Imperial Stavenn.'


I am trying to capture that text to a variable and then send that to a certain channel. I.E

Quote:
(Citytells): You say, "I am at Room #13092 - 'Looking out over Imperial Stavenn.'"


The " lines (inluding .") in the above quote is automatically insterted by the MUD

I'm using this, with some result:

Quote:

<triggers>
<trigger
enabled="y"
expand_variables="y"
match="Room*"
send_to="9"
sequence="90"
variable="Roomnum"
>
<send>%1</send>
</trigger>
</triggers>

And then:

<aliases>
<alias
match="roomroom"
enabled="y"
expand_variables="y"
send_to="12"
sequence="100"
>
<send>world.execute ("roomnum");
world.setvariable ("Roomnum", "%1");
world.getvariable ("Roomnum");
world.doafter (1, "msg randomdude I'm at @Roomnum");</send>
</alias>
</aliases>



I used the 'getvariable' there because I've been trying to make it send the room I am in currently, instead of the last stored variable. I can capture the room in variable, but it is always the last room I checked, instead of the trigger capturing the text I get when moving a room and then running the alias. From what I understand, the script when run is sendind ghr last stored variable instead of waiting until I get a new one, but I don't know how I would write it up to make it update quick enough for me to be able to simply 'go east, check roomnum and make the trigger send that roomnum to 'randomperson''.

The 'doafter' I put in becuase I was hoping another second after getting the roomnum and hopefully storing that in the variable would send the actual room, not the room I last looked ROOMNUM in.

Problem two (maybe I should make a new post for this, since it seems more complicated, but I'll give it a go.

I have NO idea how to make this work, but basically I want to omit some text, send some text UNLESS I have that text 'saved' or 'stored' somewhere to not send it. The message from the MUD is:

Quote:

You bid your ouroboros to seek out life presences nearby.
Salish is at Skirting the Areish Mountains, at 425 health and 528 mana.
Septus is at Approaching wet plains, at 543 health and 538 mana.
Randomdude is at Approaching wet plains, at 543 health and 538 mana.
Masked man is at Approaching wet plains, at 543 health and 538 mana.
Masked woman is at Approaching wet plains, at 543 health and 538 mana.
Eathi is at Approaching wet plains, at 543 health and 538 mana.


Note, that the quotes tag put everyting on the same line here. In Imperian, after 80 characters there is a newline (perhaps not important when omitting, but I thought it would be important to mention).

What I want that to do is to just send who is in the area, while omitting some names I chose myself. With the example above, I'd like this to be sent to a channel:

clantell Septus, Randomdude, Masked man, Masked woman, Eathi is in the area.

I've omitted the name Salish and everything after the other persons names.

If someone could point me in the right direction for the 2nd issue, I'd be very glad.

Thank you for reading and hopefully replying.



Amended on Wed 15 May 2013 06:57 PM by Noideas
#1
Apparently I was able to solve my first problem doing this:

Quote:

<triggers>
<trigger
enabled="y"
expand_variables="y"
group="Roomnums"
match="^Room(?P&lt;Roomnum&gt;.*)"
regexp="y"
sequence="90"
variable="Roomnum"
>
<send>rt I am at %&lt;Roomnum&gt;</send>
</trigger>
</triggers>


Still no idea about the next one though and don't know why all my tries with using * and making me send %1 instead didn't work instead of having to name the wildcard.
Australia Forum Administrator #2
First problem:


world.setvariable ("Roomnum", "%1");
world.getvariable ("Roomnum");
world.doafter (1, "msg randomdude I'm at @Roomnum");</send>


The way MUSHclient expands out variables (in this case @Roomnum) is before handing this code over to the script engine. So @Roomnum is going to be what it was at the start of execution. Changing it half-way down won't affect the variable.

Plus:


world.getvariable ("Roomnum");


That doesn't do anything useful. You have to put the variable somewhere, eg.


roomnumber = world.getvariable ("Roomnum");


However my first remark still applies.
Australia Forum Administrator #3
It's better to use 'code' tags for code (eg. triggers and MUD output) rather than 'quote' tags because that preserves the spacing.

Your second problem sounds like you could get help from here:

Template:faq=37
Please read the MUSHclient FAQ - point 37.


Personally I prefer Lua these days as a script engine, but whatever, if you want to use VBscript.

Following the ideas in that FAQ you could capture each line of output, and then look at the first word (the player name) and see if it is in your list (there are various ways you could do that) and if not, build up another list for your clantell.
#4
Many thanks, Nick!