(shouting)

LunaDLL/LunaLUA help thread

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

Re: LunaDLL help thread

Post by Hoeloe »

Oddwrath wrote:In LunaLua, what is the difference between RECT and RECTd? And which one would be the TriggerZone of LunaLua?
The difference is that RECT is 4 points with single-precision floating point values. That's a number stored in 32-bits. RECTd, however, is 4 points with double-precision floating point values. That's a number stored in 64-bits. This gives you more accuracy. You'll rarely need this, though.

I don't think LunaLua has the "TriggerZone" function built in, so neither is the answer to that. What you can do instead is simply check the player's coordinates when looping. This way you can use either, or even your own values. Something like this will work:

Code: Select all

function onLoop()
  if(player.x > leftside and player.y > topside and player.x < rightside and player.y < bottomside) then
    --do things
  end
end
You can swap out "___side" for the values of your trigger box, or references to fields in a RECT or RECTd structure if you want.
Image
Image
Image
Image
Image
User avatar
Oddwrath
The ghost of talkhaus unlikely
Posts: 95
Joined: 9 years ago
Pronouns: she/her
Location: Merry Old Europe

Re: LunaDLL help thread

Post by Oddwrath »

Hoeloe wrote:

Code: Select all

function onLoop()
  if(player.x > leftside and player.y > topside and player.x < rightside and player.y < bottomside) then
    --do things
  end
end
The onLoop() doesn't work. But the onLoopSection2() works...sorta.

Code: Select all

function onLoopSection2()
	if (player.x > -158400 and player.y > -160520 and player.x < -157640 and player.y < -150485) then
    player.speedY = 3
  end
end
It takes the first and last x coordinates and seems to completely ignore the y ones. As a result, I have a big chunk of the level, where the player cannot jump.
Furthermore, if you jump into that area, Demo glides down and continues to wall by her own until it ends.
Further-furthermore, if you spinjump into that area Demo just continues twirling like a ballerina, until she reaches the end of the area.

And if you're wondering what am I trying to do, well, I'm trying to recreate the castle mazes from smb1.

Edit: nevermind the bit with the onLoop() not working. Apparently, it doesn't want to share it's place in the script with another onLoop(). The rest are still broken, though.
Edit 2: again nevermind the bit with taking the big chunk of the level. I'm just an idiot who didn't count the y values properly. Even though, Demo still spins endlessly if you jump into that area.
:lesbian_pride: my avatar is from that obake game made in 2001 that you cannot play anymore unless you run it through a virtual machine and apply a locale patch
User avatar
Hoeloe
A2XT person
Posts: 1016
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: LunaDLL help thread

Post by Hoeloe »

Oddwrath wrote: Edit 2: again nevermind the bit with taking the big chunk of the level. I'm just an idiot who didn't count the y values properly. Even though, Demo still spins endlessly if you jump into that area.
That just sounds like you're accidentally stopping spinjumping from working. Probably because for a spinjump to stop, you need to land on the ground, and since you're setting speedY to 3, this never happens. You may need to set some player memory locations to stop the spinjump manually.
Image
Image
Image
Image
Image
TiKi
Posts: 709
Joined: 10 years ago

Re: LunaDLL help thread

Post by TiKi »

Kil: you know how for example your Luna tower 2 had items you collected only once, and you couldn't collect them again? Well I'm planning on having a "shop" in a tutorial (like NSMB where you spend star coins). Collecting the star coin adds to a variable and hides the coin forever, and buying something subtracts from the star coin counter. But would re-entering the level where you already got a star coin and set the "is this specific one dead" variable to 1 re-add the star coin to the total count since the death of the custom sprite adds 1?

TDLR does a custom sprite being hidden trigger its death event a la smw stars

Also how is that "change a SMBX npc to a custom npc" coming, that would really help the placement of it
Last edited by TiKi 9 years ago, edited 1 time in total.
User avatar
Hoeloe
A2XT person
Posts: 1016
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: LunaDLL help thread

Post by Hoeloe »

TiKi wrote:Kil: you know how for example your Luna tower 2 had items you collected only once, and you couldn't collect them again? Well I'm planning on having a "shop" in a tutorial (like NSMB where you spend star coins). Collecting the star coin adds to a variable and hides the coin forever, and buying something subtracts from the star coin counter. But would re-entering the level where you already got a star coin and set the "is this specific one dead" variable to 1 re-add the star coin to the total count since the death of the custom sprite adds 1?
Almost certainly, but you could easily counteract that by subtracting one from the counter as you kill it for being already collected.
Image
Image
Image
Image
Image
TiKi
Posts: 709
Joined: 10 years ago

