(shouting)

LunaDLL/LunaLUA help thread

The second SMBX collab!
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: LunaDLL/LunaLUA help thread

Post by Hoeloe »

S1eth wrote: Is this the same as the pNPC's "uid"?
No. It's absolutely NOT the same as pNPCs uid.

Basically, in SMBX, all enemies are kept in an array. The "index" is the position in that array that the enemy is found.

The problem is that when enemies are killed, they're removed from the array, and arrays can't have gaps, so unless the enemy is last in the array, a bunch of NPCs will then change their index.

What pNPC does is assign each NPC with a persistent UID (Unique Identifier), which is ONLY used for identifying the NPC, not for accessing the array. This allows you to find NPCs even if they change position in the array, as you can pick it out with the UID (since the UID never changes over the lifetime of the NPC).

What you'll want to do is find the NPC at the array index, which you can do using:

Code: Select all

local myNPC = NPC(index)
Then, if you call pnpc.wrap on that, it will give you the associated pNPC object, or create one if it doesn't exist.
Image
Image
Image
Image
Image
S1eth
Posts: 291
Joined: 9 years ago

Re: LunaDLL/LunaLUA help thread

Post by S1eth »

Thanks for the previous answer.

I have another question specifically about the worldToScreen function from colliders.lua .
I needed a function like that, so I just copied that one from colliders, and noticed that everything was a few pixels off.

So, my question is: why is it that whenever worldToScreen is used, it needs x - 10 and y + 10 as arguments?
Image
User avatar
Imaynotbehere4long
Gone, but...yeah, pretty much forgotten.
Posts: 289
Joined: 8 years ago

Re: LunaDLL/LunaLUA help thread

Post by Imaynotbehere4long »

SAJewers and I are at a disagreement, and I've come here to get an arbiter to settle this:

Do sprite-swaps take the same amount of time to load as graphics loaded with Graphics.loadAnimatedImage, or does the latter load faster? I recommend testing with EoW8's animated zooms from Episode 1.
My SMBX portfolio:
Image
(includes a Sonic 3D Blast styled level.)

SOMEONE ANSWER MY CRY FOR HELP: http://www.supermariobrosx.org/forums/v ... =69&t=2026
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: LunaDLL/LunaLUA help thread

Post by Kevsoft »

Imaynotbehere4long wrote: Do sprite-swaps take the same amount of time to load as graphics loaded with Graphics.loadAnimatedImage?
It's a difficult because the loading code for loadAnimatedImage is similar to SMBX's one.

Here is how SMBX does it:
1.) Call the VB6 LoadImage function (probably big overhead here, because it is a VB6-Function)
2.) Make a device context for rendering
3.) Store it

Here is how LunaLua's loadAnimatedImage does it:
1.) Load the gif and extract every frame of the gif
2.) Make multiple device context for rendering (probably big overhead here, because of multiple device contexts)
3.) Store it.

The big advantage however is that you can call loadAnimatedImage anytime. Either in the start or in mid-game. So you could say: Load animated image X and run it. While images of X is running do loadAnimatedImage of Y.
User avatar
CloudyCloud
Posts: 234
Joined: 11 years ago

Re: LunaDLL/LunaLUA help thread

Post by CloudyCloud »

1. Is there a way to make the player character float when they are holding item in the ocean? I am curious if such code is written already.

you know, SMW physics.(In SMW, player can float and thus swim faster when they hold item in the water.)

2. Possible to make only some item able to help player float on the water?
(For example, ice block. Well, you get the ice flower and then you freeze the monsters, then the frozen enemy-block will float up. And thus I am thinking that one should be able to float if they hold the frozen block also.)(I kinda want to make a swim ring.)

1st question is more to make a SMW water level.
2nd question is more for other reason.

Or actually 1st question is just extension of 2nd?
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: LunaDLL/LunaLUA help thread

Post by Kevsoft »

LunaLua v0.7.2.1 has just been released. This is an important update because it fixes an exploit which manages to run assembler code on your computer throught lunadll.txt due to an exploit in the Autocode module.

