Need help with lua? - LunaLua General Help

This is the place for discussion and support for LunaLua and related modifications and libraries.

Moderator: Userbase Moderators

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?
Angelus
Tweeter
Tweeter
Posts: 132
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: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
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

Angelus
Tweeter
Tweeter
Posts: 132
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.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9890
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Need help with lua? - LunaLua General Help

Postby Emral » 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.

TUWAN
Flurry
Flurry
Posts: 181
Joined: Sun Mar 06, 2016 11:50 am
Pronouns: she/her

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?

PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
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

Angelus
Tweeter
Tweeter
Posts: 132
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.

RPG_Magician
Snifit
Snifit
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.

DeMuZ
Fighter Fly
Fighter Fly
Posts: 37
Joined: Thu Aug 18, 2016 2:35 pm

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. :)

Angelus
Tweeter
Tweeter
Posts: 132
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: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
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

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9890
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Need help with lua? - LunaLua General Help

Postby Emral » 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.

Angelus
Tweeter
Tweeter
Posts: 132
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: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
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

Angelus
Tweeter
Tweeter
Posts: 132
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.

Angelus
Tweeter
Tweeter
Posts: 132
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?

loop
Ninji
Ninji
Posts: 984
Joined: Sun Apr 17, 2016 5:56 pm
Flair: i may be dumb but im not stupid!
Pronouns: he/him/they

Re: Need help with lua? - LunaLua General Help

Postby loop » 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.

Angelus
Tweeter
Tweeter
Posts: 132
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.

Kevsoft
Ripper II
Ripper II
Posts: 375
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

Angelus
Tweeter
Tweeter
Posts: 132
Joined: Tue Jun 21, 2016 9:38 am

Re: Need help with lua? - LunaLua General Help

Postby Angelus » Sun Jan 15, 2017 5:37 pm

That's very useful, thank you.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari