pge projectsmw centralsmbx community

firefox related css updates (bbcode/shoutbox) - ctrl-f5 if they're still jacked up for you

LunaDLL/LunaLUA help thread

The second SMBX collab!
User avatar
Wohlstand
PGE and LunaLUA developer
Posts: 152
Joined: 3 years ago

Re: LunaDLL/LunaLUA help thread

Postby Wohlstand » 11 months ago

Holy wrote:Anything special I need to do when adjusting the music volume? I'm trying to do something kinda like this:

Code: Select all
function onLoad()
Audio.SeizeStream(-1)
end

function onLoadSection0()
Audio.MusicOpen("beep.ogg")
Audio.MusicPlay()
end

function onLoopSection1()
Audio.MusicVolume = (40 + player.speedY)
end

and I'm gettin nothin
Audio.MusicVolume is function, so, try this:

Code: Select all

Audio.MusicVolume(40 + player.speedY)
[/s] (Pyro already answered this question above)

Also hints:
  • Player's max fall speed is +12, but jump up is usually -6. I think, too small speed values for a volume manipulating (Volume range is 0 to 128), you would to multiple speed into 2 or another value to hear volume difference better.
  • Before send value to MusicVolume, you would to round it into integer:

    Code: Select all

    function round(num) 
            if num >= 0 then return math.floor(num+.5) 
            else return math.ceil(num-.5) end
    end
    
  • You also can don't seize music stream (if you want play a short looped sound effect, not a music or stream of long length, and you wanna keep background music and also play sound effect), you just can use chunks instead:

    Code: Select all

    -- Pointer to loaded audio chunk
    local myBeep = Audio.newMix_Chunk()
    -- A channel number where currently our audio chunk is playing (need to manipulate it!)
    local myBeep_chan = -2
    
    function onLoad()
    	myBeep = Audio.SfxOpen("beep.ogg");
    end
    
    -- Mute looped stream on enter into section 0
    function onLoadSection0()
    	if(myBeep_chan ~= -2) then
    		Audio.SfxStop(myBeep_chan)
    		myBeep_chan = -2
    	end
    end
    
    -- When entered into section 1, start loop (take a channel number to control this sound!)
    function onLoadSection1()
    	myBeep_chan = Audio.SfxPlayCh(-1, myBeep, -1)
    end
    
    function round(num) 
            if num >= 0 then return math.floor(num+.5) 
            else return math.ceil(num-.5) end
    end
    
    -- Manipulate with volume dependent to Y speed of player
    function onLoopSection1()
    	Audio.SfxVolume(myBeep_chan,  40 + round(player.speedY*2) )
    end
    
    

User avatar
7NameSam
hey
Posts: 207
Joined: 2 years ago
Pronouns: he/him/his

Re: LunaDLL/LunaLUA help thread

Postby 7NameSam » 11 months ago

I need help, I'm using ParalX and the sections (sections = {2}) argument straight up doesn't work, the paralax graphics I only want to show
in a section section only show up in section 1. am I using an outdated version of ParalX?

Code: Select all

local paralX = loadAPI("paralX");
local pnpc = loadSharedAPI("pnpc");
local multipoints = loadAPI("multipoints");

multipoints.addLuaCheckpoint(-190976, -200352, 0);

local clouds = Graphics.loadImage("cloud.png")
local clouds2 = Graphics.loadImage("cloud2.png")
local clouds3 = Graphics.loadImage("cloud3.png")
local clouds4 = Graphics.loadImage("cloud4.png")

local wrapcloud1 = Graphics.loadImage("wrapcloud1.png")
local wrapcloud2 = Graphics.loadImage("wrapcloud2.png")
local wrapcloud3 = Graphics.loadImage("wrapcloud3.png")
local wrapcloud4 = Graphics.loadImage("wrapcloud4.png")

function onStart ()
    cld3 = paralX.create ({image=clouds3, y=-128, priority=-96, speedX=0.9, repeatY=false, parallaxX=0.9, sections={2}, parallaxY=1})
    cld4 = paralX.create ({image=clouds4, y=-160, priority=-97, speedX=0.8, repeatY=false, parallaxX=0.8, sections={2}, parallaxY=1})
    cld2 = paralX.create ({image=clouds2, y=-96, priority=-2, speedX=1.1, repeatY=false, parallaxX=1.1, sections={2}, parallaxY=1})
    cld1 = paralX.create ({image=clouds, y=-64, priority=-1, speedX=1.2, repeatY=false, parallaxX=1.2, sections={2}, parallaxY=1})
Image

User avatar
Rockythechao
Shapemorph the titlecard into the video, Hoeloe
Posts: 422
Joined: 2 years ago
First name: Michael
Pronouns: he/him/his
Location: Yes

Re: LunaDLL/LunaLUA help thread

Postby Rockythechao » 11 months ago

Ah, sorry, I forgot to update the documentation. The former implementation wouldn't work no matter what I tried so in the latest version sections are based on index instead of value; as long as sections[2] is a non-nil value it'll work. iirc the proper syntax is {2:1}.

User avatar
Holy
Posts: 91
Joined: 5 years ago

Re: LunaDLL/LunaLUA help thread

Postby Holy » 11 months ago

Wohlstand wrote:stuff
Thanks for the help! Yeah, I had to fidget around with it before I got it like I wanted it.

User avatar
7NameSam
hey
Posts: 207
Joined: 2 years ago
Pronouns: he/him/his

Re: LunaDLL/LunaLUA help thread

Postby 7NameSam » 11 months ago

Rockythechao wrote:Ah, sorry, I forgot to update the documentation. The former implementation wouldn't work no matter what I tried so in the latest version sections are based on index instead of value; as long as sections[2] is a non-nil value it'll work. iirc the proper syntax is {2:1}.
I don't understand the explanation, how do I make the value of sections[2] non-nil?
Image

User avatar
Rockythechao
Shapemorph the titlecard into the video, Hoeloe
Posts: 422
Joined: 2 years ago
First name: Michael
Pronouns: he/him/his
Location: Yes

Re: LunaDLL/LunaLUA help thread

Postby Rockythechao » 11 months ago

Code: Select all

sections={2:1, 3:5, 4:99999}
Should make the layer appear in sections 2, 3 and 4. Undefined indexes in lua tables return nil, so as long as the index is assigned any value besides nil it'll count.

That said, it's clear now that index-based is relatively unintuitive and suddenly changing the argument's syntax long after it's been firmly established was a mistake on my part, documented or not. So I'm going to try to get value-based sections working for 1.3.3 along with a variable to toggle back to index-based.

User avatar
7NameSam
hey
Posts: 207
Joined: 2 years ago
Pronouns: he/him/his

Re: LunaDLL/LunaLUA help thread

Postby 7NameSam » 11 months ago

Rockythechao wrote:

Code: Select all

sections={2:1, 3:5, 4:99999}
Should make the layer appear in sections 2, 3 and 4. Undefined indexes in lua tables return nil, so as long as the index is assigned any value besides nil it'll count.

That said, it's clear now that index-based is relatively unintuitive and suddenly changing the argument's syntax long after it's been firmly established was a mistake on my part, documented or not. So I'm going to try to get value-based sections working for 1.3.3 along with a variable to toggle back to index-based.
will this method not work with version 1.1 of ParalX? if that's the case then I guess I'm straight out of luck then because the latest version straight up doesn't draw the foreground and background layers when I tried it with the latest version of the luna files on the A2XT onedrive.
Image

User avatar
Rockythechao
Shapemorph the titlecard into the video, Hoeloe
Posts: 422
Joined: 2 years ago
First name: Michael
Pronouns: he/him/his
Location: Yes

Re: LunaDLL/LunaLUA help thread

Postby Rockythechao » 11 months ago

The sections feature has been stubbornly broken up until 1.3.2; every time I thought I fixed it the blasted thing ended up still not working for someone.

