(shouting)

LunaLua Offical Thread

The second SMBX collab!

Shall I stream some LunaLua live development?

Yes
23
92%
No
2
8%
 
Total votes: 25

User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Horikawa Otane wrote:I don't take it we know how to swap NPC/PC graphics out programatically do we?
We can swap NPC IDs programatically, but I think that's the most we can do at the moment.

Depending on what you want to do, you may be able to do something similar to what I did in my MAGLX2 Relay screen - that is, create NPCs entirely through Lua using placeSprite, which gives you full control, albeit with limited functionality.
Image
Image
Image
Image
Image
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Horikawa Otane wrote:
Hoeloe wrote:
Horikawa Otane wrote:That's okay. How would we handle multiple simultaneous keypresses?

For example, holding jump then pressing up.

edit: nevermind, figured it out more or less

edit 2: nevermind, still not working super well
What are you doing that's not working super well? The keyboard events should work just fine for multiple at once... though... personally I often prefer to just read keyboard state out of the player object during onLoop instead.
S1eth
Posts: 291
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by S1eth »

Something like this?

Code: Select all

local KEYSTATE_PRESSED = -1;

local isUpKeyPressed = false;
local upKeyCount = 0;

local testString = "successful attempts: ";

function onLoad()

end

function onLoop()
  printText(testString,3,0,90);

  if(player.UKeyState == KEYSTATE_PRESSED) then
    if(not isUpKeyPressed) then
      isUpKeyPressed = true;
      upKeyCount = upKeyCount + 1;
      if(upKeyCount >= 2) then
        -- do something
        testString = testString.."x";
        upKeyCount = 0;
      end
    end
  else
    isUpKeyPressed = false;
  end
  
  if(player.JKeyState ~= KEYSTATE_PRESSED) then
    upKeyCount = 0;
  end
end
Does not work if DOWN is held. If UP is held, pressing and releasing DOWN twice has the same effect as pressing UP twice.

BTW, I just tried using onKeyUp and onKeyDown, and onKeyUp doesn't do anything. The function is never even entered.
Image
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Horikawa Otane wrote: How would one slow a character down to, say, half-speed? I've been playing with player.Speedx and it just makes the character go insane.
Difficult. The speedX and speedY variables are for the current velocity of the player, so altering those will cause problems unless you're careful. If you can't get those to work directly, you could try a trick by halting the player's movement every other frame, so they only move half the time. That might not work either, and will probably look and control poorly, though.
Image
Image
Image
Image
Image
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Horikawa Otane wrote: Beyond this, how do you spawn an npc and keep track of *that npc*. You can use findnpcs and it'll be the last entry in the array, but if other npcs get generated or something, how do you find *your* npc in the chaos?
Use pnpc.
Image
Image
Image
Image
Image
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Yeah, "myNPC = pNPC.wrap(spawnNPC(...))" is a handy pattern.
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

Code: Select all

theNPC:kill(9)
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Kevsoft wrote:

Code: Select all

theNPC:kill(9)
That isn't the best way of instantly despawning an NPC, as that creates a "killed" effect.

Try this:

Code: Select all

npc:mem(0x40,FIELD_WORD,0xFFFF);
This kills it outright. Just be careful not reference the NPC again with pNPC after doing this.
Image
Image
Image
Image
Image
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

Hoeloe wrote:
Kevsoft wrote:

Code: Select all

theNPC:kill(9)
That isn't the best way of instantly despawning an NPC, as that creates a "killed" effect.

Try this:

Code: Select all

npc:mem(0x40,FIELD_WORD,0xFFFF);
This kills it outright. Just be careful not reference the NPC again with pNPC after doing this.
KillAnimation 9 is no animation. It is just vanish. I would prefer that, but you can try both.
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

If you actually want a true despawn as if off screen though (the difference from killing it is potentially allowing it to respawn when leaving and re-enteting the area), you can set offset 0x12A to 0
S1eth
Posts: 291
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by S1eth »

Can someone confirm if onKeyUp is never called and currently does absolutely nothing? (using 0.6.1.1)
Image
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Kevsoft wrote: KillAnimation 9 is no animation. It is just vanish. I would prefer that, but you can try both.
This is the sort of thing that needs to be in the documentation, but I believe the memory location I specified is just the "the NPC should die" flag, which makes it basically analogous.
Image
Image
Image
Image
Image
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Horikawa Otane wrote:Okay I've got placesprite working quite well, but how do you REMOVE a sprite after you've placed it?
Unfortunately the current API isn't really great about that. The only way is to give it a limited life by using the "time" parameter... Usually I just set it to 2 always (which oddly means 1 frame because it's quirky like that...) and redraw it every onLoop that I want it to stay there.
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Horikawa Otane wrote:Is there a way to print out the current address in memory for the beginning of a spawned NPC's memset? It'd make offsets easier to find... Currently I have to find them via x coordinates...
Can't you just use npc:mem to input the offset directly?
Image
Image
Image
Image
Image
Kil
Posts: 13
Joined: 15 years ago

Re: Presenting: Lunadll for Lua!

Post by Kil »

Back when I testing the NPC structs I would just make sure there was only 1 NPC in the level, then I would go to the NPC array pointer and follow it to the NPC array. GM_NPCS_PTR should be at 0x00B259E8 in global memory. Get the pointer from there, add 0xAD78 (I think) to it, and it should bring you to the memory of NPC #1 in the level. From there you can keep adding the size of the NPC struct to get to NPC #2 and so on.
DON'T PM me. Ask your question in the help thread so everyone can be answered.
Kil
Posts: 13
Joined: 15 years ago

