Page 1 of 1
extraBGOProperties.lua (v1.1) - Fancy BGOs
Posted: Tue Feb 14, 2023 1:33 pm
by MrDoubleA
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.
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!
Re: extraBGOProperties.lua - Fancy BGOs
Posted: Tue Feb 14, 2023 2:32 pm
by georgespezi12
handy for localized parallax
Re: extraBGOProperties.lua - Fancy BGOs
Posted: Wed Feb 15, 2023 12:48 pm
by georgespezi12
parallax functionality does not work properly with large, connected BGOs.
Re: extraBGOProperties.lua - Fancy BGOs
Posted: Wed Feb 15, 2023 4:38 pm
by MrDoubleA
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.
Re: extraBGOProperties.lua - Fancy BGOs
Posted: Wed Feb 15, 2023 10:59 pm
by ChunkyChimp
this is amazing
Re: extraBGOProperties.lua - Fancy BGOs
Posted: Mon Feb 20, 2023 4:15 am
by FutureNyanCat
I'm just honestly intrigued at the squishy BGO in the GIF tbh.
Re: extraBGOProperties.lua - Fancy BGOs
Posted: Mon Feb 20, 2023 6:29 am
by sonic_de_hedhog
how do i use this
Re: extraBGOProperties.lua - Fancy BGOs
Posted: Mon Feb 20, 2023 5:35 pm
by MrDoubleA
Full usage instructions are included in the post.
Re: extraBGOProperties.lua - Fancy BGOs
Posted: Tue Feb 21, 2023 12:59 pm
by sonic_de_hedhog
can you show the codes used for the example gif
Re: extraBGOProperties.lua - Fancy BGOs
Posted: Wed Feb 22, 2023 10:53 pm
by IttaBaby
Spinning, swaying and shifting I understand
but how do I make that wobbly hill?
Re: extraBGOProperties.lua - Fancy BGOs
Posted: Thu Feb 23, 2023 6:41 pm
by TheGameyFireBro105
MrDoubleA wrote: ↑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, scaling and parallax. It's also multiplayer/split screen compatible.
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?
Re: extraBGOProperties.lua - Fancy BGOs
Posted: Fri Feb 24, 2023 2:59 pm
by MrDoubleA
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
Re: extraBGOProperties.lua - Fancy BGOs
Posted: Tue Jun 20, 2023 11:22 am
by Mal8rk
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.
Re: extraBGOProperties.lua (v1.1) - Fancy BGOs
Posted: Thu Apr 04, 2024 6:57 pm
by MrDoubleA
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",
})
Re: extraBGOProperties.lua (v1.1) - Fancy BGOs
Posted: Thu Apr 04, 2024 10:05 pm
by MarioChallengerX2
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!