Once the 1.3.3 update is ready I'll copy it over to onedrive. In the meantime, you can work around it by leaving the sections undefined and just setting the layer's visibility (LayerName.visible) based on the current section. Apologies for the trouble.

User avatar
7NameSam
hey
Posts: 207
Joined: 2 years ago
Pronouns: he/him/his

Re: LunaDLL/LunaLUA help thread

Postby 7NameSam » 11 months ago

Rockythechao wrote:The sections feature has been stubbornly broken up until 1.3.2; every time I thought I fixed it the blasted thing ended up still not working for someone.

Once the 1.3.3 update is ready I'll copy it over to onedrive. In the meantime, you can work around it by leaving the sections undefined and just setting the layer's visibility (LayerName.visible) based on the current section. Apologies for the trouble.
but the layers only show up in section 1?
Image

User avatar
Rockythechao
Shapemorph the titlecard into the video, Hoeloe
Posts: 422
Joined: 2 years ago
First name: Michael
Pronouns: he/him/his
Location: Yes

Re: LunaDLL/LunaLUA help thread

Postby Rockythechao » 11 months ago

So long story short, they're probably not showing up in 1.1 due to messed up positioning math. I'm doing what I can to fix everything but I can't say how long it'll take, and frustrating life circumstances are eating into the time I have to work on fixing it. As if that wasn't enough, I accidentally overwrote the live copy with the development copy so now the current version of paralX is broken, and I'm risking losing access to my computer by writing this post for reasons I can't get into now.

I'm terribly, terribly sorry for the trouble :(

User avatar
Holy
Posts: 91
Joined: 5 years ago

Re: LunaDLL/LunaLUA help thread

Postby Holy » 11 months ago

Yoyoyoyoyoyo, how do I send the player to a coordinate in another section? I can't figure it out.

User avatar
Karatekid5
Master of submarines
Posts: 32
Joined: 7 years ago
Location: Pennsylvania
Contact:

Re: LunaDLL/LunaLUA help thread

Postby Karatekid5 » 11 months ago

Is it possible to time LunaLUA code to the beat of background music? I had a small gimmick idea for a factory level that would have specific things activate at specific times in a song, similar to SMWCP2's Musical Mechanisms.
Yoshi Ambassador!
Image

User avatar
Wohlstand
PGE and LunaLUA developer
Posts: 152
Joined: 3 years ago

Re: LunaDLL/LunaLUA help thread

Postby Wohlstand » 11 months ago

Karatekid5 wrote:Is it possible to time LunaLUA code to the beat of background music? I had a small gimmick idea for a factory level that would have specific things activate at specific times in a song, similar to SMWCP2's Musical Mechanisms.
Function Audio.MusicClock() Returns the time starts from begin of the current music track playback (in seconds [double type, so, decimals allowed]). The time resets to 0 when music track was changed.

User avatar
WestonSmith
Bunny
Posts: 147
Joined: 3 years ago

Re: LunaDLL/LunaLUA help thread

Postby WestonSmith » 11 months ago

Just gonna ask some blanket questions:

(1) I know there is a blue shoe filter in A2XT Episode 2... but is there a code for filtering out all mounts at the start of a level?
(2) I know there's also a Raocoin tracker in Episode 2. However, it seems to be giving me hassle whenever I try to add it to my own code. Is there a wiki page on this (I can't seem to find one).

If anyone simply has links to the wiki page that answers these, I'd take them. I'm having trouble finding anything meaningful on them.

User avatar
Hoeloe
One of them Lua people
Posts: 806
Joined: 5 years ago
Location: Spaaace

Re: LunaDLL/LunaLUA help thread

Postby Hoeloe » 11 months ago

WestonSmith wrote: (2) I know there's also a Raocoin tracker in Episode 2. However, it seems to be giving me hassle whenever I try to add it to my own code. Is there a wiki page on this (I can't seem to find one).
The raocoin tracker is a custom built thing for Episode 2. It's a bit complex and relies on some very specific stuff.
Image
Image
Image
Image

