simpleLayerMovement.lua - For all your custom layer movement needs!

Share and discuss custom LunaLua code and content packs for SMBX2.
MrDoubleA
Flurry
Flurry
Posts: 385
Joined: Mon Aug 20, 2018 7:02 am
Flair: How much munchers?
Pronouns: he/him

simpleLayerMovement.lua - For all your custom layer movement needs!

Postby MrDoubleA » Wed Apr 01, 2020 3:11 pm

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".
Screenshot: show
Image
Loading & Examples: show
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)}}

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

Re: simpleLayerMovement.lua - For all your custom layer movement needs!

Postby Emral » Wed Apr 01, 2020 3:59 pm

This is really cool. Well done!

PROX
Banned
Posts: 1953
Joined: Sun Jul 06, 2014 8:50 pm

Re: simpleLayerMovement.lua - For all your custom layer movement needs!

Postby PROX » Mon Apr 06, 2020 6:52 am

Finally we won't have crazy jank moving layers. This will be very useful.

Nathan7934
Goomba
Goomba
Posts: 2
Joined: Tue Sep 20, 2022 11:46 pm
Pronouns: he/him

Re: simpleLayerMovement.lua - For all your custom layer movement needs!

Postby Nathan7934 » Sat Sep 24, 2022 1:47 am

Just wanted to say that I found this library very helpful. Thanks for making it!

Iggizorn
Shy Guy
Shy Guy
Posts: 8
Joined: Mon May 16, 2022 2:55 am
Pronouns: he/him

Re: simpleLayerMovement.lua - For all your custom layer movement needs!

Postby Iggizorn » 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

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

Re: simpleLayerMovement.lua - For all your custom layer movement needs!

Postby MrDoubleA » Mon Jan 02, 2023 5:55 pm

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).

Iggizorn
Shy Guy
Shy Guy
Posts: 8
Joined: Mon May 16, 2022 2:55 am
Pronouns: he/him

Re: simpleLayerMovement.lua - For all your custom layer movement needs!

Postby Iggizorn » 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?! :/

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

Re: simpleLayerMovement.lua - For all your custom layer movement needs!

Postby MrDoubleA » Tue Jan 03, 2023 10:35 am

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.

Cognition
Dolphin
Dolphin
Posts: 83
Joined: Sun Oct 05, 2014 10:13 pm

Re: simpleLayerMovement.lua - For all your custom layer movement needs!

Postby Cognition » 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?

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

Re: simpleLayerMovement.lua - For all your custom layer movement needs!

Postby MrDoubleA » Sun Apr 23, 2023 2:01 pm

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.

Just_Thomas
Snifit
Snifit
Posts: 224
Joined: Sat Dec 16, 2023 3:32 am
Pronouns: he/him

Re: simpleLayerMovement.lua - For all your custom layer movement needs!

Postby Just_Thomas » Sat Jan 27, 2024 1:17 pm

MrDoubleA wrote:
Wed Apr 01, 2020 3:11 pm
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.

Image
Image

Can you tell me what to do?


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari