camLock.lua - Camera zones for your levels and maps

This is the place for discussion and support for LunaLua and related modifications and libraries.

Moderator: Userbase Moderators

Forum rules
Before you make a topic/post, consider the following:
-Is there a topic for this already?
-Is your post on topic/appropriate?
-Are you posting in the right forum/following the forum rules?
Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9887
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

camLock.lua - Camera zones for your levels and maps

Postby Emral » Tue Jan 09, 2018 3:03 pm

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!
Last edited by Emral on Tue Jan 09, 2018 3:12 pm, edited 1 time in total.

The0x539
Eerie
Eerie
Posts: 751
Joined: Fri Jan 22, 2016 8:02 pm

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

Postby The0x539 » Tue Jan 09, 2018 3:05 pm

gif pls

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9887
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

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

Postby Emral » Tue Jan 09, 2018 3:12 pm

Whoops I knew I forgot something. Added to OP.

Hoeloe
Phanto
Phanto
Posts: 1465
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

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

Postby Hoeloe » Tue Jan 09, 2018 4:11 pm

How does this handle multiple overlapping zones?

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9887
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

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

Postby Emral » Tue Jan 09, 2018 5:06 pm

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.

squp
Snifit
Snifit
Posts: 211
Joined: Sat Aug 12, 2017 10:10 pm
Flair: worm
Pronouns: she/it
Contact:

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

Postby squp » Wed Jan 10, 2018 3:43 pm

Enjl wrote:the main post
Yes yes YEESSSS, thank you!!! This will really help!

MECHDRAGON777
Pink Yoshi Egg
Pink Yoshi Egg
Posts: 6422
Joined: Fri Dec 20, 2013 6:40 pm
Flair: Nuclear Queen of Reversion.
Contact:

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

Postby MECHDRAGON777 » Wed Jan 31, 2018 2:18 pm

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.

erkyp3rky
Ninji
Ninji
Posts: 934
Joined: Fri Apr 15, 2016 1:41 am
Flair: formerly theloaflord

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

Postby erkyp3rky » Wed Jan 31, 2018 4:07 pm

Enjl you legend.

MECHDRAGON777
Pink Yoshi Egg
Pink Yoshi Egg
Posts: 6422
Joined: Fri Dec 20, 2013 6:40 pm
Flair: Nuclear Queen of Reversion.
Contact:

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

Postby MECHDRAGON777 » Fri Feb 02, 2018 12:07 am

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

squp
Snifit
Snifit
Posts: 211
Joined: Sat Aug 12, 2017 10:10 pm
Flair: worm
Pronouns: she/it
Contact:

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

Postby squp » Sat Apr 21, 2018 4:27 pm

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)

Crafty_Potatoes
Goomba
Goomba
Posts: 1
Joined: Sun Jul 15, 2018 3:01 pm

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

Postby Crafty_Potatoes » Mon Jul 16, 2018 10:55 am

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.


Return to “LunaLua”

Who is online

Users browsing this forum: Semrush [Bot] and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari