Page 1 of 1

Auto-Walking

Posted: Thu Jun 25, 2020 6:52 pm
by thedarkcave215
SMBX 38A has auto-walking as a feature on the overworld map, which automatically makes mario walk along a path until he comes to a crossroad or a level. Does anyone know if I could replicate this with LunaLua?

Re: Auto-Walking

Posted: Thu Jun 25, 2020 8:26 pm
by Lusho
There's a library for that actually, so you just create a map.lua file in the episode folder and add this

Code: Select all

require("tweaks/travL")

Re: Auto-Walking

Posted: Fri Jun 26, 2020 6:39 am
by thedarkcave215
CJ_RLushi wrote:
Thu Jun 25, 2020 8:26 pm
There's a library for that actually, so you just create a map.lua file in the episode folder and add this

Code: Select all

require("tweaks/travL")
:D

Re: Auto-Walking

Posted: Thu Jul 09, 2020 10:47 am
by JamesR624
Okay, what gives? I cannot seem to have the player stop when reaching a level on the map. The player will just keep waking in that direction. I have a start point, some paths going right to the first level and the level object. The player just keeps going over and past the level forever despite there being no paths to the right of the level any further.
- I have made sure to enable the tweak properly in my lua file.
- I have tried making the "right exit" settings for the level object both "none" and "any".
No matter what I do, the player will not just stop on the level. Does anyone have a fix for this?

Re: Auto-Walking

Posted: Thu Jul 09, 2020 11:16 am
by Emral
Surprised that happens. You'll have to share your world map for that so people can have a look. In general, the code checks whenever the player stops walking to see if they arrived on a level or at an intersection, and if not, continues walking in the direction they didn't come from.

Re: Auto-Walking

Posted: Thu Jul 09, 2020 11:22 am
by thedarkcave215
JamesR624 wrote:
Thu Jul 09, 2020 10:47 am
Okay, what gives? I cannot seem to have the player stop when reaching a level on the map. The player will just keep waking in that direction. I have a start point, some paths going right to the first level and the level object. The player just keeps going over and past the level forever despite there being no paths to the right of the level any further.
- I have made sure to enable the tweak properly in my lua file.
- I have tried making the "right exit" settings for the level object both "none" and "any".
No matter what I do, the player will not just stop on the level. Does anyone have a fix for this?
Do any white arrows show up when you're stopped on the world map? They should appear to tell you where you can go next.

Re: Auto-Walking

Posted: Thu Jul 09, 2020 11:56 am
by JamesR624
thedarkcave215 wrote:
Thu Jul 09, 2020 11:22 am
JamesR624 wrote:
Thu Jul 09, 2020 10:47 am
Okay, what gives? I cannot seem to have the player stop when reaching a level on the map. The player will just keep waking in that direction. I have a start point, some paths going right to the first level and the level object. The player just keeps going over and past the level forever despite there being no paths to the right of the level any further.
- I have made sure to enable the tweak properly in my lua file.
- I have tried making the "right exit" settings for the level object both "none" and "any".
No matter what I do, the player will not just stop on the level. Does anyone have a fix for this?
Do any white arrows show up when you're stopped on the world map? They should appear to tell you where you can go next.
I know about those and turned those off. The issue isn't with the indicators. If I press right from my starting point, Mario will just keep walking on the path (as expected), reach the first level at the end of the path but not ever stop. He just keeps walking right over the level as if it were just another "right path" and keep going and going forever regardless of path, scenery, or level tiles.

Added in 13 minutes 42 seconds:
Enjl wrote:
Thu Jul 09, 2020 11:16 am
Surprised that happens. You'll have to share your world map for that so people can have a look. In general, the code checks whenever the player stops walking to see if they arrived on a level or at an intersection, and if not, continues walking in the direction they didn't come from.
What do you mean "checks whenever the player stops walking to see if they arrived on a level", you can't manually stop at all. Pressing a direction causes the player to just keep going right regardless of further input (which is expected) and regardless of if there's path, level, scenery, or tile objects. (unexpected). Is there something I am supposed to place to make the player stop auto-walking?

Re: Auto-Walking

Posted: Thu Jul 09, 2020 12:11 pm
by thedarkcave215
Can you post your world map/pastebin your map.lua file? You can use this website: https://pastebin.com/

Added in 1 minute 49 seconds:
JamesR624 wrote:Is there something I am supposed to place to make the player stop auto-walking?
Nope, it should just stop on its own.

Re: Auto-Walking

Posted: Thu Jul 09, 2020 12:17 pm
by JamesR624
Welp. I figured it out. It functions properly when adding

Code: Select all

require("tweaks/travL")
to the VERY BEGINNING of map.lua.

For anyone else who had the same issue, DO NOT add it into the

Code: Select all

-- Run code on first frame of the world map
function onStart()
    --Your code here
end
section. This will break it. Add it above all that at the VERY beginning of the file, similar to luna.lua.

Re: Auto-Walking

Posted: Thu Jul 09, 2020 12:22 pm
by thedarkcave215
JamesR624 wrote:
Thu Jul 09, 2020 12:17 pm
Welp. I figured it out. It functions properly when adding

Code: Select all

require("tweaks/travL")
to the VERY BEGINNING of map.lua.

