(shouting)

LunaDLL/LunaLUA help thread

The second SMBX collab!
S1eth
Posts: 291
Joined: 9 years ago

Re: LunaDLL/LunaLUA help thread

Post by S1eth »

7NameSam wrote:
Hoeloe wrote:
7NameSam wrote:I'm unsure what I'm doing wrong?
Do I not have the latest version of colliders?

Code: Select all

local colliders = loadAPI("colliders");
 
function onLoop()
	if (colliders.collideBlock(player,1)) then
		player.speedY = -10
	end
end
What's happening that's wrong? This should push the player up when they touch a block with ID 1.
Nothing happens if I touch the block,
This code only does anything if you are inside the block rather than touching the block, for example if you use block id 447 (cloud, go through from below)
Image
User avatar
7NameSam
hey
Posts: 248
Joined: 9 years ago
Pronouns: they/them

Re: LunaDLL/LunaLUA help thread

Post by 7NameSam »

S1eth wrote: This code only does anything if you are inside the block rather than touching the block, for example if you use block id 447 (cloud, go through from below)
Oh, okay. is there any good way to check if you are touching a not-cloud block?
cramps-man
Posts: 14
Joined: 9 years ago

Re: LunaDLL/LunaLUA help thread

Post by cramps-man »

If you cbf trying to figure out how to get colliders to work, then just use the block collidesWith method.

Code: Select all

function onLoop()
	for key, b in pairs(Block.get(1)) do
		if (b:collidesWith(player) ~= 0) then
			Text.print("FUCK", 0, 0)
			break
		end
	end
end
You can see what collidesWith() returns here
http://wohlsoft.ru/pgewiki/Block_%28class%29

Checking ~= 0 checks all 4 sides of the block for collision.
User avatar
HenryRichard
Not a licensed doctor or nurse.
Posts: 31
Joined: 8 years ago
Location: ok

Re: LunaDLL/LunaLUA help thread

Post by HenryRichard »

I can't seem to get paralX.lua to work. I'm using the demo level it comes with and the latest dev build of lua, and it doesn't do anything unless I add sections = {0} to the arguments list, and then I get this error:
Capture.PNG
Capture.PNG (12.83 KiB) Viewed 7792 times
What am I doing wrong?
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: LunaDLL/LunaLUA help thread

Post by Rednaxela »

HenryRichard wrote:What am I doing wrong?
On a hunch... could you post the "function paralX.onCameraUpdate" line, from your paralX.lua in the version of paralX.lua that you're using?

I have a hunch you're on an out of date version, with a very specific bug.
User avatar
HenryRichard
Not a licensed doctor or nurse.
Posts: 31
Joined: 8 years ago
Location: ok

Re: LunaDLL/LunaLUA help thread

Post by HenryRichard »

Rednaxela wrote:
HenryRichard wrote:What am I doing wrong?
On a hunch... could you post the "function paralX.onCameraUpdate" line, from your paralX.lua in the version of paralX.lua that you're using?

I have a hunch you're on an out of date version, with a very specific bug.

Code: Select all

function paralX.onCameraUpdate (eventObj, cameraIndex)
	updateCameraSections (cameraIndex)
	currentCamera = cameraIndex
	for k,v in pairs(indexedParallaxes) do
		v:draw (cameraIndex)
	end
end
I don't think that eventObj should be there...
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: LunaDLL/LunaLUA help thread

Post by Rednaxela »

HenryRichard wrote:I don't think that eventObj should be there...
No, that needs to be there.

Hmm... not sure what's... uhless... you're on an out of date version of lunadll without thinking you are. Other than that, something for Rocky to look into.
User avatar
7NameSam
hey
Posts: 248
Joined: 9 years ago
Pronouns: they/them

Re: LunaDLL/LunaLUA help thread

Post by 7NameSam »

I'm not sure where to put this, so I'm putting this here:

I downloaded the newest version of the A2XT base game off of the onedrive, and the raocow player character has some weird offset issues
Attachments
WONTWORK3.gif
WONTWORK3.gif (199.24 KiB) Viewed 7712 times
User avatar
ztarwuff
What the heck is a flair and why am I being asked to write one for my profile?
Posts: 550
Joined: 10 years ago
Location: Within 2 miles of the Imperial Crypt of Napoleon III

Re: LunaDLL/LunaLUA help thread

Post by ztarwuff »

7NameSam wrote:I'm not sure where to put this, so I'm putting this here:

I downloaded the newest version of the A2XT base game off of the onedrive, and the raocow player character has some weird offset issues
It's the ini files that maintain's raocow's sprite hitbox. They're located in the Episode 2 folder, which means you need to download at least the ini files from the Episode 2 folder off OneDrive.
SAJewers wrote:*ping*
What was the reason the ini files couldn't be in the top level folder again?
User avatar
Wohlstand
Moondust and TheXTech developer
Posts: 186
Joined: 10 years ago
First name: Vitaly
Pronouns: he/him/his
Location: Moscow, Russia

Re: LunaDLL/LunaLUA help thread

Post by Wohlstand »

7NameSam wrote:I'm not sure where to put this, so I'm putting this here:

I downloaded the newest version of the A2XT base game off of the onedrive, and the raocow player character has some weird offset issues
So, that needed to add into lunaworld a loading of right INI-calibrations (even store Talkhaus specific lua libraries which are will work automatically)
User avatar
SAJewers
ASMBXT Level Wrangler/A2XT Project Coordinator /AAT Level Designer
Posts: 4200
Joined: 11 years ago
Location: Nova Scotia

Re: LunaDLL/LunaLUA help thread

Post by SAJewers »

ztarwuff wrote:
7NameSam wrote:I'm not sure where to put this, so I'm putting this here:

I downloaded the newest version of the A2XT base game off of the onedrive, and the raocow player character has some weird offset issues
It's the ini files that maintain's raocow's sprite hitbox. They're located in the Episode 2 folder, which means you need to download at least the ini files from the Episode 2 folder off OneDrive.
SAJewers wrote:*ping*
What was the reason the ini files couldn't be in the top level folder again?
because they're programmed like npc-xx.txt files where you need to place them in the episode folder, but then also require lunaworld.txt.

Honestly we should probably just re-do those sheets so we don't require those ini files, or create some global lua thing so that we can put them in the top level folder.
ImageImageImageImageImage | Image | Image
Sharenite | RetroAchievements | NameMC | IGDB
User avatar
Wohlstand
Moondust and TheXTech developer
Posts: 186
Joined: 10 years ago
First name: Vitaly
Pronouns: he/him/his
Location: Moscow, Russia

Re: LunaDLL/LunaLUA help thread

Post by Wohlstand »

SAJewers wrote:
ztarwuff wrote:
7NameSam wrote:I'm not sure where to put this, so I'm putting this here:

I downloaded the newest version of the A2XT base game off of the onedrive, and the raocow player character has some weird offset issues
It's the ini files that maintain's raocow's sprite hitbox. They're located in the Episode 2 folder, which means you need to download at least the ini files from the Episode 2 folder off OneDrive.
SAJewers wrote:*ping*
What was the reason the ini files couldn't be in the top level folder again?
because they're programmed like npc-xx.txt files where you need to place them in the episode folder, but then also require lunaworld.txt.

Honestly we should probably just re-do those sheets so we don't require those ini files, or create some global lua thing so that we can put them in the top level folder.
I mean playable character calibration file (which includes offsets and metrics of playable character)
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: LunaDLL/LunaLUA help thread

Post by Rednaxela »

SAJewers wrote:just re-do those sheets so we don't require those ini files
This is not really doable without changing large parts of the fundamental design of those sprites. Not only would the default hitbox size be odd with it, but many frames have significant features that rely on being able to draw above and left of the hitbox to a degree that is simply not possible with the default offset values.
SAJewers wrote:or create some global lua thing so that we can put them in the top level folder.
This however is very easy/doable.
User avatar
SAJewers
ASMBXT Level Wrangler/A2XT Project Coordinator /AAT Level Designer
Posts: 4200
Joined: 11 years ago
Location: Nova Scotia

Re: LunaDLL/LunaLUA help thread

Post by SAJewers »

Rednaxela wrote:
SAJewers wrote:or create some global lua thing so that we can put them in the top level folder.
This however is very easy/doable.
If you could make that work with the npc-xx.txt files, that would be great too. That way I also won't have to deal with people having moonwalking furbas and whatnot.
ImageImageImageImageImage | Image | Image
Sharenite | RetroAchievements | NameMC | IGDB
User avatar
Wohlstand
Moondust and TheXTech developer
Posts: 186
Joined: 10 years ago
First name: Vitaly
Pronouns: he/him/his
Location: Moscow, Russia

Re: LunaDLL/LunaLUA help thread

Post by Wohlstand »

SAJewers wrote:
SAJewers wrote:or create some global lua thing so that we can put them in the top level folder.
This however is very easy/doable.
If you could make that work with the npc-xx.txt files, that would be great too. That way I also won't have to deal with people having moonwalking furbas and whatnot.[/quote]
Anyway, a good idea to add support of GLOBAL npc.txts which are will declare default set, and I think, I'll add the automatical loading of playable calibrations INI files too and current way via lua will be used to customize them in real time. What about global NPC.txt's to re-declare global properties, I'll tell that to others
User avatar
SAJewers
ASMBXT Level Wrangler/A2XT Project Coordinator /AAT Level Designer
Posts: 4200
Joined: 11 years ago
Location: Nova Scotia

Re: LunaDLL/LunaLUA help thread

Post by SAJewers »

I'd still add a lunaglobal.lua file or whatever, since the code we we'll have in lunaworld.lua will be re-used in future episodes and backported to Ep1 and PTTS anyway, so you'd be eliminating redundancy a bit.
ImageImageImageImageImage | Image | Image
Sharenite | RetroAchievements | NameMC | IGDB
User avatar
Wohlstand
Moondust and TheXTech developer
Posts: 186
Joined: 10 years ago
First name: Vitaly
Pronouns: he/him/his
Location: Moscow, Russia

Re: LunaDLL/LunaLUA help thread

Post by Wohlstand »

SAJewers wrote:I'd still add a lunaglobal.lua file or whatever, since the code we we'll have in lunaworld.lua will be re-used in future episodes and backported to Ep1 and PTTS anyway, so you'd be eliminating redundancy a bit.
Anyway, I'll make calibrations for raocow now and I'll put them into onedrive, so, will be possible to use them
User avatar
7NameSam
hey
Posts: 248
Joined: 9 years ago
Pronouns: they/them

Re: LunaDLL/LunaLUA help thread

Post by 7NameSam »

I need help,
The data class "bums" is always 1 when I load the level

Code: Select all

local encrypt = API.load("encrypt")
local myData = encrypt.Data(Data.DATA_LEVEL, true)

if myData:get("bums") == nil then
	myData:set("bums",0)
	myData:save()
end

function onLoad()
	if myData:get("bums") == 1 and player.powerup == PLAYER_SMALL then
		player.powerup = PLAYER_BIG
	end
end

function onTick()
	Text.print(Defines.jumpheight_bounce,0,0)
	Text.print(myData:get("bums"),0,20)
	if myData:get("bums") == 1 then
		if player:mem(0x160,FIELD_WORD) > 20 then
			player:mem(0x160,FIELD_WORD,20)
		end
	end
	if myData:get("bums") == 1 then
		if player:mem(0xFA,FIELD_WORD) == -1 or player:mem(0xFC,FIELD_WORD) == -1 then
			Defines.gravity = 2
		else
			Defines.gravity = 12
		end
	else
		Defines.gravity = 12
	end
	if myData:get("bums") == 1 then
		Defines.jumpheight_bounce = 22
		Defines.jumpheight = 22
	else
		Defines.jumpheight_bounce = 20
		Defines.jumpheight = 20
	end
	if myData:get("bums") == 1 then
		for k,v in pairs(NPC.get(13,player.section)) do
			v:mem(0xF0,FIELD_DFLOAT,2)
		end
	end
	if myData:get("bums") == 1 then
		player:mem(0x12,FIELD_WORD,-1)
	else
		player:mem(0x12,FIELD_WORD,0)
	end