Additional changes are:
* Extended NPC class
* Added cheat values. Some cheat can now be toggled by value. (Defines.* namespace)
* Added Audio.MusicArtistTag(), Audio.MusicAlbumTag() and Audio.MusicCopyrightTag() functions
* Added console class. You can now use the windows console for debugging. (See LunaLua command arguments at the wiki)
* Hotfix Bugfix [LunaLua]: Fixed ROP exploit at the Autocode module.
User avatar
SAJewers
ASMBXT Level Wrangler/A2XT Project Coordinator /AAT Level Designer
Posts: 4219
Joined: 12 years ago
Location: Nova Scotia

Re: LunaDLL/LunaLUA help thread

Post by SAJewers »

How do I change a variable that's in lunaworld.lua using lunadll.lua?
I have variable = "whatever" in lunadll.lua, but Text.print(variable,50,550) in lunaworldlua just prints nil (or whatever I set it to in lunaworld.lua).

EDIT NVM I Figured it out, use _G["variable"]
ImageImageImageImageImage | Image | Image
Sharenite | RetroAchievements | NameMC | IGDB
User avatar
Karatekid5
Welcome to the resort!
Posts: 78
Joined: 14 years ago
Location: Pennsylvania
Contact:

Re: LunaDLL/LunaLUA help thread

Post by Karatekid5 »

I'm just making a simple code kinda like what Maglx2 does where an image will be displayed on-screen when a player is within certain coordinates. The code for the text runs just fine but it won't display the image. Did I set this up correctly?

Code:

Code: Select all

function onLoop()

if (player.x > -119306 and player.x < -119262 and player.y > -119974 and player.y <-119682) then
  Text.print("Olimaaaaaar",12,12)
  loadImage ("HUB/olimar.png", 1, 0xdc00ff)
  placeSprite(1, 1, 100, 100)
  end
end
Yoshi Ambassador!
Image
User avatar
snoruntpyro
cutest girl 2023
Posts: 884
Joined: 9 years ago
Pronouns: she/her
Contact:

Re: LunaDLL/LunaLUA help thread

Post by snoruntpyro »

If I remember correctly, printText/Text.print draws relative to the screen, while loadImage/Graphics.loadImage does not. I'm not sure how to solve this, though, sorry!!
Image
Image
Image
Image
Image
User avatar
SAJewers
ASMBXT Level Wrangler/A2XT Project Coordinator /AAT Level Designer
Posts: 4219
Joined: 12 years ago
Location: Nova Scotia

Re: LunaDLL/LunaLUA help thread

Post by SAJewers »

Graphics.placeSrpite does draw relative to the screen. try this code:

Code: Select all

local overlay = Graphics.loadImage("//HUB/Olimar.png");

function onLoop()
	if (player.x > -119306 and player.x < -119262 and player.y > -119974 and player.y <-119682) then
		Text.print("Olimaaaaaar",12,12)
		Graphics.placeSprite(1, overlay, 100, 100)
	end
end


ImageImageImageImageImage | Image | Image
Sharenite | RetroAchievements | NameMC | IGDB
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: LunaDLL/LunaLUA help thread

Post by Kevsoft »

You can draw images relative to the screen by using Graphics.drawImage. If you want to draw images relative to the level-scene then you can use Graphics.drawImageToScene.
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: LunaDLL/LunaLUA help thread

Post by Hoeloe »

Kevsoft wrote:You can draw images relative to the screen by using Graphics.drawImage. If you want to draw images relative to the level-scene then you can use Graphics.drawImageToScene.
Would be nice to have something similar for text.
Image
Image
Image
Image
Image
User avatar
SAJewers
ASMBXT Level Wrangler/A2XT Project Coordinator /AAT Level Designer
Posts: 4219
Joined: 12 years ago
Location: Nova Scotia

Re: LunaDLL/LunaLUA help thread

Post by SAJewers »

any updates on the ticking P-switch thingy?
ImageImageImageImageImage | Image | Image
Sharenite | RetroAchievements | NameMC | IGDB
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: LunaDLL/LunaLUA help thread

Post by Kevsoft »