Re: LunaDLL help thread

Post by TiKi »

So if "StarCoin x = 1 (collected)", I'd subtract 1 from the total StarCoin counter in the "add 1 to the star coin counter once the custom npc dies" event?

Also to Kil: you know how Game Maker allows you to make one object and when you place an instance of it, use "creation codes" to modify it? Is that supported? It would be tedious to make the whole variable rigmarole for EACH OF 240 DRAGON COINS SEPERATELY
User avatar
Hoeloe
A2XT person
Posts: 1016
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: LunaDLL help thread

Post by Hoeloe »

TiKi wrote:So if "StarCoin x = 1 (collected)", I'd subtract 1 from the total StarCoin counter in the "add 1 to the star coin counter once the custom npc dies" event?
You'd subtract one from the total StarCoin counter if you start the level and find that is has been collected. Then, when you kill the NPC, it will increment the counter, which cancels out the subtraction.
TiKi wrote: Also to Kil: you know how Game Maker allows you to make one object and when you place an instance of it, use "creation codes" to modify it? Is that supported? It would be tedious to make the whole variable rigmarole for EACH OF 240 DRAGON COINS SEPERATELY
I don't believe it is, because LunaDLL isn't really object oriented in that way. You can write some lua code to generate variable names, rather than manually naming each one, but I don't think objects and classes really exist.

Oh, also, what are you referring to when you talk about 240 dragon coins?
Image
Image
Image
Image
Image
TiKi
Posts: 709
Joined: 10 years ago

Re: LunaDLL help thread

Post by TiKi »

Thanks

And my episode has 48 levels x 5 dragon coins = 240 coins
User avatar
Hoeloe
A2XT person
Posts: 1016
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: LunaDLL help thread

Post by Hoeloe »

TiKi wrote:Thanks

And my episode has 48 levels x 5 dragon coins = 240 coins
Ah, so you're trying to do an A2MT style dragon coin system? It's doable, but will be painful.
Image
Image
Image
Image
Image
TiKi
Posts: 709
Joined: 10 years ago

Re: LunaDLL help thread

Post by TiKi »

So the only thing to do is actually to have 240 copies of the coin sprite code floating around?
User avatar
Hoeloe
A2XT person
Posts: 1016
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: LunaDLL help thread

Post by Hoeloe »

TiKi wrote:So the only thing to do is actually to have 240 copies of the coin sprite code floating around?
Oh, no. You can just run the code on each object of the same ID using arrays and for loops (assuming you're using lua). No need to copy and paste it that many times.
Image
Image
Image
Image
Image
TiKi
Posts: 709
Joined: 10 years ago

Re: LunaDLL help thread

Post by TiKi »

Oops I forgot to say I only really get auto code. Not lua.
Kil
Posts: 13
Joined: 15 years ago

Re: LunaDLL help thread

Post by Kil »

I'll just give you my permanently collectible dragon coin lua code and you can use that. You won't need to understand it. Also if you were making permanent collectibles as custom sprites, you probably should've just designed them to handle all that in their base behavior instead of doing it all manually each time. That would really be the point of building custom sprites - build once, reuse many times.

(the level you're looking at is a very bad example of this, because it uses lots sprites that are only used once)
DON'T PM me. Ask your question in the help thread so everyone can be answered.
darkychao
Posts: 0
Joined: 13 years ago
Location: When you sleep there's a lesson you must learn: not for the lesson today, mate.

Re: LunaDLL help thread

Post by darkychao »

Is there a way for a level to check the demo counter.
Also, would it be possible to count enemies killed, in a similar way to the demo/death counter.
Image
Image
Image
BeatBoxingBoo wrote:a medley is just, like, a mixture of medics
Check out my TF2 community workshop stuff:
Crust CrusherImage Crafty CutterImage PinheadImageThreadImage
If I didn't like anybody who had a different opinion than me on something I like I wouldn't have any friends.-Bwarch
Kil
Posts: 13
Joined: 15 years ago

Re: LunaDLL help thread

Post by Kil »

yes
DON'T PM me. Ask your question in the help thread so everyone can be answered.
Zia Satazaki
Floof Incarnate
Posts: 28
Joined: 14 years ago
Pronouns: she/they

Re: LunaDLL help thread

Post by Zia Satazaki »

Hoeloe wrote:I don't believe it is, because LunaDLL isn't really object oriented in that way. You can write some lua code to generate variable names, rather than manually naming each one, but I don't think objects and classes really exist.
Lua doesn't exactly "support" OO and inheritance in the traditional sense, but they can both be done with some fairly simple (if somewhat obscure) syntax; tables can contain functions, etc. and can inherit from another table via their _env value and such.
User avatar
Hoeloe
A2XT person
Posts: 1016
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: LunaDLL help thread

Post by Hoeloe »

JVyrn wrote:
Hoeloe wrote:I don't believe it is, because LunaDLL isn't really object oriented in that way. You can write some lua code to generate variable names, rather than manually naming each one, but I don't think objects and classes really exist.
Lua doesn't exactly "support" OO and inheritance in the traditional sense, but they can both be done with some fairly simple (if somewhat obscure) syntax; tables can contain functions, etc. and can inherit from another table via their _env value and such.
Ah. Thanks for that. I only started using Lua the other day, so I'm not hugely familiar with how it works. I was aware that tables could contain functions, but not that they could "inherit" from other tables in an OO manner.
Image
Image
Image
Image
Image
TiKi
Posts: 709
Joined: 10 years ago

Re: LunaDLL help thread

Post by TiKi »

http://speedy.sh/tAqk3/The-Ultimate-Stronghold.zip

So when the "change dry bones to crab" code triggers while the dry bones is crumbled, it shows the crab sprite but it's friendly thankfully. Is there any way to not trigger the sprite change when the dry bones is crumbled?
Darkchaox100
Posts: 0
Joined: 9 years ago

Re: LunaDLL help thread

Post by Darkchaox100 »

TiKi wrote:http://speedy.sh/tAqk3/The-Ultimate-Stronghold.zip

So when the "change dry bones to crab" code triggers while the dry bones is crumbled, it shows the crab sprite but it's friendly thankfully. Is there any way to not trigger the sprite change when the dry bones is crumbled?
Wait a moment,are you FanOfSMBX? Because i didnt gave anyone else then him the Torch Stuff.
TiKi
Posts: 709
Joined: 10 years ago

Re: LunaDLL help thread

Post by TiKi »

Yeah. Oops, should I delete the link?
Darkchaox100
Posts: 0
Joined: 9 years ago

Re: LunaDLL help thread

Post by Darkchaox100 »

TiKi wrote:Yeah. Oops, should I delete the link?
No reasom to delete it.
I was just wondering..
TiKi
Posts: 709
Joined: 10 years ago

Re: LunaDLL help thread

Post by TiKi »

Okay so I know how to make the dragon coins into money. How would one go about buying stuff though? I was thinking of hit a block to buy the item... But I don't think lunadll can activate upon SMBX events? And I'd be re using a block type (the message block) for all buying blocks.
User avatar
Hoeloe
A2XT person
Posts: 1016
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: LunaDLL help thread

Post by Hoeloe »

TiKi wrote:Okay so I know how to make the dragon coins into money. How would one go about buying stuff though? I was thinking of hit a block to buy the item... But I don't think lunadll can activate upon SMBX events? And I'd be re using a block type (the message block) for all buying blocks.
LunaLua actually can activate on SMBX events! It's a bit round-about, but there's a library to help!

Here's the link to the thread with the download link in the first post: viewtopic.php?f=36&t=14980&start=125
Image
Image
Image
Image
Image
TiKi
Posts: 709
Joined: 10 years ago

Re: LunaDLL help thread

Post by TiKi »

Oh. The bad thing is I don't *use* lua code, so unless someone volunteers to be the lua guy I can't do it I'm afraid.
Darkchaox100
Posts: 0
Joined: 9 years ago

Re: LunaDLL help thread

Post by Darkchaox100 »

TiKi wrote:Oh. The bad thing is I don't *use* lua code, so unless someone volunteers to be the lua guy I can't do it I'm afraid.
Go to the Smbx Chat and PM Kevsoft,i'm sure he will help you just like he helped me.
Post Reply