User avatar
WestonSmith
Bunny
Posts: 147
Joined: 3 years ago

Re: LunaDLL/LunaLUA help thread

Postby WestonSmith » 11 months ago

Derns. Thanks all the same.

User avatar
Karatekid5
Master of submarines
Posts: 32
Joined: 7 years ago
Location: Pennsylvania
Contact:

Re: LunaDLL/LunaLUA help thread

Postby Karatekid5 » 10 months ago

Is it possible to slow down the frame speed of an animated background? I want the walls of the background to change colors, like at a party, but I want to do it without hurting people's eyes.
Yoshi Ambassador!
Image

User avatar
Ittababy
Posts: 7
Joined: 3 years ago

Re: LunaDLL/LunaLUA help thread

Postby Ittababy » 10 months ago

Is there or can there be a database of lunalua codes? Like maybe a section of one of the wiki's being where everyone logs in helpful things. I ask because I know that what I want is already solved somewhere, but I forget how to do it. (wind) Wouldn't it be nice if we could share all this stuff in a nice organized way? ...Or do we already do that? :?:
A very shy ghost.

S1eth
Posts: 285
Joined: 2 years ago

Re: LunaDLL/LunaLUA help thread

Postby S1eth » 9 months ago

I am having trouble with the Graphics.glDraw function and I believe that the function is bugged when using "sceneCoords = true".

Specifically, when I draw with sceneCoords, the image is drawn one pixel too far up, and one pixel too far left.

Test: I have an image with width = 96 and height = 32.
I want to draw this image in the top left corner of my screen.
These two functions should be identical?

Code: Select all

    --scene coords
    Graphics.glDraw{
      texture = testImg,
      vertexCoords = translate(vtxTest, Camera.get()[1].x+48, Camera.get()[1].y+16),
      textureCoords = texTest,
      sceneCoords = true,
      priority = -15.0
    };
    
    --screen coords
    Graphics.glDraw{
      texture = testImg,
      vertexCoords = translate(vtxTest, 48, 16),
      textureCoords = texTest,
      priority = -15.0
    };
The first function is off by one pixel along both the x and y axis.
I have to add +1 to x and y.

translate(vtxTest, Camera.get()[1].x+48+1, Camera.get()[1].y+16+1),

If I apply transformations such as rotation, or flipping horizonally/vertically, there are more problems.

Gifs of the tests:

normal
Image

rotate by 180°
Image

flip horizontally
Image
Image

User avatar
Leet
Well, hello, Smith ( ´-`)ノ
Posts: 1002
Joined: 4 years ago
First name: Chie Arale
Pronouns: she/her
Location: Harman's Room

Re: LunaDLL/LunaLUA help thread

Postby Leet » 7 months ago

installed lunalua on a vanilla smebex for the first time and for some reason the game keeps freezing up when entering or beating a level? :s not every time and sometimes the game comes back but
ImageWell it is a decent hack but sometime its just too repetitif there no level that actually pop in your face and your like oh yeah that level they all ressemble themselves and just monster along the way.
Blood Ghoul wrote:Sometimes it seems my blood spurts out in gobs, as if it were a fountain's pulsing sobs. I clearly hear it mutter as it goes yet cannot find the wound from which it flows. Before I met you, baby, I didn't know what I was missing.

User avatar
ztarwuff
What the heck is a flair and why am I being asked to write one for my profile?
Posts: 473
Joined: 3 years ago
Location: Within 2 miles of the Imperial Crypt of Napoleon III

Re: LunaDLL/LunaLUA help thread

Postby ztarwuff » 6 months ago

Does anybody know if there's a way of making all the enemies invincible? I'm trying to use NPC8 as one of those spike traps that shoot out of the floor like in the movies, except I don't want the player or shells to kill the npc.

Also, if there's a way to get NPC8 to ignore priority, that'd also be great, but for now I'd settle for invincible npc.


Return to “A2XT”

Who is online

Users browsing this forum: No registered users and 1 guest

cron