Activate lua using powerups?

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?
HazmatWarrior
Goomba
Goomba
Posts: 2
Joined: Thu Sep 22, 2016 10:19 am

Activate lua using powerups?

Postby HazmatWarrior » Fri Oct 14, 2016 7:05 am

Is there a way to activate a lua script by picking up a powerup, and then removes the original powerup's code?

For example, Tanooki Suit = Double jumping and no original tanooki effects

or

Fire Mario = Throws bowser's fireballs

Thanks in advance

PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: Activate lua using powerups?

Postby PixelPest » Fri Oct 14, 2016 7:19 am

Yes. You would basically have an onTick() event and check for the int power-up state of player.powerup. For example, to check if the player has a fire flower:

Code: Select all

function onTick()
   if player.powerup == 3 then
      --do whatever you want when the player collects a fire flower
   end
end 
There's no shortcut yet to clear a power-up state, however you could for fire flower transform the player fireball into Bowser's fireball, or add Bowser's fireball GFX to the player fireball and just constantly set its y-speed to 0 or some number just smaller than that if gravity is affecting it. For the Tanooki there would be some way you'd need to come up with to neutralize the current effects

HazmatWarrior
Goomba
Goomba
Posts: 2
Joined: Thu Sep 22, 2016 10:19 am

Re: Activate lua using powerups?

Postby HazmatWarrior » Fri Oct 14, 2016 7:26 am

PixelPest wrote:Yes. You would basically have an onTick() event and check for the int power-up state of player.powerup. For example, to check if the player has a fire flower:

Code: Select all

function onTick()
   if player.powerup == 3 then
      --do whatever you want when the player collects a fire flower
   end
end 
There's no shortcut yet to clear a power-up state, however you could for fire flower transform the player fireball into Bowser's fireball, or add Bowser's fireball GFX to the player fireball and just constantly set its y-speed to 0 or some number just smaller than that if gravity is affecting it. For the Tanooki there would be some way you'd need to come up with to neutralize the current effects

How would i change a player fireball to another npc?

PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: Activate lua using powerups?

Postby PixelPest » Fri Oct 14, 2016 8:02 am

In 2.0 Beta 3 there is an API called classExpander.lua which has an NPC:transform function. You would have to use NPC.get() in a for loop within an onTick() event after loading the API. Basically:

Code: Select all

local classExpander = API.load("classExpander");

function onTick()
   if player.powerup == 3 then
      for _, v in pairs(NPC.get(13)) do
         v:transform(282) --NPC:transform(newID, centered)
      end
   end
end 


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari