Very simple paths?

panamaniac
Posts: 14
Joined: Thu Jul 31, 2014 7:21 pm

Very simple paths?

Post by panamaniac »

So I'm very new at this, and I can tell that the complex stuff is way beyond me.

What I'm trying to do is simple: imagine a 10x10 square of rooms, with me starting in ne corner. I want a path/speedwalk that goes 10s, 10w, 10n, 10e...but that I can stop and restart along the way at designated places. Restarting with the same command is the key. For example, let's say I wanted to stop in se, sw, and nw corners. Ideally, I'd start the walk, it would go 10s and stop. Then, when I nod or something, it would go 10 w and stop, waiting for another nod.

Does something like this exist or can it be created? I can't find a way to do it in mudlet.

FYI, how I'm currently managing this is by having lots of aliases. For instance, "a1" to make me go 10s, then "a2" to make me go 10w, etc. It's a lot more cumbersome simply b/c I have to type the next number (e.g., a78) for each new room.

Thanks for any help for this noob!

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

Re: Very simple paths?

Post by demonnic »

So you know where you'll want to stop each time?

If that's the case, it's not too bad. For each such path, you would make a table
Code: [show] | [select all] lua
pathing = pathing or{}
pathing.currentPath = pathing.currentPath of ""
pathing.currentNode = pathing.currentNode or 0
pathing.walks = pathing.walks or {}
pathing.walks.someWalkName = { "10s", "10w", "10n", "10e"}
--you would continue to add others as pathing.walks.someOtherWalkName, etc

Where someWalkName is a convenient name for you to remember the path set. To walk it, I would use two aliases... startPathing and cp (for continue pathing, but nice and short.. you could use anything really)
Code: [show] | [select all] lua
--startPathing alias. matches on "^startPathing (\w+)$"
pathing.currentPath = matches[2]
pathing.currentNode = 1
speedwalk(pathing.walks[pathing.currentPath][pathing.currentNode])
and cp:
Code: [show] | [select all] lua
--alias to continue the path. Or you could make a label or whatever. Just have it match on "^cp$" if it's an alias. No parameters

if pathing.currentNode < #pathing.walks[pathing.currentPath] then
  pathing.currentNode = pathing.currentNode +1
  speedwalk(pathing.walks[pathing.currentPath][pathing.currentNode])
else
  pathing.currentNode = 0
  cecho("<red:yellow>You're at the end already, bub!")
end

Now... I haven't tested it, but that -should- do what you want, stopping at each 'break' point. Is that what you were looking for, or am I off the mark?

panamaniac
Posts: 14
Joined: Thu Jul 31, 2014 7:21 pm

Re: Very simple paths?

Post by panamaniac »

Thanks so much for the reply! You're totally on the mark—but this makes no sense to me. I'm reading up on the manual, as well as the specific wiki for tables (http://lua-users.org/wiki/TablesTutorial), but still am having a hard time. Can you explain this to me like I'm a 4-year-old?

First, do I start by just pasting in the content from the first box of code you shared? If so, where? Under scripts-->Add item, then just paste it in? I delete the green text about "add your lua script here," paste your code, but it gets the following bug: Lua syntax error:[string "pathing = pathing or{}..."]:2 attempt to call global "of" (a nil value).

As you can see, I'm a total noob. I think I understand the basic idea behind tables, but I don't know where to build them in Mudlet, and I don't know how to make them work. For instance, I'm trying to do the basic "foo=123" stuff in that wiki article, but it's not working at all. If someone can explain this more basically that would be super helpful. Meanwhile I'll keep trying to make this work/understand it on my end.

Thanks again for any help!

panamaniac
Posts: 14
Joined: Thu Jul 31, 2014 7:21 pm

Re: Very simple paths?

Post by panamaniac »

OK, so as to that first string of code, I replaced "of" with "or" near the end of line 2, and that fixed the bug.

I then created the startPathing alias (Alias name: startPathing; Pattern: ^startPathing$; Substitution: I left this blank). This showed no bugs.

Now, if I type "startPathing," nothing happens (the MUD doesn't respond either). Seems like progress!

However, I created the cp alias and it's bugged. The bug reads: Lua syntax error:[string "function Alias312()..."]:5: 'end' expected (to close 'function' at line 1) near ".

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

Re: Very simple paths?

Post by demonnic »

the alias should be "^startPathing (\w+)"$" and you would call it by giving it the name of the path you want it to start, so if you have a path named "OrcRun" you would type "startPathing OrcRun" and it would do the first segment of the path.

As for the cp alias, that doesn't sound right. Try removing and remaking it, without the comment or anything?

panamaniac
Posts: 14
Joined: Thu Jul 31, 2014 7:21 pm

Re: Very simple paths?

Post by panamaniac »

WOW. All fixed. This is perfect. TY sir!

So for other walks, I would just add additional lines to the end of that first code—

pathing.walks.BrandNewWalkName = { "5nw", "2w"}

So basically this one script would be the home for all my speedwalks!

Thank you again!!

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

Re: Very simple paths?

Post by demonnic »

Always happy to help =)

panamaniac
Posts: 14
Joined: Thu Jul 31, 2014 7:21 pm

Re: Very simple paths?

Post by panamaniac »

OK, another question: What if I want my path segments to have non-typical directions (e.g., barn, porch, etc.)?

It seems like the paths only recognize basic directional commands as directions at the moment. Is there a way to change that?

panamaniac
Posts: 14
Joined: Thu Jul 31, 2014 7:21 pm

Re: Very simple paths?

Post by panamaniac »

Bumping this in case anyone has a suggestion. I tried putting non-directions in quotes but it doesn't help. I figure the main way to fix this would be to find where in mudlet is the library that knows the cardinal directions, then add additional entries for other words. Any thoughts?

Jor'Mox
Posts: 1146
Joined: Wed Apr 03, 2013 2:19 am

Re: Very simple paths?

Post by Jor'Mox »

Have you added the directions as special exits for the rooms in your map? It seems that if those are in place, I would expect the path to be properly generated using those commands.

Post Reply