Page 1 of 1

customCamera.lua (v1.0.1) - Actual Camera Control Stuff

Posted: Sun Mar 20, 2022 6:48 pm
by MrDoubleA
Hey! Made this over a few days. Adds two sizeables (called controllers and blockers) that let you control the camera/screen itself, including targetting NPC's, zooming in/out, and cropping the screen. Its controls are also available as options in the library itself if you don't want to use the controllers.

(As mentioned in the controller extra settings, certain things like NPC's with custom rendering won't work properly with zooming out. If you want to fix this, you can use some of the "register draw" functions mentioned near the top of the lua file, but I may add more compatibility for NPC's over time.)

Screenshots: show
(Note: these sizeables are invisible in-game and are only shown here for demonstration/testing.)
Image
Image
Image
Image

Note about Handycam: show
This library should be partially compatible with handycam.lua, but if you have some zoom with it by default and want to use this library, you should change code like this:

Code: Select all

local handycam = require("handycam")

handycam[1].zoom = 1.5
To:

Code: Select all

local customCamera = require("customCamera")

customCamera.defaultZoom = 1.5

Download!

Re: customCamera.lua - Actual Camera Control Stuff

Posted: Sun Mar 20, 2022 7:34 pm
by FutureNyanCat
Ayo it's finally out. I might get around to using this for cutscenes with the layer-event system.

Re: customCamera.lua - Actual Camera Control Stuff

Posted: Sun Mar 20, 2022 9:35 pm
by Mal8rk
This is hella awesome!

but an example level would be a nice touch

Re: customCamera.lua - Actual Camera Control Stuff

Posted: Sun Mar 20, 2022 11:54 pm
by AirShip
Awesome work MrDoubleA, one more must-necessary lua for my collection, good job!

Re: customCamera.lua - Actual Camera Control Stuff

Posted: Mon Mar 21, 2022 2:08 am
by LooKiCH
I hope there is no bug with item box

Re: customCamera.lua - Actual Camera Control Stuff

Posted: Mon Mar 21, 2022 11:26 am
by Master of Disaster
I noticed some small things with this pack:
First, the controller areas have a bottom collision. Thus it isn't possible to jump into a camera control area from below
Second, the reserve item Box doesn't release its content at the right spot when camera offset (X and/or Y) is active. Although this doesn't have to be changed as it is a minor gripe that doesn't affect gameplay in a bad way.
The bottom collision though should get adressed though.

Really liking this system so far, it gives the builder much more agency and works extremely fluently, good job!

Re: customCamera.lua (v1.0.1) - Actual Camera Control Stuff

Posted: Tue Mar 22, 2022 5:29 pm
by MrDoubleA
Small update. Change log:
- The camera will now be properly reset after going through a pipe to the same section that you're already in.
- For drawScene (i.e., zooming out), fixed sizeable rendering.
- For drawScene, BGO's will no longer render while hidden.
- For drawScene, added special support for the launch barrel NPC's.

Also, not a change, but I just want to point out that customCamera.drawScene can just be used outside of any actual camera stuff, if you find that useful for your own code.

Re: customCamera.lua (v1.0.1) - Actual Camera Control Stuff

Posted: Fri Jun 10, 2022 10:09 am
by JamesR624
This is really awesome!
however, I did notice that this doesn't seem to have any support for player 2.

I sadly have noticed that nearly ALL scripts on this site like shaders or camera functions, never seem to take into account 2 players. How come? It's a core mechanic of the game.

Re: customCamera.lua (v1.0.1) - Actual Camera Control Stuff

Posted: Fri Jun 10, 2022 10:28 am
by deice
JamesR624 wrote:
Fri Jun 10, 2022 10:09 am
I sadly have noticed that nearly ALL scripts on this site like shaders or camera functions, never seem to take into account 2 players. How come? It's a core mechanic of the game.
there's probably a lot of things that contribute to this, but to name a few:

- scripts that account for more than one player are harder to code and much harder to test
- a lot of recent episodes don't allow for two players (iirc even the default launcher template has two player mode disabled) so scripts that people make for their episodes and then publish are less likely to do so, and there's less of a target audience
- very very few people use two player mode, so even if the script is meant to work with two players, it's unlikely that someone will notice when it doesn't

there's probably other things too, but these are the first few that come to mind.

Re: customCamera.lua (v1.0.1) - Actual Camera Control Stuff

Posted: Fri Jun 10, 2022 10:54 am
by JamesR624
Ahh, thank you for the clarifaction.

Well, I'll admit that 2 player co-op does also make it harder to make levels that account for all that.

I realize that this may be slightly off topic but I have been searching and cannot seem to find this. I was curious if there was a way to have the character switch between Mario & Luigi upon death? I was hoping to make a '2-player mode', that is just swapping out the two players each death instead of co-op. This would make level making easier but also make it so all shaders and scripts can work fine without needing to take into account the co-op, as you said.

My first place to look was the scripting for the player blocks and just have that trigger upon death but I cannot seem to find a way to do that so I was just curious if I am missing something.

Re: customCamera.lua (v1.0.1) - Actual Camera Control Stuff

Posted: Fri Jun 10, 2022 12:36 pm
by deice
JamesR624 wrote:
Fri Jun 10, 2022 10:54 am
I realize that this may be slightly off topic but I have been searching and cannot seem to find this. I was curious if there was a way to have the character switch between Mario & Luigi upon death?
i've sent you a pm so as to avoid clogging the thread up with off-topic discussion.

Re: customCamera.lua (v1.0.1) - Actual Camera Control Stuff

Posted: Fri Nov 11, 2022 2:14 am
by FutureNyanCat
Finally convinced myself to use this to showcase some setups in case they go off-screen. Very useful camera controls!

Re: customCamera.lua (v1.0.1) - Actual Camera Control Stuff

Posted: Wed Jan 11, 2023 6:54 pm
by Pixelated_Perfection
I know this is a bit late but I recently found that using darkness and lighting combined with this script has a funny little result.
(Ignore how blocky everything looks zoomed out thats from retroResolution)
Image

Im not sure what to do about this but maybe thats something to look into for future updates to the script?

Re: customCamera.lua (v1.0.1) - Actual Camera Control Stuff

Posted: Sun Jan 29, 2023 12:59 pm
by MrDoubleA
Pixelated_Perfection wrote:
Wed Jan 11, 2023 6:54 pm
I know this is a bit late but I recently found that using darkness and lighting combined with this script has a funny little result.
(Ignore how blocky everything looks zoomed out thats from retroResolution)
Image

Im not sure what to do about this but maybe thats something to look into for future updates to the script?
This unfortunately isn't really fixable (or would be harder to fix than it's worth). Zooming out requires re-rendering the level, which excludes any darkness.

