How do I make a Thwimp constantly jump forward instead of back and forth?

Post here for help and support regarding LunaLua and SMBX2's libraries and features.
Chilly14
Snifit
Snifit
Posts: 230
Joined: Thu Jul 18, 2019 10:28 pm
Flair: wash your hands and stay at home
Pronouns: he/him

How do I make a Thwimp constantly jump forward instead of back and forth?

Postby Chilly14 » Mon Jul 22, 2019 10:33 pm

I've been trying to figure this out, but I haven't yet. Any answers...? ',:(

Maxjacinto2
Bit
Bit
Posts: 73
Joined: Sat Dec 28, 2013 5:21 pm
Flair: YNWA

Re: How do I make a Thwimp constantly jump forward instead of back and forth?

Postby Maxjacinto2 » Tue Jul 23, 2019 1:26 am

I know this is a Lua-oriented question, but the easiest way to make this is to simply replace the Fighter Fly's graphics. :)

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

Re: How do I make a Thwimp constantly jump forward instead of back and forth?

Postby Enjl » Tue Jul 23, 2019 4:27 am

Copy npc-301.lua into the level folder, rename it to npc-751.lua, copy the sprite and ini file (data/pge/config/smbx2/items/npc/npc-301.ini) as well, and do the same. Go into npc-751.lua and remove the data.direction field and everything related to setting it or retrieving information from it. NPC-751 is now a copy of thwimp which doesn't know what turning is.

Chilly14
Snifit
Snifit
Posts: 230
Joined: Thu Jul 18, 2019 10:28 pm
Flair: wash your hands and stay at home
Pronouns: he/him

Re: How do I make a Thwimp constantly jump forward instead of back and forth?

Postby Chilly14 » Tue Jul 23, 2019 7:26 am

Thank you!

Added in 12 minutes 36 seconds:
Okay, it's working, for the most part, but somehow the Thwimp never stops jumping forward even after hitting a wall. Plus, even if it is set to go right, it still jumps left. How do I fix this?

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

Re: How do I make a Thwimp constantly jump forward instead of back and forth?

Postby Enjl » Tue Jul 23, 2019 8:11 am

Chilly14 wrote:
Tue Jul 23, 2019 7:39 am
Thank you!

Added in 12 minutes 36 seconds:
Okay, it's working, for the most part, but somehow the Thwimp never stops jumping forward even after hitting a wall. Plus, even if it is set to go right, it still jumps left. How do I fix this?
You probably removed the data.direction from the line where it sets the speedX value when a jump begins. I don't know exactly what integer it is, so here's an example on how it MIGHT look vs how it SHOULD look:
v.speedX = 2
should be
v.speedX = 2 * v.direction

v.direction automatically changes when the thwimp hits a wall.

If I'm talking utter nonsense here, please share your new thwimp file on https://hastebin.com/

Chilly14
Snifit
Snifit
Posts: 230
Joined: Thu Jul 18, 2019 10:28 pm
Flair: wash your hands and stay at home
Pronouns: he/him

Re: How do I make a Thwimp constantly jump forward instead of back and forth?

Postby Chilly14 » Tue Jul 23, 2019 8:26 am


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

Re: How do I make a Thwimp constantly jump forward instead of back and forth?

Postby Enjl » Tue Jul 23, 2019 9:29 am

Chilly14 wrote:
Tue Jul 23, 2019 8:26 am
Here: https://hastebin.com/obipoyefep.rb
Here's the line:
v.speedX = data.thwimpJumpSpeed * data.thwimpJumpDirection
data.thwimpJumpDirection needs to be replaced with v.direction.

Chilly14
Snifit
Snifit
Posts: 230
Joined: Thu Jul 18, 2019 10:28 pm
Flair: wash your hands and stay at home
Pronouns: he/him

Re: How do I make a Thwimp constantly jump forward instead of back and forth?

Postby Chilly14 » Tue Jul 23, 2019 10:38 am

Oh, thank you! I finally got it to work properly.


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 2 guests