end

function onNPCKill(eventObj, killedNPC, killReason)
	if killedNPC.id == 13 and myData:get("bums") == 1 then
		Misc.doBombExplosion(killedNPC.x + 8, killedNPC.y + 8, 0)
		Misc.doBombExplosion(killedNPC.x + 8, killedNPC.y + 32, 0)
		Misc.doBombExplosion(killedNPC.x + 8, killedNPC.y - 16, 0)
		Misc.doBombExplosion(killedNPC.x + 32, killedNPC.y + 8, 0)
		Misc.doBombExplosion(killedNPC.x - 16, killedNPC.y + 8, 0)
	end
end

function onEvent(eventName)
	if eventName == "hit" and myData:get("bums") == 1 then
		myData:set("bums",0)
		myData:save(0)
	else
		myData:set("bums",1)
		myData:save(0)
	end
end
S1eth
Posts: 291
Joined: 9 years ago

Re: LunaDLL/LunaLUA help thread

Post by S1eth »

7NameSam wrote:I need help,
The data class "bums" is always 1 when I load the level
Here's your problem

Code: Select all

function onEvent(eventName) -- is called with the "Level - Start" parameter value when you load the level
   if eventName == "hit" and myData:get("bums") == 1 then -- this evaluates to false
      myData:set("bums",0)
      myData:save(0)
   else -- so then, "bums" is set to 1 whenever any event happens that is not "hit"
      myData:set("bums",1) 
      myData:save(0)
   end
end
There are 3 default events for "Level - Start", "P Switch - Start", and "P Switch - End". All of these, and any new events you create will set "bums" to 1.
Image
User avatar
Holy
Posts: 133
Joined: 12 years ago

Re: LunaDLL/LunaLUA help thread

Post by Holy »

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
User avatar
snoruntpyro
cutest girl 2023
Posts: 884
Joined: 9 years ago
Pronouns: she/her
Contact:

Re: LunaDLL/LunaLUA help thread

Post by snoruntpyro »

Holy wrote: function onLoopSection1()
Audio.MusicVolume = (40 + player.speedY)
end[/code]
and I'm gettin nothin
Seems as if you're treating it like a variable, when Audio.MusicVolume is a function. Try Audio.MusicVolume(40+player.speedY).
Image
Image
Image
Image
Image
User avatar
Holy
Posts: 133
Joined: 12 years ago

Re: LunaDLL/LunaLUA help thread

Post by Holy »

Ohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh.

Yup, that was it.
User avatar
Wohlstand
Moondust and TheXTech developer
Posts: 186
Joined: 10 years ago
First name: Vitaly
Pronouns: he/him/his
Location: Moscow, Russia

Re: LunaDLL/LunaLUA help thread

Post by Wohlstand »

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: 248
Joined: 9 years ago
Pronouns: they/them

Re: LunaDLL/LunaLUA help thread

Post by 7NameSam »

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})
Rixithechao
https://www.youtube.com/watch?v=BODxOghVmko
Posts: 1812
Joined: 10 years ago
First name: Mack
https://rixithechao.talkhaus.com/

Re: LunaDLL/LunaLUA help thread

Post by Rixithechao »

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}.
Delightful Adventure Enhanced is out now!

Image

There's an official ASMT Discord server! Check it out to discuss Demo games and follow their development! thread, invite link

(Entry requires verification, either with a connected Youtube/Twitter/Twitch/etc account or manually by the server staff.)


Itch.io (albums and eventually games), Youtube (dofur pass and I guess other videos)
Post Reply