sinelayers.lua - Smooth infinite layer movement

Share and discuss custom LunaLua code and content packs for SMBX2.

Moderator: Userbase Moderators

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

sinelayers.lua - Smooth infinite layer movement

Postby Emral » 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
Ludwig von Koopa
Ludwig von Koopa
Posts: 3584
Joined: Tue Dec 02, 2014 2:28 am
Flair: Legalize Awooo!
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
Ripper II
Ripper II
Posts: 394
Joined: Mon Aug 20, 2018 7:02 am
Flair: How much munchers?

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
Snifit
Snifit
Posts: 216
Joined: Mon Oct 25, 2021 11:04 pm
Flair: English Speaking Spanish Speaker
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

HAK0TA538
Bob-Omb
Bob-Omb
Posts: 22
Joined: Wed Oct 18, 2023 11:57 pm
Flair: Lua is cool
Pronouns: He/Him

Re: sinelayers.lua - Smooth infinite layer movement

Postby HAK0TA538 » Tue Nov 28, 2023 10:15 pm

I see this doesent seem to work well with npcs? That or theres an option im not filling

MrDoubleA
Ripper II
Ripper II
Posts: 394
Joined: Mon Aug 20, 2018 7:02 am
Flair: How much munchers?

Re: sinelayers.lua - Smooth infinite layer movement

Postby MrDoubleA » Sun Dec 10, 2023 12:39 pm

HAK0TA538 wrote:
Tue Nov 28, 2023 10:15 pm
I see this doesent seem to work well with npcs? That or theres an option im not filling
What NPCs are you trying it with? Most NPCs do not move with layers.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 2 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari