Share and discuss custom LunaLua code and content packs for SMBX2.
Moderator: Userbase Moderators
|
|
|
|
-
Davice
- Shy Guy

- Posts: 8
- Joined: Fri Oct 25, 2024 4:23 pm
- Pronouns: he/him
Postby Davice » Wed Apr 16, 2025 6:51 pm
NSMB Camera UPDATE 1.1
An alternative camera logic which mimics the camera behavior of New Super Mario Bros / Super Mario Maker.
That means the camera is not staticly fixed to the player, instead the camera smoothly follows the player.
This script is about 90% compatible with customCamera.lua (zoom blocks and camera blockers are tested, using boundaries and custom screen sizes can cause problems) and with warpTransition.lua
While using warpTransition.lua you have to paste the following code line at line 464 because my script automatically makes inner section transitions, otherwise there would be conclifcts and bugs.
Code: Select all warpTransition.sameSectionTransition = warpTransition.TRANSITION_NONE
How to import in your level:
When you want to import the script into your whole episode place the script file in your episode folder, open your episode luna.lua and paste the following code line:
Code: Select all local nsmbCamera = require("nsmbCamera")
When you want to import the script into a specific level without influencing other levels in your episode place the script file into your level folder, open your level luna.lua (if there is none just create one) and paste also the same code lineas for using in your whole episode.
Settings
If you want to deactive the level start zooming feature or the whole script for a specific level or inside a function you can use one or both of the following code lines as an example (do not forget to import the script first in your script file):
Downlaod:
https://workupload.com/file/NAUhW6FFARm
Last edited by Davice on Mon Jun 09, 2025 2:42 pm, edited 4 times in total.
|
|
|
|
|
|
|
|
|
-
mariobrigade2018
- Rocky Wrench

- Posts: 673
- Joined: Wed May 24, 2023 7:00 pm
- Flair: OK in coding who dreams of making a Mario game
- Pronouns: he/him
Postby mariobrigade2018 » Wed Apr 16, 2025 6:56 pm
Neat, although there is a better way to add comparability to warpTransitions without manual editing for the player. I’ll see if I can make an in depth explanation on it soon.
|
|
|
|
|
|
|
|
|
-
dulushich_ViiU
- Koopa

- Posts: 16
- Joined: Sun Aug 27, 2023 8:08 am
- Pronouns: them
Postby dulushich_ViiU » Wed Apr 16, 2025 8:54 pm
I liked that the camera was moving so steeply.
But I definitely didn't expect that, please fix it.
|
|
|
|
|
|
|
|
|
-
Maximum
- Fighter Fly

- Posts: 38
- Joined: Fri Sep 20, 2024 1:38 am
- Flair: Everyone has a purpose in life.
- Pronouns: he/him
Postby Maximum » Wed Apr 16, 2025 9:15 pm
dulushich_ViiU wrote: ↑Wed Apr 16, 2025 8:54 pm
I liked that the camera was moving so steeply.
But I definitely didn't expect that, please fix it.
I have that same problem too.
|
|
|
|
|
|
|
|
|
-
Davice
- Shy Guy

- Posts: 8
- Joined: Fri Oct 25, 2024 4:23 pm
- Pronouns: he/him
Postby Davice » Wed Apr 16, 2025 9:40 pm
dulushich_ViiU wrote: ↑Wed Apr 16, 2025 8:54 pm
I liked that the camera was moving so steeply.
But I definitely didn't expect that, please fix it.
what the hell? i tried to find as much errors as possible but i have never seen that. can you describe when this happens so i can fix it better?
|
|
|
|
|
|
|
|
|
-
RimeNTreason
- Goomba

