Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ VBscript ➜ Trying to gag lines only when walking

Trying to gag lines only when walking

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Zuurstof   (13 posts)  Bio
Date Mon 23 Dec 2002 11:10 PM (UTC)
Message
It sounds pretty easy but it has me cracking up. I'm trying to gag my prompt every time that I move. I use aliases to run through large amounts of rooms and every time I hit a new room it shows my prompt again, this wasn't so irritating at first but I had to turn on newline after every prompt for another script that I am using so now I get spammed to death, what used to be 1 line is now 2.

Example:
Mirkwood(e, s, w and n)
a dagger
a staff
[HP:210 EP:120]
Mirkwood(e, s, w and n)
[HP:210 EP:120]

this is what I get now instead of

the old way
Mirkwood(e, s, w and n) [HP:210 EP:120]


Anyways what I am trying to do is gag my prompt line when I move. But only when I move, now I got one thing that might help, you can always recognise a movement by (e,s, etc)
the "(" and ")" so that can be used to check if your last line was a movement line, but that bring me to another problem, what if there is stuff in the room like in the example(I don't think it's possible to help it not showing prompt now). I was thinking maybe we check the previous 2 lines somehow to see if there was a prompt and if so then gag the new prompt. This is just theory, I have no real idea how to work it out though. I can imagine keeping two global variabels and check them with instr or something if there was a prompt, but I have no idea on how to gag the new prompt then.

If anybody was able to follow this maybe bizare story and thinks he can add something positive to it I would be more then thankful.

Greetings Zuurstof,
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 24 Dec 2002 01:44 AM (UTC)
Message
Can you copy and paste the trigger you are using?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Zuurstof   (13 posts)  Bio
Date Reply #2 on Tue 24 Dec 2002 06:25 AM (UTC)
Message
I'm not using a trigger yet, this was all theory, but I was thinking on handling it in my hpStatus sub. In this sub I change my prompt

^\[HP\:(.*?) EP\:(.*?)\]$ and log from output enabled.

sub hpStatus(thename, theoutput, thewildcards)
dim clrHP
dim clrEP
dim hp
dim ep

hp = Cint(Trim(thewildcards(1)))
ep = Cint(Trim(thewildcards(2)))

if hp < 50 then clrHp = "red"
if hp => 50 then clrHp = "maroon"
if hp => 75 then clrHP = "orange"
if hp => 150 then clrHP = "yellow"
if hp => 200 then clrHP = "lime"

if ep < 50 then clrEP = "red"
if ep => 50 then clrEp = "maroon"
if ep => 100 then clrEP = "orange"
if ep => 150 then clrEP = "yellow"
if ep => 200 then clrEP = "lime"

world.ColourTell "Red", "", "("
world.ColourTell clrHP, "", "HP: " & thewildcards(1)
world.ColourTell clrEP, "", " EP:" & thewildcards(2)
world.ColourNote "Red", "", ")"
End Sub

So I just send a note back.
Maybe I could put a check around like the following example:

if instr(1,LastLine,"(") <> 0 and instr(1,SecondLastLine,"(") <> 0 then
world.ColourTell "Red", "", "("
world.ColourTell clrHP, "", "HP: " & thewildcards(1)
world.ColourTell clrEP, "", " EP:" & thewildcards(2)
world.ColourNote "Red", "", ")"
end if

So this should work and all I have to do now is every time I run this function to put
SecondLastLine = LastLine
LastLine = * ( <== this is what i'm unsure of ) I dunno how to put the entire line into a variable. Hope this helps clear things a bit up but i doubt it:)

Greetings Zuurstof,
Top

Posted by Zuurstof   (13 posts)  Bio
Date Reply #3 on Tue 24 Dec 2002 03:46 PM (UTC)
Message
Well I a little tinkering and I think I got a decent enough solution, i'm just wondering how much it could slow things down. I am evaluating every line with a * trigger.

That trigger calls a function that put
- SecondLastLine into ThirdLastLine
- LastLine into SecondLastLine
- LastLine = arrwildcards(1)
and that's it, I used global vars for this.

Next I went to my hpStatus function and edited it to check if there was a '(' in the SecondLastLine or the ThirdLastLine. If so then I dind't send the prompt to the world, so this seems work) It's a little dirty and it doesn't work for rooms with more then 2 items in it but for the rest is seems to work like a charm.

I'm just wondering if anybody knows a less dirty way to this, Now i'm evaluating every line with a trigger and so the trigger gets called A LOT:)

Greetings Zuurstof,
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #4 on Thu 26 Dec 2002 03:55 AM (UTC)
Message
You can use GetLineInfo to keep track of the contents of previous lines, so the * trigger is a bit of an overkill.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Shadowfyr   USA  (1,792 posts)  Bio
Date Reply #5 on Thu 26 Dec 2002 05:32 AM (UTC)
Message
Except that getlineinfo would require looking back a bit to find if it was a move and there is no certainty of success.

Everyone seems to be ovelooking the obvious. Use onplugincommand like so:

function OnPluginCommand (sText)
  dim Dirls, Dirs, count
  Dirls = "s,south,n,north,e,east,w,west,nw,northwest,"
  Dirls = Dirls + "ne,northeast,sw,southwest,se,southeast,"
  Dirls = Dirls + "u,up,d,down,open door" '-Add any others here.
  Dirs = split(Dirls,":")
  for count = 0 to ubound(Dirs)
    if instr(sText, Dirs(count)) then
      enabletrigger "GagPrompt", vbTrue
      exit for
    else
      enabletrigger "GagPrompt", vbFalse
    end if
  next
  OnPluginCommand = vbTrue
end function

Note: I assume this will gag on any line that includes movement, even if a stacked command contains both movements and standard commands. This is probably a minor issue though. The only real problem is that this will work only from in a plugin, thus both this script and the trigger it switched on/off needs to be placed into one.

Note: It can't handle things like 'open east door', but modifying it to do so shouldn't be too hard.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


20,438 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.