sinelayers.lua - Smooth infinite layer movement

Share and discuss custom LunaLua code and content packs for SMBX2.
Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9491
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Orphion Egamalenitar Osmos IV, Esq.

sinelayers.lua - Smooth infinite layer movement

Postby Enjl » Mon Aug 22, 2022 8:30 am

Image

This script lets you define layers that move according to a sine wave without having to write lua or configure events.
It's a product of my own laziness and uses the layer name as the definition for the wave motion.
To use this script, load it in your luna.lua and name your layers according to the specification.

local sinelayers = require("sinelayers")

https://pastebin.com/0ZKuBXJa


-- Examples:
-- sinea8f1x10y10d8 -- Y-Sway amplitude of 8 (* 8), frequency of 1 (second), x-movement of 10 (blocks right), y-movement of 10 blocks (down), over the course of 8 (seconds)
-- sinea0f1x-3y-8d1 -- No sway. Move 3 blocks left and 8 blocks up within one second.

-- Explanation:
-- The layer gets 2 sine motions applied. A constant y-sway, and a separate x/y movement motion. The former is controlled by a, f. The latter by x, y, d
-- sinea <- identifier
-- a[num] <- amplitude of the constant y-swaying motion, in quarter-blocks (pixels * 8)
-- f[num] <- frequency of the constant y-swaying motion, in seconds
-- x[num] <- horizontal distance travelled during movement motion, in blocks (pixels * 32)
-- y[num] <- vertical distance travelled during movement motion, in blocks (pixels * 32)
-- d[num] <- frequency (duration) of the movement motion, in seconds

Alagirez
Boom Boom
Boom Boom
Posts: 3370
Joined: Tue Dec 02, 2014 2:28 am
Flair: Show your fangs!
Pronouns: He/Him/That wolf
Contact:

Re: sinelayers.lua - Smooth infinite layer movement

Postby Alagirez » Mon Aug 22, 2022 11:37 pm

So, do I have to name a specific layer such as "sinea8f1x10y10d8" to make the lib work? ...or write it in the luna file?
I did both of them but no results, probably it's just me not knowing much about luna stuff.

...Apparently I have to write the confirugation code as a layer name.
Great stuff anyways.

Edit: The libarary didn't load because the lib name was "sinelayers.lua.lua".

MrDoubleA
Flurry
Flurry
Posts: 351
Joined: Mon Aug 20, 2018 7:02 am
Flair: How much munchers?
Pronouns: he/him

Re: sinelayers.lua - Smooth infinite layer movement

Postby MrDoubleA » Tue Aug 23, 2022 8:55 pm

Great stuff, and really convenient! Do kinda wish there was spaces between properties (since they're very odd to read as-is) though that's only a simple edit. Also, the parsing could probably be a string.match pattern.

Mal8rk
Tweeter
Tweeter
Posts: 154
Joined: Mon Oct 25, 2021 11:04 pm
Flair: I like socializing with people online
Pronouns: He/Him
Contact:

Re: sinelayers.lua - Smooth infinite layer movement

Postby Mal8rk » Fri Oct 07, 2022 4:46 pm

Hey, so I have found a problem, where if you hide a layer with the name of the configuration code (sinea0f1x127y0d140), it will still keep moving like normal, even though it's supposed to stay still


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 1 guest