Torch Auto

Need some help with your MUD client? Forgot your password? Get help here.
Forum rules
- Use common sense and be respectful towards each other at all times, even when disagreeing.
- Do not reveal sensitive game information. Guild secrets, player seconds are examples of things not allowed.
Kwevin
Veteran
Posts: 207
Joined: 21 Mar 2016 09:17

Torch Auto

Post by Kwevin » 18 Apr 2018 02:23

Just wondering about something here. Would it be at all possible to automatically light torches with a trigger if it's dark, and extinguish them when there is light again? Cuz let's be honest, everyone occasionally forgets about their torches until they burn out after you've been sitting somewhere idle for three hours.

Think it could be done? Currently I'm using Mudlet.
Alea iacta est. Serius regredi est.

sylphan
Veteran
Posts: 234
Joined: 12 Nov 2017 19:56

Re: Torch Auto

Post by sylphan » 18 Apr 2018 05:50

Kwevin wrote:Just wondering about something here. Would it be at all possible to automatically light torches with a trigger if it's dark, and extinguish them when there is light again? Cuz let's be honest, everyone occasionally forgets about their torches until they burn out after you've been sitting somewhere idle for three hours.

Think it could be done? Currently I'm using Mudlet.
I haven't used torches in a long time. Do they give a message just before they go out (e.g. "the flame on the excellent torch begins to flicker and fade" or whatever)? If so just make a trigger. But I also think you can light a torch, as long as it's in inventory but not in a pack or anything, even if you're in darkness.

Drazson
Titan
Posts: 499
Joined: 24 Jan 2016 21:27

Re: Torch Auto

Post by Drazson » 18 Apr 2018 09:36

Have 2 out, 1 lit. When the message pops, light torches, get torch from pack.

User avatar
Shanoga
Wizard
Posts: 193
Joined: 03 Mar 2014 13:03
Location: US West

Re: Torch Auto

Post by Shanoga » 18 Apr 2018 18:51

I like to use the Excellent Torches from Avenir/Sybarus. I usually run through the tunnels underneath the Dark Elves and grab some from the crates/chests. They burn about 30min each and I carry 5 or so. I have this simple trigger in Mudlet for lighting them after one burns out (I usually burn two at once)

PATTERN (perl regex):

Code: Select all

^(?:> )?The excellent torch goes out\.$
TRIGGER CODE:

Code: Select all

sendAll("light torch","light second torch",false)
sendAll("open scrip","get torch from scrip",false)
tempTimer(1,function() send("close all",false) end)

If you wanted to set it up so that it auto-lights when you enter "A dark room." you could use the following. It is dependent on having at least one torch in your inventory when you enter the dark room.

PATTERN (perl regex):

Code: Select all

^A dark room\.$
TRIGGER CODE:

Code: Select all

send("light torches",false)

Syrk
Rising Hero
Posts: 362
Joined: 06 Jul 2011 22:24

Re: Torch Auto

Post by Syrk » 18 Apr 2018 21:09

Shanoga wrote:
PATTERN (perl regex):

Code: Select all

^(?:> )?The excellent torch goes out\.$
One can also:
TRIGGER CODE:

Code: Select all

send ("drop burnt torch")

Raelle
Great Adventurer
Posts: 166
Joined: 18 Jul 2017 19:31

Re: Torch Auto

Post by Raelle » 18 Apr 2018 21:28

I have no idea how to code, but could one write a script to periodically <appraise light> and then <extinguish torches> if 1) it's light, naturally or otherwise, and 2) nothing is emitting darkness?

sylphan
Veteran
Posts: 234
Joined: 12 Nov 2017 19:56

Re: Torch Auto

Post by sylphan » 18 Apr 2018 22:15

Raelle wrote:I have no idea how to code, but could one write a script to periodically <appraise light> and then <extinguish torches> if 1) it's light, naturally or otherwise, and 2) nothing is emitting darkness?
I don't see why not. Sounds like you'd want A. a alias that starts (and another that stops) B. a timer and C. a trigger with two patterns, that fires when either one is matched.

This would be easy in Mudlet (so easy that I could do it!), but if you're using something else, including the web client, I've no idea.

Syrk
Rising Hero
Posts: 362
Joined: 06 Jul 2011 22:24

Re: Torch Auto

Post by Syrk » 18 Apr 2018 22:47

Raelle wrote:I have no idea how to code, but could one write a script to periodically <appraise light> and then <extinguish torches> if 1) it's light, naturally or otherwise, and 2) nothing is emitting darkness?
It would interfere with magic map and seeing exits - you can not see them in dark and you would have to move to other room with active light source to be able to. It is easier to have torch on all the time.

