Page 1 of 1

sinelayers.lua - Smooth infinite layer movement

Posted: Mon Aug 22, 2022 8:30 am
by Emral
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

Re: sinelayers.lua - Smooth infinite layer movement

Posted: Mon Aug 22, 2022 11:37 pm
by Alagirez
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".

Re: sinelayers.lua - Smooth infinite layer movement

Posted: Tue Aug 23, 2022 8:55 pm
by MrDoubleA
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.

Re: sinelayers.lua - Smooth infinite layer movement

Posted: Fri Oct 07, 2022 4:46 pm
by Mal8rk
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

Re: sinelayers.lua - Smooth infinite layer movement

Posted: Tue Nov 28, 2023 10:15 pm
by HAK0TA538
I see this doesent seem to work well with npcs? That or theres an option im not filling

Re: sinelayers.lua - Smooth infinite layer movement

Posted: Sun Dec 10, 2023 12:39 pm
by MrDoubleA
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.