Re: Presenting: Lunadll for Lua!

Post by Kil »

yep, they are all converted to windows GDI bitmaps and pointers to them stored in a giant array somewhere
DON'T PM me. Ask your question in the help thread so everyone can be answered.
User avatar
Ditocoaf
Haustone Tournament Finalist
Posts: 724
Joined: 12 years ago
Pronouns: he/him/his
Location: On the horizon of the brandscape
https://ditocoaf.talkhaus.com/

Re: Presenting: Lunadll for Lua!

Post by Ditocoaf »

Every time Windows Defender gets new virus definition files, it re-discovers what it's certain is a trojan in smbx.exe: "Win32/Pocyx.D!plock"

I know this is a known issue, and I just tell it to Allow that "trojan", but every time, a couple weeks later smbx.exe vanishes abruptly again. Windows Defender confiscates and quarantines the exe every time it updates its definition files. Does anyone else have this problem?
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Ditocoaf wrote:Every time Windows Defender gets new virus definition files, it re-discovers what it's certain is a trojan in smbx.exe: "Win32/Pocyx.D!plock"

I know this is a known issue, and I just tell it to Allow that "trojan", but every time, a couple weeks later smbx.exe vanishes abruptly again. Windows Defender confiscates and quarantines the exe every time it updates its definition files. Does anyone else have this problem?
Yeah, it's an annoying false alarm that happens to me too.

The next version of LunaDLL has a fix for this though, in the form of a LunaLoader.exe that allows use of a vanilla smbx.exe. I can post an experimental build of it for you if you want
User avatar
Ditocoaf
Haustone Tournament Finalist
Posts: 724
Joined: 12 years ago
Pronouns: he/him/his
Location: On the horizon of the brandscape
https://ditocoaf.talkhaus.com/

Re: Presenting: Lunadll for Lua!

Post by Ditocoaf »

Nah, I'm not using SMBX that often lately, so it's no big deal. I just notice every couple weeks that the icon on my start bar has turned into a blank file, so I go and fish it out of jail.
User avatar
Willhart
Stalker, Doxxer, and Sexual Harasser
Banned
Posts: 2434
Joined: 13 years ago
Location: Finland

Re: Presenting: Lunadll for Lua!

Post by Willhart »

I'd like to give the player a blue boot when the game loads. How do I do that? Mount state seems to be divided into different addresses or something.

Edit: I also noticed, that even though this code works, it give "invalid player pointer" error when the player dies.

Code: Select all

function onLoad()
    player.powerup = PLAYER_HAMMER;
end
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Willhart wrote:I'd like to give the player a blue boot when the game loads. How do I do that? Mount state seems to be divided into different addresses or something.

Edit: I also noticed, that even though this code works, it give "invalid player pointer" error when the player dies.

Code: Select all

function onLoad()
    player.powerup = PLAYER_HAMMER;
end
That's because onLoad is called when the level loads in the editor too, but the player doesn't exist there. If you want to fix that, then just add a check for the player.isValid field.

As for the blue boot, you'll first want to do:

Code: Select all

player:mem(0x108, FIELD_WORD, 1);
Then experiment with values in the memory location 0x10A, which controls mount colour.
Image
Image
Image
Image
Image
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

For those interested in such things... one minor update about 0.7:

The "Graphics" API namespace has now deprecated manually assigned resource IDs. They were always a pain in terms of watching out for conflicts anyway.

The new variant of loadImage now returns a reference you can use instead, and when this reference is garbage collected by Lua, the image is automatically unloaded from the engine too. Also, to keep things simple, the new variant of loadImage no longer accepts a transparency colour. Use an image format that supports transparency (i.e. PNG or GIF) if you want to move to the new API in 0.7 and use an image with transparency.

The old API will still work as always, because compatibility is king, but thought I'd mention what way the new API was heading.
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Rednaxela wrote: The old API will still work as always, because compatibility is king, but thought I'd mention what way the new API was heading.
I'm still not sure what all the arguments to placeSprite do. I know that two of the available "types" are world space and screen space placement, but are there any others, and what does the "extra" argument do?
Image
Image
Image
Image
Image
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Hoeloe wrote:
Rednaxela wrote: The old API will still work as always, because compatibility is king, but thought I'd mention what way the new API was heading.
I'm still not sure what all the arguments to placeSprite do. I know that two of the available "types" are world space and screen space placement, but are there any others, and what does the "extra" argument do?
So... for the types, look here and here

So aside from the absolute and relative position plain old ones... there's a "collectable item" which can be configured to trigger an autocode event, there's a process bar one, there's some sort of phanto implementation, and there's some sort of 'custom' one. I've never tried using any of them myself.

The "extra" corresponds to some autocode string argument, which... for the case of the "collectable item" one gets interpreted as an integer representing the autocode event to trigger... and for the case of the 'custom' one gets treated as the "blueprint name". Not entirely sure what that's about, but looks like there are undocumented Autocode commands for making those blueprints and doing a couple other things with custom sprites. Basically... all that is some (so far as I know) undocumented Autocode API stuff that Kil had been working on at one pont.

I'm thinking that 1) I want to add a "drawImage" API some time that bypasses all that custom sprite code... because no reason to go through that custom sprite instantiation stuff for just drawing an image for a frame... and 2) More properly integrate that custom sprite system with Lua, among other things by extending "placeSprite" to return a reference to the created custom sprite and being able to do things with that (and possibly replacing placeSprite's type argument with multiple functions... because overloading function arguments to do multiple different things like is done with 'extra', is lame...)
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

I would generall completely overhaul the complete class. Maybe even add a new one with better OpenGL integration.
Post Reply