Re: customCamera.lua (v1.0.1) - Actual Camera Control Stuff

Posted: Sun Jan 29, 2023 2:11 pm
by Pixelated_Perfection
MrDoubleA wrote:
Sun Jan 29, 2023 12:59 pm
Pixelated_Perfection wrote:
Wed Jan 11, 2023 6:54 pm
I know this is a bit late but I recently found that using darkness and lighting combined with this script has a funny little result.
(Ignore how blocky everything looks zoomed out thats from retroResolution)
Image

Im not sure what to do about this but maybe thats something to look into for future updates to the script?
This unfortunately isn't really fixable (or would be harder to fix than it's worth). Zooming out requires re-rendering the level, which excludes any darkness.
ah, makes sense, well i had to ask, thanks for the response!

Re: customCamera.lua (v1.0.1) - Actual Camera Control Stuff

Posted: Wed May 08, 2024 5:37 am
by Just_Thomas
MrDoubleA wrote:
Sun Mar 20, 2022 6:48 pm
block-998.lua: 15: attempt to call field 'setBlockSettings' (a table value)

What am I doing wrong here, I tested around and I just don`t get it.

Edit: This simply sucks.
There is definitely something in this little bit of code here that causes this problem. So, as like in case of the The error message seemed somehow familiar to me.
If you exclude the commented lines, it is not that much.

Code: Select all

Defines.player_grabSideEnabled = false
Defines.player_grabTopEnabled = false
Defines.player_grabShellEnabled = false

--https://www.smbxgame.com/forums/viewtopic.php?t=29121
--True SMB1 Playables (Version 2.0 - LUIGI UPDATE)
--by: Nate-O
function onStart()
	Player.setCostume(CHARACTER_MARIO, "SMB1-Mario")
	Player.setCostume(CHARACTER_LUIGI, "SMB1-Luigi")
end

function onTick()
    	player.keys.dropItem = false
    	player.keys.altJump = false

--Code by deIce
--https://www.smbxgame.com/forums/posting.php?mode=quote&p=399575
--NPC always moves right after spawning
	for _, v in NPC.iterate() do
		if(v:mem(0x138, FIELD_WORD) == 1 and v:mem(0x13C, FIELD_DFLOAT) == 0) then
		v.direction = DIR_RIGHT
		end
	end
end

--https://www.smbxgame.com/forums/viewtopic.php?p=399480
--heartsForAll (v3.1.0.5) - Applies Heart System to Box Users
--by: AppleTheTomato
local pc = require("heartsForAll")

--https://www.smbxgame.com/forums/viewtopic.php?t=26835
--[NPC Pack / Library] Extended Koopas (v1.1.1) - More and more accurate koopas!
--by: MrDoubleA
local extendedKoopas = require("extendedKoopas")

--https://www.smbxgame.com/forums/viewtopic.php?t=28655
--Auto-loading next level after winning • levellist.lua
--by: LooKiCH
-- in {} paste the filenames of your levels in ascending order
-- BOTH MAP.LUA AND LUNA.LUA MUST HAVE THE SAME LEVEL LIST VALUE!
--require("levellist").levels = {"template_normalLevel.lvlx","template_underground.lvlx","template_normalLevel2.lvlx"}

--https://www.smbxgame.com/forums/viewtopic.php?t=25750
--warpTransition.lua (v1.1.3) - Spruce up your warps!
--by: MrDoubleA			
local warpTransition = require("warpTransition")
warpTransition.levelStartTransition = warpTransition.TRANSITION_MOSAIC

--https://www.smbxgame.com/forums/viewtopic.php?p=399891#p390017
--Re: warpTransition.lua (v1.1.3) - Spruce up your warps!
--by: Marioman2007

Master of Disaster wrote:
Mon May 06, 2024 1:49 pm
Just_Thomas wrote:
Sun May 05, 2024 11:03 am
PS: By the way, I have this ugly bug here.

Image

This bug happens if I already copy the files into my main project folder. They just have to be there to cause the bug, not even used or anything.
The really strange thing about that is, in the "safe area" (I sometimes test them seperate for several reasons) it does NOT happen at all.
I hope your block doesn't interfere with anything else.
Huh, what is your block-906? And also, it would also probably help to find out which npc/block of the pack specifically causes the issues.
Because tbh I have no idea what part of my npcs/roulette block is so menacing that it kills other custom blocks by it's sole existence

Re: customCamera.lua (v1.0.1) - Actual Camera Control Stuff

Posted: Thu May 09, 2024 12:58 am
by Marioman2007
That error is caused by the warp transition modifier.
In the block's lua file, change "blockManager.setBlockSettings = ({" to "blockManager.setBlockSettings({"

Re: customCamera.lua (v1.0.1) - Actual Camera Control Stuff

Posted: Thu May 09, 2024 3:50 am
by Just_Thomas
Marioman2007 wrote:
Thu May 09, 2024 12:58 am
That error is caused by the warp transition modifier.
In the block's lua file, change "blockManager.setBlockSettings = ({" to "blockManager.setBlockSettings({"
Great, while I had somehow suspected this “block” as the culprit in the meantime, I never ever would have thought of just removing an equal sign.
Thank you for that. I am glad I can leave this useful block of yours in my project. :)

Added in 5 hours 47 minutes 57 seconds:
MrDoubleA wrote:
Sun Mar 20, 2022 6:48 pm
Image
Image
Image
The camera blocker has default settings and does not seem to work from below.
It might the roughly the same what Master of Disaster already mentioned.
Also is there something I can do to prevent the "default settings reset" when the player dies/falls in a pit?

Alternative:
https://ibb.co/vdSTs3T
https://ibb.co/HHzjgm9