Help on a really quick relay script.

t4kato

New member
Hi. I'm unfamiliar with how relay scripts work yet. But there's been this one functionality that I've been dying to see added to the graphical interface of the relay browser.

Usually when I'm adventuring, it's helpful to see what's happening on the character panel. Unfortunately the panel doesn't seem to update as frequently as I want it to, so I'm left with right clicking and clicking through all the menus to "Reload this frame". Naturally a handful.

Is there a quick way to add a [refresh] link to the top of the panel? I think this would be a nice addition to mafia as well.
 

jasonharper

Developer
Turn your monitor upside down. That way, the [refresh] link that mafia is already adding to the bottom of the charpane will now be at the top, as desired.
 

StDoodle

Minion
You're in a mood today, aren't you? ;)

Also; file enclosed; tested on compact side pane, no idea if it works on full.
 

Attachments

  • charpane.ash
    240 bytes · Views: 48

heeheehee

Developer
Staff member
I'm pretty sure it also reloads on a more regular basis if you have chat open -- something like after every adventure? Or is it action?
 

t4kato

New member
Oh thanks all of you. Thanks Doodle! This should help me understand relay scripting as well. =]

And...I'm aware of the link at the bottom of charpane; am confused by the design decision to put it there. For those of us with 30+ buffs, this is almost as much work as refreshing. :p
But quick fix either way.
 

lostcalpolydude

Developer
Staff member
Normally I would rather see another buff than the refresh link that I don't use very often. That link is more convenient than refreshing a frame in firefox, at least, and refreshing the whole window clears chat history.
 

t4kato

New member
I see what you're saying, but access to one extra buff in exchange for a less useful refresh link seems to be an unnecessary trade-off. I tinkered around with Doodle's script (thanks for showing me how!). If you squeeze the link above your character name, you can have a link at the top without sacrificing a buff either. :p

While doing so, I had trouble understanding the lazy matcher .+? thing. It kept matching the entire page and replacing everything. Isn't making it lazy supposed to prevent this? Any tips for this newbie?

Code:
<center>.+?refresh.+?</center>

Specifically, this matched the whole page instead of just the block containing the refresh. :(
 

StDoodle

Minion
Your problem might be that "<center>" exists in the javascript above the main page, so it's matching starting there. You may want to match against "<body.+?<center>.+?refresh.+?</center>" to match just vs. the main chunk of the page. But I'm not sure exactly what you're trying to do, so *shrug*.
 

t4kato

New member
Haha. This stuff is really confusing. I have another question. In this matcher, I was trying to match a number followed by a string of text like "12 pie crust". However, as you'll notice, I used \\d instead of \d to capture digits. \d kept trying to match the letter 'd' for some reason. Why would this be? x_X

Code:
matcher m = create_matcher("(\\d+) (.+)", str);

One last question: is there any way to get the CLI to accept a string of parameters instead of just one when calling a .ash script? For example, it's really convenient that you can do stuff like "adventure.ash 20" to pass in 20 as a variable. But you can't do "mall.ash 5, anti-anti-antidote". I've tried various other ways, but none of them have worked. Is it not possible? If not, I'd love to see it implemented.
 

StDoodle

Minion
You need to double-escape pattern slashes, as mafia escapes them in all strings, so it interprets "\d" as "d".

For your CLI argument question; your best bet is to accept a single string parameter (by having void main(string args) as your main declaration) and then do some parsing on the string inside of the script to break it up into multiple arguments. For example,
Code:
void main(string args) {
    string [int] arglist = split_string(args, ",\\s*");
    foreach a in arglist {
        print(arglist[a]);
    }
}
Would except a list of arguments, separated by a comma & 0 or more spaces.
 

jasonharper

Developer
Backslashes have special meaning to both string constants and regexps: you have to double the backslash in the string to pass a single backslash through to the regexp. Here's an experiment for you to try in the CLI:
ash length("\\d")
This produces 2, not 3 - this string actually contains a single backslash followed by a 'd'.

To pass multiple parameters to a script from the CLI, you have to accept a single string parameter and split it up yourself.
 

t4kato

New member
Oh! Thank you all for these resources. Well I tackled the problem crudely myself with the "(\\d+) (.+)" matcher above. :D

I was just wondering if I was being dumb again, completely ignoring an existing built-in mafia feature to handle multiple parameters. Guess not. =/
 
I'm pretty sure it also reloads on a more regular basis if you have chat open -- something like after every adventure? Or is it action?

I noticed one day that my char pane was updating rapidly (keeping up with mafia's automation, actually) and was startled by it so I posted here about it. I was told the same thing, that it updates when chat is open.

Since that day though, my char pane hasn't updated by itself unless I do some movement in the browser, even though I always have chat open (and always had before that day as well)
 

fronobulax

Developer
Staff member
I think the current solution is to have one parameter, a string, and have the script parse it. Bale has done that for EatDrink somewhere although I have yet to mainline his work.
 

t4kato

New member
After parsing the single string parameter, I'm left with two strings (one of which needs to be parsed into an integer). Is there a parseInt function? Currently I have:

Code:
int number = extract_meat("You gain " + n + " Meat")

There has to be a better way. xD
 

fronobulax

Developer
Staff member
After parsing the single string parameter, I'm left with two strings (one of which needs to be parsed into an integer). Is there a parseInt function? Currently I have:

Code:
int number = extract_meat("You gain " + n + " Meat")

There has to be a better way. xD

to_int()?
 
Top