Page 1 of 1

camLock.lua - Camera zones for your levels and maps

Posted: Tue Jan 09, 2018 3:03 pm
by Emral
Download

Doing camera zones was always just a feature which took a small number of lines to do. It's rather simple, but why not make it more simple?
Sadly, I'm unable to make it as simple as "select areas in the editor" yet, but one line of lua per zone should do for now.
This script works in levels and on the world map. You can use it on the map to have arbitrarily sized boundaries for individual worlds.
Here's how you use it:

Put the file into your level or episode folder and then type the following into your lunadll.lua or lunaoverworld.lua file:

Code: Select all

local camLock = API.load("camLock")
camLock.addZone(x,y,width,height,speed)
x: The x-coordinate of the top left corner of the zone.
y: The y-coordinate of the top left corner of the zone.
width: how wide your zone should be
height: how tall your zone should be
speed: how quickly the camera should snap into the zone. 0 means it won't react to the zone, while 1 means that it will snap instantly. Any value in between is a gradual move towards the zone. Default is 0.05.

Bear in mind that this library doesn't care about section boundaries, so if you don't want the camera to go below a section, be careful with your zones.

Image

Have fun!

Re: camLock.lua - Camera zones for your levels and maps

Posted: Tue Jan 09, 2018 3:05 pm
by The0x539
gif pls

Re: camLock.lua - Camera zones for your levels and maps

Posted: Tue Jan 09, 2018 3:12 pm
by Emral
Whoops I knew I forgot something. Added to OP.

Re: camLock.lua - Camera zones for your levels and maps

Posted: Tue Jan 09, 2018 4:11 pm
by Hoeloe
How does this handle multiple overlapping zones?

Re: camLock.lua - Camera zones for your levels and maps

Posted: Tue Jan 09, 2018 5:06 pm
by Emral
Hoeloe wrote:How does this handle multiple overlapping zones?
Currently no support for overlapping ones. Just fixed a bug with adjacent ones, though. They should work as intended now. I tried to do some shenanigans with overlapping ones but I think I'd need to rewrite the entire thing for that. Might do that if we want to have this for plugins in the future, but for simple world map borders and "rooms" levels this should work nicely.

Re: camLock.lua - Camera zones for your levels and maps

Posted: Wed Jan 10, 2018 3:43 pm
by squp
Enjl wrote:the main post
Yes yes YEESSSS, thank you!!! This will really help!

Re: camLock.lua - Camera zones for your levels and maps

Posted: Wed Jan 31, 2018 2:18 pm
by MECHDRAGON777
This is a big help for metroidvanias. I think I asked for this about half a year ago, hahaha. Thanks a ton. (This makes Metrovania's require way less sections and way less warps.)

Edit: Knew how to do this with the world map, never thought it would be this easy for levels to, that is my bad for thinking outside of the box only instead of both in and out.

Re: camLock.lua - Camera zones for your levels and maps

Posted: Wed Jan 31, 2018 4:07 pm
by erkyp3rky
Enjl you legend.

Re: camLock.lua - Camera zones for your levels and maps

Posted: Fri Feb 02, 2018 12:07 am
by MECHDRAGON777
I just wonder if at some point it will be possible to do zones that are screen sizes of three on the top, and two on the bottom. An example of what I mean (albeit different measurements) would be this:
Image

Re: camLock.lua - Camera zones for your levels and maps

Posted: Sat Apr 21, 2018 4:27 pm
by squp
Hey, uh
On the worldmap, when I try to use it, it just has a white screen.
Image

Code: Select all

local camLock = API.load("camLock")

camLock.addZone(-1632,-608,1600,1200,0.05)

camLock.addZone(32,64,800,600,0.05)

Re: camLock.lua - Camera zones for your levels and maps

Posted: Mon Jul 16, 2018 10:55 am
by Crafty_Potatoes
FlatKiwi wrote:
Sat Apr 21, 2018 4:27 pm
Hey, uh
On the worldmap, when I try to use it, it just has a white screen.
I noticed that it appears whenever X is less than 800 and Y is less than 576.
The more left and up the zone starts, the bigger the white box.
Probably just a bug in the code.