extraBGOProperties.lua (v1.1) - Fancy BGOs

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

extraBGOProperties.lua (v1.1) - Fancy BGOs

Postby MrDoubleA » Tue Feb 14, 2023 1:33 pm

This is a library that allows you to control more about how a BGO looks via extra settings. It supports movement, rotation, opacity/colour tinting, scaling, parallax and even shaders. It's also multiplayer/split screen compatible.

Image
Image

How to use: show
Installation

To install, place the files from the zip folder into your level/episode folder. Then, add the following line to your luna.lua file:

Code: Select all

local extraBGOProperties = require("extraBGOProperties")
There should now be settings on the right side of the screen when selecting a BGO.

Movement

In the settings box, there is an option labeled "movement". This works similarly to the Graf NPC's patterns. You can set the following values: x, y, scaleX, scaleY, rotation, opacity and color. Examples on how to use these are below the option. Note that "t" is the number of seconds since the level started, x and y are measured in blocks, rotation is measured in degrees and opacity should be between 0 and 1.

Default Settings

Via code in a luna.lua file or elsewhere, you can specify default settings for each BGO ID. For example, after loading in the library:

Code: Select all

extraBGOProperties.registerID(1,{
    movementFunc = function(v,t)
        local data = extraBGOProperties.getData(v)

        data.offsetY = math.sin(t*4)
    end,

    scaleX = 2,
    scaleY = 2,
})
The first number is the BGO ID, and the rest of the values are settings. The valid settings to enter are offsetX, offsetY, scaleX, scaleY, rotation, opacity, parallaxX, parallaxY, pivotX, pivotY and finally, movementFunc. The movement function works similarly to the movement box, except you must change things via the BGO's data table.

Download!

georgespezi12
Dolphin
Dolphin
Posts: 99
Joined: Mon Jun 01, 2020 3:45 am

Re: extraBGOProperties.lua - Fancy BGOs

Postby georgespezi12 » Tue Feb 14, 2023 2:32 pm

handy for localized parallax

georgespezi12
Dolphin
Dolphin
Posts: 99
Joined: Mon Jun 01, 2020 3:45 am

Re: extraBGOProperties.lua - Fancy BGOs

Postby georgespezi12 » Wed Feb 15, 2023 12:48 pm

parallax functionality does not work properly with large, connected BGOs.

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

Re: extraBGOProperties.lua - Fancy BGOs

Postby MrDoubleA » Wed Feb 15, 2023 4:38 pm

georgespezi12 wrote:
Wed Feb 15, 2023 12:48 pm
parallax functionality does not work properly with large, connected BGOs.
It does, it's just that the parallax is centred on the BGO, not on the section bounds. So, you need to space them out a bit.

ChunkyChimp
Spiny
Spiny
Posts: 26
Joined: Tue Sep 01, 2020 9:02 pm
Flair: I TAKE GFX FOR MY OWN LEVELS

Re: extraBGOProperties.lua - Fancy BGOs

Postby ChunkyChimp » Wed Feb 15, 2023 10:59 pm

this is amazing

FutureNyanCat
Rocky Wrench
Rocky Wrench
Posts: 696
Joined: Fri Dec 20, 2013 8:39 pm
Flair: Species: Felis robotus
Pronouns: He/Him
Contact:

Re: extraBGOProperties.lua - Fancy BGOs

Postby FutureNyanCat » Mon Feb 20, 2023 4:15 am

I'm just honestly intrigued at the squishy BGO in the GIF tbh.

sonic_de_hedhog
Shy Guy
Shy Guy
Posts: 7
Joined: Fri Jan 20, 2023 7:37 am
Pronouns: he/him

Re: extraBGOProperties.lua - Fancy BGOs

Postby sonic_de_hedhog » Mon Feb 20, 2023 6:29 am

how do i use this

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

Re: extraBGOProperties.lua - Fancy BGOs

Postby MrDoubleA » Mon Feb 20, 2023 5:35 pm

sonic_de_hedhog wrote:
Mon Feb 20, 2023 6:29 am
how do i use this
Full usage instructions are included in the post.

sonic_de_hedhog
Shy Guy
Shy Guy
Posts: 7
Joined: Fri Jan 20, 2023 7:37 am
Pronouns: he/him

Re: extraBGOProperties.lua - Fancy BGOs

Postby sonic_de_hedhog » Tue Feb 21, 2023 12:59 pm

can you show the codes used for the example gif

IttaBaby
Swooper
Swooper
Posts: 53
Joined: Sat Apr 08, 2017 8:19 pm

Re: extraBGOProperties.lua - Fancy BGOs

Postby IttaBaby » Wed Feb 22, 2023 10:53 pm

Spinning, swaying and shifting I understand
but how do I make that wobbly hill?

TheGameyFireBro105
Eerie
Eerie
Posts: 743
Joined: Thu Jan 09, 2020 6:09 pm
Flair: Good at remakes
Pronouns: he/him

Re: extraBGOProperties.lua - Fancy BGOs

Postby TheGameyFireBro105 » Thu Feb 23, 2023 6:41 pm

MrDoubleA wrote:
Tue Feb 14, 2023 1:33 pm
Spoiler: show
This is a library that allows you to control more about how a BGO looks via extra settings. It supports movement, rotation, opacity, scaling and parallax. It's also multiplayer/split screen compatible.

Image
Image

How to use: show
Installation

To install, place the files from the zip folder into your level/episode folder. Then, add the following line to your luna.lua file:

Code: Select all

local extraBGOProperties = require("extraBGOProperties")
There should now be settings on the right side of the screen when selecting a BGO.

Movement

In the settings box, there is an option labeled "movement". This works similarly to the Graf NPC's patterns. You can set the following values: x, y, scaleX, scaleY, rotation, and opacity. Examples on how to use these are below the option. Note that "t" is the number of seconds since the level started, x and y are measured in blocks, rotation is measured in degrees and opacity should be between 0 and 1.

Default Settings

Via code in a luna.lua file or elsewhere, you can specify default settings for each BGO ID. For example, after loading in the library:

Code: Select all

extraBGOProperties.registerID(1,{
    movementFunc = function(v,t)
        local data = extraBGOProperties.getData(v)

        data.offsetY = math.sin(t*4)
    end,

    scaleX = 2,
    scaleY = 2,
})
The first number is the BGO ID, and the rest of the values are settings. The valid settings to enter are offsetX, offsetY, scaleX, scaleY, rotation, opacity, parallaxX, parallaxY, pivotX, pivotY and finally, movementFunc. The movement function works similarly to the movement box, except you must change things via the BGO's data table.

Download!
What's the code for the bouncing bush/hill thing?
Last edited by ElectriKong on Fri Feb 24, 2023 11:17 am, edited 1 time in total.
Reason: Spoilered long quote

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

Re: extraBGOProperties.lua - Fancy BGOs

Postby MrDoubleA » Fri Feb 24, 2023 2:59 pm

TheGameyFireBro105 wrote:
Thu Feb 23, 2023 6:41 pm
What's the code for the bouncing bush/hill thing?
IttaBaby wrote:
Wed Feb 22, 2023 10:53 pm
Spinning, swaying and shifting I understand
but how do I make that wobbly hill?
This is its movement code:

Code: Select all

local stretch = sin(t*8)

scaleX = 1 + stretch*0.1
scaleY = 1 - stretch*0.075

Mal8rk
Snifit
Snifit
Posts: 200
Joined: Mon Oct 25, 2021 11:04 pm
Flair: English Speaking Spanish Speaker
Pronouns: He/Him
Contact:

Re: extraBGOProperties.lua - Fancy BGOs

Postby Mal8rk » Tue Jun 20, 2023 11:22 am

This script is great and all, however if hide a moving bgo in a layer, the bgo will still move like normal even though it is hidden.

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

Re: extraBGOProperties.lua (v1.1) - Fancy BGOs

Postby MrDoubleA » Thu Apr 04, 2024 6:57 pm

Updated this library to include some extra features: colour changing (allowing you to tint a BGO) and shader support. Note that shaders and their uniforms are only supported per-ID rather than per-BGO, and therefore must be set up through Lua code. A function can be set to change their uniforms once per frame, per camera.

Sample for setting up a shader:

Code: Select all

extraBGOProperties.registerID(1,{
    getUniformsFunc = function(id,camIdx)
        return {
            time = lunatime.tick(),
        }
    end,
    fragShader = "wavy.frag",
})

MarioChallengerX2
Dolphin
Dolphin
Posts: 81
Joined: Sat Dec 31, 2022 4:34 pm
Pronouns: he/him

Re: extraBGOProperties.lua (v1.1) - Fancy BGOs

Postby MarioChallengerX2 » Thu Apr 04, 2024 10:05 pm

MrDoubleA wrote:
Thu Apr 04, 2024 6:57 pm
Updated this library to include some extra features: colour changing (allowing you to tint a BGO) and shader support. Note that shaders and their uniforms are only supported per-ID rather than per-BGO, and therefore must be set up through Lua code. A function can be set to change their uniforms once per frame, per camera.

Sample for setting up a shader:

Code: Select all

extraBGOProperties.registerID(1,{
    getUniformsFunc = function(id,camIdx)
        return {
            time = lunatime.tick(),
        }
    end,
    fragShader = "wavy.frag",
})
Is tinting a BGO required in lua too? I thought it was just the shader!


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 2 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari