Page 1 of 1

Activate lua using powerups?

Posted: Fri Oct 14, 2016 7:05 am
by HazmatWarrior
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

Re: Activate lua using powerups?

Posted: Fri Oct 14, 2016 7:19 am
by PixelPest
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

Re: Activate lua using powerups?

Posted: Fri Oct 14, 2016 7:26 am
by HazmatWarrior
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?

Re: Activate lua using powerups?

Posted: Fri Oct 14, 2016 8:02 am
by PixelPest
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