Page 1 of 1
simpleLayerMovement.lua - For all your custom layer movement needs!
Posted: Wed Apr 01, 2020 3:11 pm
by MrDoubleA
This is a library which allows for you to simply create complex layer movement. You can
download it here! For examples and how to use, see "Loading & Examples".
To load it, simply put this in your luna.lua file:
Code: Select all
local slm = require("simpleLayerMovement")
Here are some examples:
Circular Movement
Code: Select all
slm.addLayer{name = "move 1",movement = slm.MOVEMENT_CIRCLE,speed = 64,verticalDistance = 1,horizontalDistance = 1.5}
slm.addLayer{name = "move 2",movement = slm.MOVEMENT_CIRCLE,speed = 32,distance = 0.5}
Looping Movement
Code: Select all
slm.addLayer{name = "move 1",verticalMovement = slm.MOVEMENT_LOOP,verticalSpeed = 2,verticalDistance = 320}
Cosine Wave Movement
Code: Select all
slm.addLayer{name = "move 1",speed = 96,horizontalMovement = slm.MOVEMENT_COSINE,horizontalSpeed = 64,horizontalDistance = 1}
Points Movements
Code: Select all
slm.addLayer{name = "move 1",movement = slm.MOVEMENT_POINTS,speed = 1,points = {vector(64,32),vector(96,96),vector(-96,96),vector(-64,32),vector(0,0)}}
slm.addLayer{name = "move 2",movement = slm.MOVEMENT_POINTS,speed = 3,points = {vector(48,-48),vector(96,0),vector(0,0)}}
Re: simpleLayerMovement.lua - For all your custom layer movement needs!
Posted: Wed Apr 01, 2020 3:59 pm
by Emral
This is really cool. Well done!
Re: simpleLayerMovement.lua - For all your custom layer movement needs!
Posted: Mon Apr 06, 2020 6:52 am
by PROX
Finally we won't have crazy jank moving layers. This will be very useful.
Re: simpleLayerMovement.lua - For all your custom layer movement needs!
Posted: Sat Sep 24, 2022 1:47 am
by Nathan7934
Just wanted to say that I found this library very helpful. Thanks for making it!
Re: simpleLayerMovement.lua - For all your custom layer movement needs!
Posted: Mon Jan 02, 2023 5:06 pm
by Iggizorn
I don't understand how to use the script =(. I wrote local slm = require("simpleLayerMovement") in my lua file from the level. Packed the lua file from the script in my level folder. I don't understand where and how I should now register my layer from the editor. Can someone explain that to me in a bit more detail
Re: simpleLayerMovement.lua - For all your custom layer movement needs!
Posted: Mon Jan 02, 2023 5:55 pm
by MrDoubleA
Iggizorn wrote: ↑Mon Jan 02, 2023 5:06 pm
I don't understand how to use the script =(. I wrote local slm = require("simpleLayerMovement") in my lua file from the level. Packed the lua file from the script in my level folder. I don't understand where and how I should now register my layer from the editor. Can someone explain that to me in a bit more detail
You cannot use it from the editor itself. You need to add some extra code to your luna.lua file (like what's shown in the "examples" part of the post).
Re: simpleLayerMovement.lua - For all your custom layer movement needs!
Posted: Mon Jan 02, 2023 7:21 pm
by Iggizorn
I know how to address layers from the lua file. I have read the code several times and do not understand where to place my layer. Is it possible to upload a small demo level where i can see how it works? maybe?! :/
Re: simpleLayerMovement.lua - For all your custom layer movement needs!
Posted: Tue Jan 03, 2023 10:35 am
by MrDoubleA
Iggizorn wrote: ↑Mon Jan 02, 2023 7:21 pm
I know how to address layers from the lua file. I have read the code several times and do not understand where to place my layer. Is it possible to upload a small demo level where i can see how it works? maybe?! :/
All you need to do to get started is copy and paste the examples into your luna.lua file, and change the names. If you are having trouble, you can send your current code to let me see what's wrong with it.
Re: simpleLayerMovement.lua - For all your custom layer movement needs!
Posted: Sat Apr 22, 2023 1:13 pm
by Cognition
The luna code is trying to find the layers in other levels that don't have these layers, creating an error. How do I isolate the code to just the one level if the examples are to be pasted in the global lua file?
Re: simpleLayerMovement.lua - For all your custom layer movement needs!
Posted: Sun Apr 23, 2023 2:01 pm
by MrDoubleA
Cognition wrote: ↑Sat Apr 22, 2023 1:13 pm
The luna code is trying to find the layers in other levels that don't have these layers, creating an error. How do I isolate the code to just the one level if the examples are to be pasted in the global lua file?
Don't put it in the global lua file, and use the level's lua file instead.
Re: simpleLayerMovement.lua - For all your custom layer movement needs!
Posted: Sat Jan 27, 2024 1:17 pm
by Just_Thomas
Really useful. LIke your example screenshot already shows, it is better than npc-106 (SMB1 elevator).
But how exactly did you create this "multiple elevators"-effect (no idea how to call it) without interruption?
(so from SMB 1-2 near the end of the level)
Code: Select all
slm.addLayer{name = "move 3",verticalMovement = slm.MOVEMENT_LOOP,verticalSpeed = 2,verticalDistance = 3500}
is only for one of them, if you copy one of these "block-units" with that layer and place if offset than the other "block-unit" will also move only 3500 units.
I could make a lot of copies but at some point all of them have went through and it would take some time, until it does repeat again.
Can you tell me what to do?
Re: simpleLayerMovement.lua - For all your custom layer movement needs!
Posted: Wed Sep 04, 2024 5:08 pm
by Alucard648
Is it possible for Poins layer movement to change speed between vectors, so we can have simple crushers like in this gif? Same question goes to looping vectors.

Damn janky vanilla layer movement.