User avatar
Shanoga
Wizard
Posts: 193
Joined: 03 Mar 2014 13:03
Location: US West

Re: Torch Auto

Post by Shanoga » 18 Apr 2018 23:11

Raelle wrote:I have no idea how to code, but could one write a script to periodically <appraise light> and then <extinguish torches> if 1) it's light, naturally or otherwise, and 2) nothing is emitting darkness?
Certainly. I'm one who tends to try and reduce spam, so I would create some an additional trigger that gags the typical MUD output from appraise light when it checks. You could check whenever you want - including in every room you enter. You could do some combination of the following things.

Keep in mind, I am writing this here only and not in Mudlet therefore I haven't tested it.



Trigger "Automatically Extinguish Torches":
PATTERNS:

Code: Select all

^(\w+) is in the open air and naturally light\.$
^(\w+) is indoors and lit\, either by a torch\, or by natural sources\.$
TRIGGER CODE:

Code: Select all

selectCurrentLine()
deleteLine()
if torchLit = true then
   send("extinguish torches", false)
   torchLit = false
end
***Reduces the spam that you'll see in pretty much every room as you enter.


Trigger "Gag Dark Room":
PATTERNS:

Code: Select all

^(\w+) is indoors and naturally dark\.$
^It is dark\, very dark\. What else is there to observe\? Nothing\, you see nothing\.$
TRIGGER CODE:

Code: Select all

selectCurrentLine()
deleteLine()
***Reduces the spam that you'll see in pretty much every room as you enter.


Script "AutoExtinguish":
User Event Handler:

Code: Select all

gmcp.room
SCRIPT CODE:

Code: Select all

function AutoExtinguish()
   if torchLit = true then
      enableTrigger("Gag Dark Room")
      enableTrigger("Automatically Extinguish Torches")
      send("appraise light",false)
   end
   tempTimer(.5, function()
      disableTrigger("Gag Dark Room")
      disableTrigger("Automatically Extinguish Torches")
   end)
end
***This script will run whenever your client receives a gmcp.room packet, which is every time you enter a room. If torchLit is enabled(true) then your client will check the light in the room to see if you should extinguish your torch. It gags the appraise light output so your screen doesn't get filled with it. We disabled the trigger on a timer so that if there is up to .5 sec of server lag, the message will still be gagged.
If you don't want to check in every room, you could set this up to check every 5th, 10th, or any interval of rooms that you want. Simply add this to the code just below "function AutoExtinguish()" and change "10" to the interval of rooms that you want to check:

Code: Select all

roomLightCounter = roomLightCounter or 0
roomLightCounter = roomLightCounter + 1
if roomLightCounter ~= 10 then
   return
end
roomLightCounter = 0
You would also want to make the following updates to the things I posted above:
PATTERN (perl regex):

Code: Select all

^A dark room\.$
TRIGGER CODE:

Code: Select all

send("light torches",false)
torchLit = true
***The only difference here is that we are now setting the torchLit variable, which basically enables your client to send the <appraise light> command to the MUD so you can auto-extinguish.


I would also recommend an alias like this if you go this route:
ALIAS PATTERN:

Code: Select all

^light (\w+ )(torch|torches)$
ALIAS CODE:

Code: Select all

send(matches[1])
torchLit = true
**This allows you to set the torchLit variable every time you light a torch manually, even if you <light second torch> or <light small torches>.


And just to be safe, if you ever DO want to appraise the light in the room and something has gone weird with your torchLit variable, we want to make sure we aren't gagging the output:
ALIAS PATTERN:

Code: Select all

^appraise light$
ALIAS CODE:

Code: Select all

disableTrigger("Gag Dark Room")
disableTrigger("Automatically Extinguish Torches")
send(matches[1])(
What's the point of all this? What does it do?
This allows you to automatically be checking the light status in the room for EVERY room you enter IF you have a torch lit, but it shouldn't be spamming your screen with all of the checks. As soon as you enter a lit room, you will automatically extinguish your torch and set Mudlet to NOT send the <appraise light> command to the MUD. Your Mudlet will be running the code, but you won't be spamming the Genesis servers this way.
Note: It's kinda hacky. There are probably more elegant ways of doing it. This may have some errors since it's totally untested. and I wrote it in this post instead of in Mudlet. But this will at least get you started and you could potentially add specific cases on top of this.

Raelle
Great Adventurer
Posts: 166
Joined: 18 Jul 2017 19:31

Re: Torch Auto

Post by Raelle » 20 Apr 2018 21:46

thanks for posting that Shanoga!!

like I said, I don't know how to do this stuff, but I'd like to learn, so it's really helpful to see all the different parts laid out as you did above.

Post Reply
http://tworzymyatmosfere.pl/przescieradla-jedwabne-z-gumka/