SAJewers wrote:any updates on the ticking P-switch thingy?
Uhm, what do you need again from the P-Switch mechanism?
User avatar
Ignoritus
O◡O
Posts: 207
Joined: 11 years ago
Pronouns: he/him/his
Location: U.S.

Re: LunaDLL/LunaLUA help thread

Post by Ignoritus »

Kevsoft wrote:If you want to draw images relative to the level-scene then you can use Graphics.drawImageToScene.
Does this force the draw call even if the destination isn't currently on-screen, or does it perform a check beforehand?
Image
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: LunaDLL/LunaLUA help thread

Post by Kevsoft »

Ignoritus wrote:
Kevsoft wrote:If you want to draw images relative to the level-scene then you can use Graphics.drawImageToScene.
Does this force the draw call even if the destination isn't currently on-screen, or does it perform a check beforehand?
Direct draw, no on-screen check.
User avatar
SAJewers
ASMBXT Level Wrangler/A2XT Project Coordinator /AAT Level Designer
Posts: 4219
Joined: 12 years ago
Location: Nova Scotia

Re: LunaDLL/LunaLUA help thread

Post by SAJewers »

Kevsoft wrote:
SAJewers wrote:any updates on the ticking P-switch thingy?
Uhm, what do you need again from the P-Switch mechanism?
The request was to replace the P-switch jingles with a sound effect that played over the regular level music, like in ASMT:
SAJewers wrote:
Rednaxela wrote:
SAJewers wrote:EDIT: Also, Is it possible to have no P-Switch music, like in ASMT/A2MT?
I'm unaware of what was done in ASMT/A2MT for no P-Switch music (was it just have no music file or a silent music file?), but any reason the same can't be done?

I'm now however thinking that in the next few days I may look into adding a "p-switch settings" thing to LunaLua, so various things about p-switches could be set from Lua, which would be via the lunaworld.lua file for making something episode-wide. Might think about making it so in addition to silent or not, maybe allowing the duration to be changed by Lua code (not super relevant to A2XT stuff at the episode level but maybe some level creators would find it handy)
the P-switch thingy in ASMT was an ASM patch that replaced the P-switch music with a ticking sound effect that played over the level music. Here's an example from raocow's ASMT LP, or a TAS of that level if you don't want commentary. I can easily grab that sound effect.
ImageImageImageImageImage | Image | Image
Sharenite | RetroAchievements | NameMC | IGDB
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:any updates on the ticking P-switch thingy?
Ahhh right. Sorry about that. Life has been a bit hectic recently and that item slipped off my radar for a bit.
Once I get time for it, it's probably a quick 1-evening type of task.

Any target date of when you want it for? I know things are in the level review stage right now right? I'll try to not let it slip off my radar in any case.
User avatar
SAJewers
ASMBXT Level Wrangler/A2XT Project Coordinator /AAT Level Designer
Posts: 4219
Joined: 12 years ago
Location: Nova Scotia

Re: LunaDLL/LunaLUA help thread

Post by SAJewers »

As soon as you can get it done, but don't rush. We'll probably need more levels, as almost half the levels have rejects to their name. If we can get some reviewers to review levels, I'm hoping to get the current submissions list pared down significantly by the end of the month. I expect we'll hit maybe 40 approved levels by then, and would need about 30 or 40 more. I don't expect to get a finalized level list before christmas, unless we get a big spree of submissions after MaGLX2.
ImageImageImageImageImage | Image | Image
Sharenite | RetroAchievements | NameMC | IGDB
User avatar
Karatekid5
Welcome to the resort!
Posts: 78
Joined: 14 years ago
Location: Pennsylvania
Contact:

Re: LunaDLL/LunaLUA help thread

Post by Karatekid5 »

SAJewers wrote:Graphics.placeSrpite does draw relative to the screen. try this code:

Code: Select all

local overlay = Graphics.loadImage("//HUB/Olimar.png");

function onLoop()
	if (player.x > -119306 and player.x < -119262 and player.y > -119974 and player.y <-119682) then
		Text.print("Olimaaaaaar",12,12)
		Graphics.placeSprite(1, overlay, 100, 100)
	end
