Trigger for Bump-testing Hidden Exits

Post Reply
Scinternace
Posts: 4
Joined: Thu Jan 13, 2022 5:44 pm

Trigger for Bump-testing Hidden Exits

Post by Scinternace »

Hey all,

New to the forum, and to mudlet. I know how to create some very basic triggers, but this one is beyond my ability to think through.

The mud I play has hidden exits - exits that will not show as a possible direction to move in until the player has already tried to move that way. In this case they will 'bump' into a hidden door, at which point it becomes a visible exit.

I want to find these exits. But I DON'T want to manually go in every possible direction besides those shown every time I enter a room.

I was wondering if it were possible to create a script/trigger that will automatically explore in every direction that isn't initially shown as a "north", "south", etc. exit whenever I enter a room. For example, if I enter a room that has exits to the North and South, my character will automatically try to go east, west, up and down. Would that be possible?

Looking forward to reading your replies, I welcome any and all advice on this

User avatar
demonnic
Posts: 808
Joined: Sat Dec 05, 2009 3:19 pm

Re: Trigger for Bump-testing Hidden Exits

Post by demonnic »

It's certainly doable, yeah. You'd want to list out all the possible directions you want to check in a table, and then make a trigger for the exits line from your game which captures the exits and loops the table of possible directions. So if the exits come in as "Obvious exits: north, east, southeast" you could use a trigger that matched the pattern "^Obvious exits: (.*)" and the following code
Code: [show] | [select all] lua
local dirs = { "north", "northeast", "east", "southeast", "south", "southwest", "west", "northwest", "up", "down", "in", "out" } -- edit to suit your game
local knownExits = string.split(matches[2], ", ") -- this line takes "north, east, southeast" and turns it into a table, {"north", "east", "southeast"}
for _, exit in ipairs(dirs) do --this loops the dirs table of possible directions
  if not table.contains(knownExits, string.lower(exit)) then --if the direction isn't in the table we made from the captured exits
    send(exit) --try to go that direction
  end
end

The actual code may need to be tweaked depending on what the exits line actually looks like from your game, but hopefully this gets you started.

Scinternace
Posts: 4
Joined: Thu Jan 13, 2022 5:44 pm

Re: Trigger for Bump-testing Hidden Exits

Post by Scinternace »

That's a huge help, thank you so much!

Scinternace
Posts: 4
Joined: Thu Jan 13, 2022 5:44 pm

Re: Trigger for Bump-testing Hidden Exits

Post by Scinternace »

I tinkered around with this a little, customizing it to include only the directional commands that apply to my mud, but in its current state the trigger isn't functioning. Have I entered everything correctly?

The error showing in the error log seems unrelated, but I have included it anyway on the offchance that it isn't.

Image

Pattern: ^Exits: (.*) -- My mud's exit list line reads like [Exits: North East Etc.]

Code: Select all

local dirs = { "north", "east", "south", "west", "up", "down" }
local knownExits = string.split(matches[2], ", ")
for _, exit in ipairs(dirs) do
if not table.contains(knownExits, string.lower(exit)) then
send(exit)
end
end

User avatar
demonnic
Posts: 808
Joined: Sat Dec 05, 2009 3:19 pm

Re: Trigger for Bump-testing Hidden Exits

Post by demonnic »

you'll want to try the pattern

Code: Select all

^\[Exits: (.*)\]
And for the code try instead
Code: [show] | [select all] lua
local dirs = {"north", "east", "south", "west", "up", "down" }
local knownExits = string.split(matches[2], " ")
for _, exit in ipairs(dirs) do
  if not table.contains(knownExits, string.lower(exit)) then
    send(exit)
  end
end
[lua]

Scinternace
Posts: 4
Joined: Thu Jan 13, 2022 5:44 pm

Re: Trigger for Bump-testing Hidden Exits

Post by Scinternace »

Perfect! That finally did it, I really appreciate the guidance.

I copy-pasted the pattern and code, labelled the pattern as perl regex and now I bump every wall I come across. My PC may end up with the flattest face in the realms, but no hidden room is safe from me now!

Post Reply