Need help with lua? - LunaLua General Help

This is the place for discussion and support for LunaLua and related modifications and libraries.
Forum rules
Before you make a topic/post, consider the following:
-Is there a topic for this already?
-Is your post on topic/appropriate?
-Are you posting in the right forum/following the forum rules?
User avatar
King of GETs
Spiny
Spiny
Posts: 48
Joined: Sat Jan 16, 2016 8:17 pm

Re: Need help with lua? - LunaLua General Help

Postby King of GETs » Thu Jan 05, 2017 3:45 am

Hoeloe wrote:
King of GETs wrote:So I was diving into LunaLua, and I got it to work in the editor, but it only works with "Test -> LunaTest -> Run testing" and NOT "Test Level <Alpha>" or "Test a saved file".

Is this normal?
Yes. "Test Level <Alpha>" is the alpha PGE engine, not SMBX.

You can also hit F5 as a shortcut, though, so I suggest trying that.
Thanks, will do.

User avatar
Angelus
Bit
Bit
Posts: 129
Joined: Tue Jun 21, 2016 9:38 am

Re: Need help with lua? - LunaLua General Help

Postby Angelus » Thu Jan 05, 2017 11:40 am

How to make a NPC stop moving while in midair, or while falling? I know we can set the NPC to not move at all, but I only want it to be stuck during its fall. Sadly I wasn't able to find anything similar to the player.mem which can set a certain thing to happen when not touching the ground, etc.

PixelPest
Link
Link
Posts: 7116
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Current Project: Boom Boom Evolution
Chat Username: PixelPest
Contact:

Re: Need help with lua? - LunaLua General Help

Postby PixelPest » Thu Jan 05, 2017 12:01 pm

You can check NPC.speedY (it will be greater than 0 if falling) and then set that

User avatar
Angelus
Bit
Bit
Posts: 129
Joined: Tue Jun 21, 2016 9:38 am

Re: Need help with lua? - LunaLua General Help

Postby Angelus » Thu Jan 05, 2017 1:33 pm

Sorry, while I understand what you meant I should've done a better question. I don't want to keep the NPC floating in midair. What I want is to keep it from moving to the right or to the left when falling, but once it hits the ground, it starts moving as usual.

Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 8729
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Orphion Egamalenitar Osmos IV, Esq.

Re: Need help with lua? - LunaLua General Help

Postby Enjl » Thu Jan 05, 2017 1:41 pm

You can use the NPC.dontMove flag if none of your NPCs with the ground pound property natively use it.
Ideas are useless if you can't make them real.
Image

User avatar
TUWAN
Blooper
Blooper
Posts: 177
Joined: Sun Mar 06, 2016 11:50 am
Current Project: :/
Chat Username: TUWAN

Re: Need help with lua? - LunaLua General Help

Postby TUWAN » Thu Jan 05, 2017 2:00 pm

Isn't there a discord server for this?
just kidding.
[she/her]

Support:
Spoiler: show
Image
Image
ImageImage
Image
Image
My ranks:
Spoiler: show
ImageRank #1: Goomba: 1-4 posts
Image Rank #2: Shy Guy: 5-9 posts
Image Rank #3: Cheep-Cheep: 10-19 posts
Image Rank #4: Koopa Troopa 20-29 posts
ImageRank #5: Bom-omb: 30-39 posts
ImageRank #6: Spiny: 40-59 posts
ImageRank #7: Fighter Fly: 60-79 posts
ImageRank #8: Rex: 80-99 posts
ImageRank #9: Swooper: 100-124 posts
ImageRank #10: Bit: 125-149 posts
Image Rank #11:Hoopster: 150-174 posts
List of all ranks:
viewtopic.php?f=48&t=961

PixelPest
Link
Link
Posts: 7116
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Current Project: Boom Boom Evolution
Chat Username: PixelPest
Contact:

Re: Need help with lua? - LunaLua General Help

Postby PixelPest » Thu Jan 05, 2017 2:21 pm

Yeah, but Discodehaus isn't solely about LunaLua help, it has other channels too

User avatar
Angelus
Bit
Bit
Posts: 129
Joined: Tue Jun 21, 2016 9:38 am

Re: Need help with lua? - LunaLua General Help

Postby Angelus » Thu Jan 05, 2017 2:34 pm

Alright! The closest thing I've got so far is the code below. The problem is, the NCP now follows my direction instead of taking its own. Is there something I could do to prevent it? Also, tell me if something is wrong into my code so I can fix it if necessary.
Spoiler: show
function onLoop()
for k,v in pairs(NPC.get(19,player.section)) do
if v:mem(0x0A,FIELD_WORD) == 0 then
v.dontMove = true;
elseif v:mem(0x0A,FIELD_WORD) == 2 then
v.dontMove = false;
end
end
end
By the way, shouldn't I be able to cancel its X speed during the falling? I've tried to set it to 0 but it didn't work.

User avatar
RPG_Magician
Pokey
Pokey
Posts: 216
Joined: Tue Sep 06, 2016 7:22 am

Re: Need help with lua? - LunaLua General Help

Postby RPG_Magician » Fri Jan 06, 2017 4:35 am

Can someone help me with disabling saving on the overworld, and replace it with talking to a npc inside a level to save?
I'm still struggling with the basics of Lunalua and any help would be appreciated.
Image Image

User avatar
DeMuZ
Bob-omb
Bob-omb
Posts: 37
Joined: Thu Aug 18, 2016 2:35 pm
Current Project: The Episode of Nonsense series

Re: Need help with lua? - LunaLua General Help

Postby DeMuZ » Fri Jan 06, 2017 8:17 am

RPG_Magician wrote:Can someone help me with disabling saving on the overworld, and replace it with talking to a npc inside a level to save?
I'm still struggling with the basics of Lunalua and any help would be appreciated.
The easiest way to make player unable to save is to make the game think all the time that he has been cheating.
Put this code into your overworld luna file. (lunaoverworld.lua in your episode folder)

Code: Select all

function onTick()
	Defines.player_hasCheated = true
end
I think I don't have to explain this one.
Put this code into your lvl files where you wanna save by talking. (lunadll.lua in your lvl folder)

Code: Select all

function onEvent(name)
	if name == "your event name" then
		Misc.saveGame()
	end
end
I hope I helped you. :)

User avatar
Angelus
Bit
Bit
Posts: 129
Joined: Tue Jun 21, 2016 9:38 am

Re: Need help with lua? - LunaLua General Help

Postby Angelus » Mon Jan 09, 2017 4:07 pm

Something went wrong with my code... I was trying to turn the Muncher block into an instant kill one (even if the player is big at the moment he touches it), but for some reason the game went mad. Take a look at the picture:
Spoiler: show
Image
As you can see, the player just keeps dying over and over after touching it until I have no choice but to close the editor. Here's the actual code:
Spoiler: show
for _,v in pairs (Block.get(109)) do
if v:collidesWith(player) == 1 then
player:kill();
What have I done wrong? :(

PixelPest
Link
Link
Posts: 7116
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Current Project: Boom Boom Evolution
Chat Username: PixelPest
Contact:

Re: Need help with lua? - LunaLua General Help

Postby PixelPest » Mon Jan 09, 2017 4:17 pm

You're killing the player over and over again which is why the effect keeps playing. Try only killing the player only if v:collidesWith(player) and player:mem (0x13E, FIELD_WORD) == 0

Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 8729
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Orphion Egamalenitar Osmos IV, Esq.

Re: Need help with lua? - LunaLua General Help

Postby Enjl » Mon Jan 09, 2017 4:22 pm

PixelPest wrote:You're killing the player over and over again which is why the effect keeps playing. Try only killing the player only if v:collidesWith(player) and player:mem (0x13E, FIELD_WORD) == 0
Uhh... Block:collidesWith returns an int between 0 and 4. In this if statement, it will alway be true.
Ideas are useless if you can't make them real.
Image

User avatar
Angelus
Bit
Bit
Posts: 129
Joined: Tue Jun 21, 2016 9:38 am

Re: Need help with lua? - LunaLua General Help

Postby Angelus » Mon Jan 09, 2017 4:32 pm

PixelPest wrote:You're killing the player over and over again which is why the effect keeps playing. Try only killing the player only if v:collidesWith(player) and player:mem (0x13E, FIELD_WORD) == 0
Oh thank you very much, it works beautifully! Although I would like to know, why was that needed in order to work?

PixelPest
Link
Link
Posts: 7116
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Current Project: Boom Boom Evolution
Chat Username: PixelPest
Contact:

Re: Need help with lua? - LunaLua General Help

Postby PixelPest » Mon Jan 09, 2017 9:15 pm

As I said before, you're killing the player over and over again. When the death effect is spawned, the position of the player's hitbox stays in the same spot as when it died; it doesn't follow the effect path. Because of this, the block collided with the player's hitbox over and over, so the player was killed over and over, thus spawning a new death effect each tick. The player memory check that I provided acts as a counter for the death animation. If it isn't playing, the field remains 0

User avatar
Angelus
Bit
Bit
Posts: 129
Joined: Tue Jun 21, 2016 9:38 am

Re: Need help with lua? - LunaLua General Help

Postby Angelus » Tue Jan 10, 2017 8:47 am

I see, thank you very much for this explanation.

User avatar
Angelus
Bit
Bit
Posts: 129
Joined: Tue Jun 21, 2016 9:38 am

Re: Need help with lua? - LunaLua General Help

Postby Angelus » Sun Jan 15, 2017 9:09 am

How do I set a paragoomba to chase through lua?

loop13
Eerie
Eerie
Posts: 980
Joined: Sun Apr 17, 2016 5:56 pm
Flair: I mainly play Celeste nowadays
Current Project: failing English IV
Chat Username: loop13uh

Re: Need help with lua? - LunaLua General Help

Postby loop13 » Sun Jan 15, 2017 2:52 pm

Angelus wrote:How do I set a paragoomba to chase through lua?
The brown Paragoomba can chase without LunaLUA, but I am guessing you are talking about the Red Paragoomba.
Hello, I make a lot of typos
specific people know my whereabouts though

my wifi is as useful as a brick

im more active on discord

:idea: I'm not (completely) dead; I rarely talk because I usually have nothin to say; I'll talk when I actually have a comment I want to make, or if someone asks me somethin...

nostalgia is a beautiful thing, isn't it?

anything before 2020 is most likely me being a weirdo or an idiot.

User avatar
Angelus
Bit
Bit
Posts: 129
Joined: Tue Jun 21, 2016 9:38 am

Re: Need help with lua? - LunaLua General Help

Postby Angelus » Sun Jan 15, 2017 3:30 pm

Jayce 777 wrote:
Angelus wrote:How do I set a paragoomba to chase through lua?
The brown Paragoomba can chase without LunaLUA, but I am guessing you are talking about the Red Paragoomba.
No, it's not that. What I meant is, how do I change a Paragoomba which is hovering left-right, to a chase state through Lua. I don't want it to be chasing since the moment it spawns, but to start chasing after a certain event instead. The thing is, I can't find any sort of thing chase-related in the NPC class to use into my code.

User avatar
Kevsoft
Ripper II
Ripper II
Posts: 374
Joined: Sun Jul 27, 2014 8:03 am

Re: Need help with lua? - LunaLua General Help

Postby Kevsoft » Sun Jan 15, 2017 4:23 pm

I might be wrong here, but I think the current movement property is saved in the ai values. You might want print out the values from .ai1 to .ai5
At least this is the case for cheep-cheep AI


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 2 guests