end



I tried out your code, though it resulted in this error:
Attachments
luna error.png
luna error.png (17.66 KiB) Viewed 3965 times
Yoshi Ambassador!
Image
User avatar
SAJewers
ASMBXT Level Wrangler/A2XT Project Coordinator /AAT Level Designer
Posts: 4219
Joined: 12 years ago
Location: Nova Scotia

Re: LunaDLL/LunaLUA help thread

Post by SAJewers »

Karatekid5 wrote:
SAJewers wrote:Graphics.placeSrpite does draw relative to the screen. try this code:

Code: Select all

local overlay = Graphics.loadImage("//HUB/Olimar.png");

function onLoop()
	if (player.x > -119306 and player.x < -119262 and player.y > -119974 and player.y <-119682) then
		Text.print("Olimaaaaaar",12,12)
		Graphics.placeSprite(1, overlay, 100, 100)
	end
end



I tried out your code, though it resulted in this error:
Try this:

Code: Select all

local overlay = Graphics.loadImage("Misc.resolveFile("Olimar.png"));

function onLoop()
	if (player.x > -119306 and player.x < -119262 and player.y > -119974 and player.y <-119682) then
		Text.print("Olimaaaaaar",12,12)
		Graphics.placeSprite(1, overlay, 100, 100)
	else
	Graphics.unplaceSprites(overlay)
	end
end


ImageImageImageImageImage | Image | Image
Sharenite | RetroAchievements | NameMC | IGDB
User avatar
Karatekid5
Welcome to the resort!
Posts: 78
Joined: 14 years ago
Location: Pennsylvania
Contact:

Re: LunaDLL/LunaLUA help thread

Post by Karatekid5 »

SAJewers wrote: Try this:

Code: Select all

local overlay = Graphics.loadImage("Misc.resolveFile("Olimar.png"));

function onLoop()
	if (player.x > -119306 and player.x < -119262 and player.y > -119974 and player.y <-119682) then
		Text.print("Olimaaaaaar",12,12)
		Graphics.placeSprite(1, overlay, 100, 100)
	else
	Graphics.unplaceSprites(overlay)
	end
end

Got a simpler error this time. Is there a problem with the parentheses?
Attachments
luna error 2.png
luna error 2.png (3.73 KiB) Viewed 3993 times
Yoshi Ambassador!
Image
User avatar
Ignoritus
O◡O
Posts: 207
Joined: 11 years ago
Pronouns: he/him/his
Location: U.S.

Re: LunaDLL/LunaLUA help thread

Post by Ignoritus »

Karatekid5 wrote:
SAJewers wrote: Try this:

Code: Select all

local overlay = Graphics.loadImage("Misc.resolveFile("Olimar.png"));

function onLoop()
	if (player.x > -119306 and player.x < -119262 and player.y > -119974 and player.y <-119682) then
		Text.print("Olimaaaaaar",12,12)
		Graphics.placeSprite(1, overlay, 100, 100)
	else
	Graphics.unplaceSprites(overlay)
	end
end

Got a simpler error this time. Is there a problem with the parentheses?
Quotations actually. You open a quotation before Misc which then turns everything proceeding into a string including your close-parantheses.
Image
User avatar
Karatekid5
Welcome to the resort!
Posts: 78
Joined: 14 years ago
Location: Pennsylvania
Contact:

Re: LunaDLL/LunaLUA help thread

Post by Karatekid5 »

I removed the quotation mark before the Misc, but now running the code makes SMBX crash with an exception code of 0xc0000005.
Yoshi Ambassador!
Image
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: LunaDLL/LunaLUA help thread

Post by Kevsoft »

Try with:

Code: Select all

local overlay = Graphics.loadImage(Misc.resolveFile("HUB/Olimar.png"));

function onLoop()
   if (player.x > -119306 and player.x < -119262 and player.y > -119974 and player.y <-119682) then
      Text.print("Olimaaaaaar",12,12)
      Graphics.placeSprite(1, overlay, 100, 100)
   end
end
Post Reply