Cat & Penguin Powerups (help needed)

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?
Gaming-Dojo
Monty Mole
Monty Mole
Posts: 124
Joined: Mon Jan 25, 2016 9:20 am
Pronouns: he/him
Contact:

Cat & Penguin Powerups (help needed)

Postby Gaming-Dojo » Mon Aug 14, 2017 8:30 am

Hello Guys.
I tried to make apis for cat and penguin powerups as I think these would be cool to have in SMBX but they don't work without producing an error.
These are the codes:
Cat:

Code: Select all

local cat = {}

local climbTimer = 10

function cat.oninitAPI()
registerEvent(cat, "onTickEnd", "onTickEnd", false)
end

function cat.onTickEnd()
if player.powerup == 4 then
   if player:mem(0x14C,FIELD_WORD) ~= 0 or player:mem(0x148,FIELD_WORD) ~= 0 then
      player:mem(0x40,FIELD_WORD,3)
	  climbTimer = climbTimer - 1
	  end
   if climbTimer == 0 then
      player:mem(0x40,FIELD_WORD,2)
      end
	     if player:mem(0x14C,FIELD_WORD) == 0 and player:mem(0x148,FIELD_WORD) == 0 then
		    climbTimer = 10
		 end
	  end
end
	 
return cat
Penguin:

Code: Select all

local penguin = {}

local can_slide = false

function penguin.onInitAPI()
     registerEvent(penguin, "onTick", "onTick", false)
	 end


function onTick()
   if player:mem(0x16C,FIELD_WORD,1)  then 
   can_slide = true
   end

 if can_slide == true then
    if player.downkeypressing == true then 
	player:mem(0x3C,FIELD_WORD,1)
 end
    end
		Graphics.sprites.mario[7].img = Graphics.loadImage("penguin_mario.png")
   end

return penguin
Can you say me what's wrong with these codes.For the penguin, I suppose that there's an issue with recognizing when sliding's ready/with building up speed.
Greetings,yoshiegg.

Hoeloe
Phanto
Phanto
Posts: 1465
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Cat & Penguin Powerups (help needed)

Postby Hoeloe » Mon Aug 14, 2017 8:34 am

yoshiegg wrote:they don't work without producing an error
Please post the error message. The message exists for a reason, and it gives vital information about what the problem is.

That said, the cat powerup has one too many "end" statements.

It's recommended to format things like this:

Code: Select all

if(someCondition) then
    if(someOtherCondition) then
        --do some things
    end
end
Each open block should step in, each end should step back out again. This makes it very obvious if there's a mismatch somewhere, which would help avoid this issue.

Also don't use Graphics.loadImage inside onTick. Save it to a variable outside the function and use that.

Gaming-Dojo
Monty Mole
Monty Mole
Posts: 124
Joined: Mon Jan 25, 2016 9:20 am
Pronouns: he/him
Contact:

Re: Cat & Penguin Powerups (help needed)

Postby Gaming-Dojo » Mon Aug 14, 2017 8:55 am

There was really no error notification but the codes don't work as they should though.I now increased the timer of the cat as a climbing of 10 ticks wouldve been hardly recognizable.
So that's my cat code now:

Code: Select all

local cat = {}

local climbTimer = 300

function cat.oninitAPI()
registerEvent(cat, "onTickEnd", "onTickEnd", false)
end

function cat.onTick()
  if player.powerup == 4 then
   if player:mem(0x14C,FIELD_WORD) ~= 0 or player:mem(0x148,FIELD_WORD) ~= 0 then
      player:mem(0x40,FIELD_WORD,3)
	  climbTimer = climbTimer - 1
	  end
   if climbTimer == 0 then
      player:mem(0x40,FIELD_WORD,2)
   end
	     if player:mem(0x14C,FIELD_WORD) == 0 and player:mem(0x148,FIELD_WORD) == 0 then
		    climbTimer = 10
		 end
  end
end
	 
return cat

The0x539
Eerie
Eerie
Posts: 751
Joined: Fri Jan 22, 2016 8:02 pm

Re: Cat & Penguin Powerups (help needed)

Postby The0x539 » Mon Aug 14, 2017 8:59 am

I see you're trying to modify the player's "climbing state", as used by fences and vines and stuff. I don't feel like that's going to work, I feel like vanilla code will immediately detect that the player isn't anywhere near any climbable objects, and kick you right out of that state. Try just messing with speed or upward jumping force.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari