Post here for help and support regarding LunaLua and SMBX2's libraries and features.
Moderator: Userbase Moderators
|
|
|
|
-
thedarkcave215
- Buster Beetle

- Posts: 81
- Joined: Tue Jun 09, 2020 2:30 pm
- Flair: Bubbly drinks are best served cold.
Postby thedarkcave215 » Thu Jun 25, 2020 6:52 pm
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?
|
|
|
|
|
|
|
|
|
-
Lusho
- Blooper

- Posts: 163
- Joined: Wed Dec 25, 2019 11:39 pm
- Flair: Intention is what matters
- Pronouns: he/him
Postby Lusho » 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
|
|
|
|
|
|
|
|
|
-
thedarkcave215
- Buster Beetle

- Posts: 81
- Joined: Tue Jun 09, 2020 2:30 pm
- Flair: Bubbly drinks are best served cold.
Postby thedarkcave215 » Fri Jun 26, 2020 6:39 am
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

|
|
|
|
|
|
|
|
|
-
JamesR624
- Spiny

- Posts: 29
- Joined: Wed Aug 09, 2017 4:24 pm
Postby JamesR624 » 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?
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » 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.
|
|
|
|
|
|
|
|
|
-
thedarkcave215
- Buster Beetle

- Posts: 81
- Joined: Tue Jun 09, 2020 2:30 pm
- Flair: Bubbly drinks are best served cold.
Postby thedarkcave215 » 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.
|
|
|
|
|
|
|
|
|
-
JamesR624
- Spiny

- Posts: 29
- Joined: Wed Aug 09, 2017 4:24 pm
Postby JamesR624 » Thu Jul 09, 2020 11:56 am
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?
|
|
|
|
|
|
|
|
|
-
thedarkcave215
- Buster Beetle

- Posts: 81
- Joined: Tue Jun 09, 2020 2:30 pm
- Flair: Bubbly drinks are best served cold.
Postby thedarkcave215 » Thu Jul 09, 2020 12:11 pm
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.
|
|
|
|
|
|
|
|
|
-
JamesR624
- Spiny

- Posts: 29
- Joined: Wed Aug 09, 2017 4:24 pm
Postby JamesR624 » Thu Jul 09, 2020 12:17 pm
Welp. I figured it out. It functions properly when adding
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.
|
|
|
|
|
|
|
|
|
-
thedarkcave215
- Buster Beetle

- Posts: 81
- Joined: Tue Jun 09, 2020 2:30 pm
- Flair: Bubbly drinks are best served cold.
Postby thedarkcave215 » Thu Jul 09, 2020 12:22 pm
JamesR624 wrote: ↑Thu Jul 09, 2020 12:17 pm
Welp. I figured it out. It functions properly when adding
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! 
|
|
|
|
|
|
|
|
|
-
JamesR624
- Spiny

- Posts: 29
- Joined: Wed Aug 09, 2017 4:24 pm
Postby JamesR624 » Sun Jul 12, 2020 12:08 pm
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?
|
|
|
|
|
|
|
|
|
-
thedarkcave215
- Buster Beetle

- Posts: 81
- Joined: Tue Jun 09, 2020 2:30 pm
- Flair: Bubbly drinks are best served cold.
Postby thedarkcave215 » 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.
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » 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.
|
|
|
|
|
|
|
|
|
-
thedarkcave215
- Buster Beetle

- Posts: 81
- Joined: Tue Jun 09, 2020 2:30 pm
- Flair: Bubbly drinks are best served cold.
Postby thedarkcave215 » 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.
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » 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
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:

|
|
|
|
|
|
|
|
|
-
JamesR624
- Spiny

- Posts: 29
- Joined: Wed Aug 09, 2017 4:24 pm
Postby JamesR624 » Tue Jul 14, 2020 8:28 am
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:
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?
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Tue Jul 14, 2020 8:37 am
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.
|
|
|
|
|
Return to “LunaLua Help”
Users browsing this forum: No registered users and 0 guests
|