- Posts: 2
- Joined: Wed Apr 16, 2025 9:42 pm
Postby RimeNTreason » Wed Apr 16, 2025 9:47 pm
happened to me as well. just sorta ignores the level's walls. i personally added this to make it work:
Code: Select all local sec = Section(player.section)
targetX = math.max(sec.boundary.left + (camera.width / 2) / cam.zoom, math.min(sec.boundary.right - (camera.width / 2) / cam.zoom, targetX))
targetY = math.max(sec.boundary.top + (camera.height / 2) / cam.zoom, math.min(sec.boundary.bottom - (camera.height / 2) / cam.zoom, targetY))
put that under:
Code: Select all targetY = math.max(playerY - yMargin, math.min(playerY + yMargin, targetY))
this does NOT fix the zoom at level start still zooming out of bounds, but idk what to do about that rn so i just disabled it on my end.
|
|
|
|
|
|
|
|
|
-
Davice
- Shy Guy

- Posts: 8
- Joined: Fri Oct 25, 2024 4:23 pm
- Pronouns: he/him
Postby Davice » Wed Apr 16, 2025 9:49 pm
Maximum wrote: ↑Wed Apr 16, 2025 9:15 pm
dulushich_ViiU wrote: ↑Wed Apr 16, 2025 8:54 pm
I liked that the camera was moving so steeply.
But I definitely didn't expect that, please fix it.
I have that same problem too.
do you use a custom resolution? thats one of the few things i never tested
|
|
|
|
|
|
|
|
|
-
dulushich_ViiU
- Koopa

- Posts: 16
- Joined: Sun Aug 27, 2023 8:08 am
- Pronouns: them
Postby dulushich_ViiU » Wed Apr 16, 2025 11:05 pm
Davice wrote: ↑Wed Apr 16, 2025 9:49 pm
Maximum wrote: ↑Wed Apr 16, 2025 9:15 pm
dulushich_ViiU wrote: ↑Wed Apr 16, 2025 8:54 pm
I liked that the camera was moving so steeply.
But I definitely didn't expect that, please fix it.
I have that same problem too.
do you use a custom resolution? thats one of the few things i never tested
In short, it happens when you go to the edge of the map and you see blackness.
as for me, your resolutions are strange, the screens are all so stretched that it doesn't bother your eyes
|
|
|
|
|
|
|
|
|
-
Maximum
- Fighter Fly

- Posts: 38
- Joined: Fri Sep 20, 2024 1:38 am
- Flair: Everyone has a purpose in life.
- Pronouns: he/him
Postby Maximum » Thu Apr 17, 2025 2:21 am
RimeNTreason wrote: ↑Wed Apr 16, 2025 9:47 pm
happened to me as well. just sorta ignores the level's walls. i personally added this to make it work:
Code: Select all local sec = Section(player.section)
targetX = math.max(sec.boundary.left + (camera.width / 2) / cam.zoom, math.min(sec.boundary.right - (camera.width / 2) / cam.zoom, targetX))
targetY = math.max(sec.boundary.top + (camera.height / 2) / cam.zoom, math.min(sec.boundary.bottom - (camera.height / 2) / cam.zoom, targetY))
put that under:
Code: Select all targetY = math.max(playerY - yMargin, math.min(playerY + yMargin, targetY))
this does NOT fix the zoom at level start still zooming out of bounds, but idk what to do about that rn so i just disabled it on my end.
I tried your code, and it still doesn't work properly.
Last edited by Maximum on Wed May 14, 2025 3:47 pm, edited 1 time in total.
|
|
|
|
|
|
|
|
|
-
Doodoxing
- Swooper

- Posts: 70
- Joined: Wed Feb 05, 2014 12:09 pm
- Pronouns: he/him
Postby Doodoxing » Thu Apr 17, 2025 9:32 am
Not working for me either. I put this additional code in proper place in lua file. It helped a bit, but have not fixed it entirely.
Don't mind WarpTransition. It has nothing to do with it. Problem is happening even without it.
|
|
|
|
|
|
|
|
|
-
ilovehamburgerz
- 2025 Egg Hunter

- Posts: 470
- Joined: Thu Jul 25, 2024 5:34 am
- Flair: i have 0 dollars
- Pronouns: he/him
Postby ilovehamburgerz » Thu Apr 17, 2025 11:20 am
I hate to say this, but this is obsolete as this already exists.
And besides, why go yourself the hassle of making one thing when that thing is litteraly already done by another guy? i dont get it
|
|
|
|
|
|
|
|
|
-
KurttheKing
- Tweeter