For anyone else who had the same issue, DO NOT add it into the

Code: Select all

-- Run code on first frame of the world map
function onStart()
    --Your code here
end
section. This will break it. Add it above all that at the VERY beginning of the file, similar to luna.lua.
Ah, nice work figuring it out. I'm not very experienced with Lua so thanks for giving other users on this thread some advice! ;)

Re: Auto-Walking

Posted: Sun Jul 12, 2020 12:08 pm
by JamesR624
I am curious, is there any way to modify this code so that upon reaching a stopping point, the player always faces "down", AKA, frontwards, to better mimic the SMW style instead of just sitting in the direction last traveled?

Re: Auto-Walking

Posted: Sun Jul 12, 2020 12:10 pm
by Emral
You'll need to set world.playerCurrentDirection to 3 when the player stops moving I think.
https://wohlsoft.ru/pgewiki/World_%28class%29

Re: Auto-Walking

Posted: Sun Jul 12, 2020 12:47 pm
by thedarkcave215
Enjl wrote:
Sun Jul 12, 2020 12:10 pm
You'll need to set world.playerCurrentDirection to 3 when the player stops moving I think.
https://wohlsoft.ru/pgewiki/World_%28class%29
world.playerCurrentDirection is a read-only variable... I tried this for myself and no matter what I did I couldn't get it to work.

Re: Auto-Walking

Posted: Sun Jul 12, 2020 1:06 pm
by Emral
thedarkcave215 wrote:
Sun Jul 12, 2020 12:47 pm
Enjl wrote:
Sun Jul 12, 2020 12:10 pm
You'll need to set world.playerCurrentDirection to 3 when the player stops moving I think.
https://wohlsoft.ru/pgewiki/World_%28class%29
world.playerCurrentDirection is a read-only variable... I tried this for myself and no matter what I did I couldn't get it to work.
Ah... hm. In that case, that might be what stopped me from making a variable for it back in the day haha. Quickly asked Rednaxela about the matter and apparently that field is simply derived from the playerWalkingFrame variable, so if you set that to 0 or 1 you will get the desired effect. Try that.

Re: Auto-Walking

Posted: Sun Jul 12, 2020 1:24 pm
by thedarkcave215
Enjl wrote:
Sun Jul 12, 2020 1:06 pm
thedarkcave215 wrote:
Sun Jul 12, 2020 12:47 pm
Enjl wrote:
Sun Jul 12, 2020 12:10 pm
You'll need to set world.playerCurrentDirection to 3 when the player stops moving I think.
https://wohlsoft.ru/pgewiki/World_%28class%29
world.playerCurrentDirection is a read-only variable... I tried this for myself and no matter what I did I couldn't get it to work.
Ah... hm. In that case, that might be what stopped me from making a variable for it back in the day haha. Quickly asked Rednaxela about the matter and apparently that field is simply derived from the playerWalkingFrame variable, so if you set that to 0 or 1 you will get the desired effect. Try that.
Nope. That didn't change anything.

Re: Auto-Walking

Posted: Sun Jul 12, 2020 1:43 pm
by Emral
thedarkcave215 wrote:
Sun Jul 12, 2020 1:24 pm
Enjl wrote:
Sun Jul 12, 2020 1:06 pm
thedarkcave215 wrote:
Sun Jul 12, 2020 12:47 pm

world.playerCurrentDirection is a read-only variable... I tried this for myself and no matter what I did I couldn't get it to work.
Ah... hm. In that case, that might be what stopped me from making a variable for it back in the day haha. Quickly asked Rednaxela about the matter and apparently that field is simply derived from the playerWalkingFrame variable, so if you set that to 0 or 1 you will get the desired effect. Try that.
Nope. That didn't change anything.
You're probably trying to do it in onTick, in which case SMBX would override it before drawing. Try it at the end of onDraw, like this:
Image

Re: Auto-Walking

Posted: Tue Jul 14, 2020 8:28 am
by JamesR624
Enjl wrote:
Sun Jul 12, 2020 1:43 pm
thedarkcave215 wrote:
Sun Jul 12, 2020 1:24 pm
Enjl wrote:
Sun Jul 12, 2020 1:06 pm

Ah... hm. In that case, that might be what stopped me from making a variable for it back in the day haha. Quickly asked Rednaxela about the matter and apparently that field is simply derived from the playerWalkingFrame variable, so if you set that to 0 or 1 you will get the desired effect. Try that.
Nope. That didn't change anything.
You're probably trying to do it in onTick, in which case SMBX would override it before drawing. Try it at the end of onDraw, like this:
Image
Sorry for the other noob-ish question. Would I put this in my map.lua or edit travl.lua directly?

If I have to add it to map.lua, may I ask how to insert the onDraw function properly into map.lua so as not to break more things?

Re: Auto-Walking

Posted: Tue Jul 14, 2020 8:37 am
by Emral
Ah, mine was a modification to travl.lua. I forgot that you don't wanna edit it in basegame directly, sorry. Bit of a brainfart there.

In onDraw of your map.lua you can try, instead of isStanding, to check for world.playerWalkingDirection == 0. I think that should take care of it.
If it does not, you can copy travl.lua into your episode folder and edit it there. It's not as neat a solution, but at least it won't break basegame.