- Posts: 142
- Joined: Tue Mar 15, 2022 4:55 pm
- Flair: Certified Nerd
- Pronouns: He/Him
-
Contact:
Postby KurttheKing » Thu Apr 17, 2025 11:33 am
Retro wrote: ↑Thu Apr 17, 2025 11:20 am
I hate to say this, but this is obsolete as this already exists.
And besides, why go yourself the hassle of making one thing when that thing is litteraly already done by another guy? i dont get it
Uh, customCamera works through multiple sizeables across your entire level, this is essentially plug-and-play as it requires no in-editor setup. Also, it's meant to work in unison with customCamera, though you may have not seen that
|
|
|
|
|
|
|
|
|
-
dulushich_ViiU
- Koopa

- Posts: 16
- Joined: Sun Aug 27, 2023 8:08 am
- Pronouns: them
Postby dulushich_ViiU » Thu Apr 17, 2025 10:10 pm
Doodoxing wrote: ↑Thu Apr 17, 2025 9:32 am
Not working for me either. I put this additional code in proper place in lua file. It helped a bit, but have not fixed it entirely.
Don't mind WarpTransition. It has nothing to do with it. Problem is happening even without it.
How did you do 16:9
|
|
|
|
|
|
|
|
|
-
Doodoxing
- Swooper

- Posts: 70
- Joined: Wed Feb 05, 2014 12:09 pm
- Pronouns: he/him
Postby Doodoxing » Fri Apr 18, 2025 12:42 am
It's a basic stuff about setting mainbuffersize. It's a well known piece of code.
I think that it is actually the custom resolution to cause that problem.
|
|
|
|
|
|
|
|
|
-
dulushich_ViiU
- Koopa

- Posts: 16
- Joined: Sun Aug 27, 2023 8:08 am
- Pronouns: them
Postby dulushich_ViiU » Fri Apr 18, 2025 3:58 am
Doodoxing wrote: ↑Fri Apr 18, 2025 12:42 am
It's a basic stuff about setting mainbuffersize. It's a well known piece of code.
I think that it is actually the custom resolution to cause that problem.
Not well, where to make or download it ?
|
|
|
|
|
|
|
|
|
-
Doodoxing
- Swooper

- Posts: 70
- Joined: Wed Feb 05, 2014 12:09 pm
- Pronouns: he/him
Postby Doodoxing » Fri Apr 18, 2025 4:44 am
Put this into luna.lua:
Code: Select all function onStart()
Graphics.setMainFramebufferSize(960,540)
end
function onCameraUpdate()
camera.width,camera.height = Graphics.getMainFramebufferSize()
end
|
|
|
|
|
|
|
|
|
-
dulushich_ViiU
- Koopa

- Posts: 16
- Joined: Sun Aug 27, 2023 8:08 am
- Pronouns: them
Postby dulushich_ViiU » Fri Apr 18, 2025 5:51 am
Doodoxing wrote: ↑Fri Apr 18, 2025 4:44 am
Put this into luna.lua:
Code: Select all function onStart()
Graphics.setMainFramebufferSize(960,540)
end
function onCameraUpdate()
camera.width,camera.height = Graphics.getMainFramebufferSize()
end
Thanks
|
|
|
|
|
|
|
|
|
-
RimeNTreason
- Goomba

- Posts: 2
- Joined: Wed Apr 16, 2025 9:42 pm
Postby RimeNTreason » Fri Apr 18, 2025 8:19 am
Doodoxing wrote: ↑Fri Apr 18, 2025 4:44 am
Put this into luna.lua:
Code: Select all function onStart()
Graphics.setMainFramebufferSize(960,540)
end
function onCameraUpdate()
camera.width,camera.height = Graphics.getMainFramebufferSize()
end
this does not fix it for me. ill stick with my solution for now.
|
|
|
|
|
Return to “LunaLua”
Users browsing this forum: Rodriv64 and 3 guests
|