Link Up Slash

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?
fern
Bot
Bot
Posts: 56
Joined: Sat Dec 02, 2017 8:59 pm

Link Up Slash

Postby fern » Sat Dec 09, 2017 4:15 pm

Is there a way I could make Link perform the up slash automatically.

I have this as a placeholder:

Code: Select all

function onTick()
	if player.jumpKeyPressing or player.altJumpKeyPressing or player.speedY ~= 0 then
		player.upKeyPressing = true
	end
end
It works, but it's not great when you're standing in front of signs/doors.

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

Re: Link Up Slash

Postby PixelPest » Sat Dec 09, 2017 7:40 pm

Look for a field here that has to do with it and try that maybe: http://wohlsoft.ru/pgewiki/SMBX_Player_Offsets

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

Re: Link Up Slash

Postby Emral » Sun Dec 10, 2017 12:42 pm

PixelPest wrote:Look for a field here that has to do with it and try that maybe: http://wohlsoft.ru/pgewiki/SMBX_Player_Offsets
Or try the correct spot.
Offset 0x44 is true/-1 when a player stands in front of the NPC and the little exclamation point appears. It does not distinguish between players, though, so what you want to do:

Code: Select all

function onTick()
	local npcBlock = false
	for k,v in ipairs(NPC.getIntersecting(player.x, player.y, player.x + player.width, player.y + player.height)) do
		if v.friendly and v:mem(0x44, FIELD_WORD) == -1 then
			npcBlock = true
			break
		end
	end
	if not (player:isGroundTouching() or npcBlock) then
		player.upKeyPressing = true
	end
end
Be careful: This will ALSO lock the up key when swimming and in fairy state. Refer to pixelpest's link for flags which you can use to exclude those scenarios.

fern
Bot
Bot
Posts: 56
Joined: Sat Dec 02, 2017 8:59 pm

Re: Link Up Slash

Postby fern » Sun Dec 10, 2017 5:08 pm

Enjl wrote:
PixelPest wrote:Look for a field here that has to do with it and try that maybe: http://wohlsoft.ru/pgewiki/SMBX_Player_Offsets
Or try the correct spot.
Offset 0x44 is true/-1 when a player stands in front of the NPC and the little exclamation point appears. It does not distinguish between players, though, so what you want to do:

Code: Select all

function onTick()
	local npcBlock = false
	for k,v in ipairs(NPC.getIntersecting(player.x, player.y, player.x + player.width, player.y + player.height)) do
		if v.friendly and v:mem(0x44, FIELD_WORD) == -1 then
			npcBlock = true
			break
		end
	end
	if not (player:isGroundTouching() or npcBlock) then
		player.upKeyPressing = true
	end
end
Be careful: This will ALSO lock the up key when swimming and in fairy state. Refer to pixelpest's link for flags which you can use to exclude those scenarios.
Thank you for this, just one question. Is there a simpler way, such as forcing a certain sprite? I tried player:setCurrentSpriteIndex(4,10, true) , but it didn't work.

The only reason I want him to press up is because I don't want him crouching when he jumps. People told me you can change animations with PGE Calibrator, but I can't get it to work, I was only able to resize the hitboxes.

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

Re: Link Up Slash

Postby Emral » Sun Dec 10, 2017 7:29 pm

"Pressing up" and "Not crouching" are two very different things. Can't you just set downKeyPressing to false when in midair?
If you mean the jump sprite you can set player:mem(0x114, FIELD_WORD, n) when jumping where n is the new frame you want it to be, though you do have to go through the PGE calibrator which is explained here.

fern
Bot
Bot
Posts: 56
Joined: Sat Dec 02, 2017 8:59 pm

Re: Link Up Slash

Postby fern » Sun Dec 10, 2017 7:52 pm

Enjl wrote:"Pressing up" and "Not crouching" are two very different things. Can't you just set downKeyPressing to false when in midair?
If you mean the jump sprite you can set player:mem(0x114, FIELD_WORD, n) when jumping where n is the new frame you want it to be, though you do have to go through the PGE calibrator which is explained here.
I've already tried setting player:mem(0x114, FIELD_WORD) to the jump sprite when player.speedY ~= 0 and it doesn't work. I've also tried using PGE Calibrator, but the animations don't load, only changing hitboxes works. Unless I'm doing something wrong. :?:

How exactly do you change the animations? Do you just set them up like this and save the INI? Because this is what I've been doing, and then I load them into Lua using Level.loadPlayerHitboxes(). Is there a different function for loading the animations?
Image

EDIT: I do have downKeyPressing set to false in midair to prevent the player from using the downward slash, but the crouching sprite is part of his jump animation.

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

Re: Link Up Slash

Postby Hoeloe » Sun Dec 10, 2017 8:01 pm

fern wrote: I've already tried setting player:mem(0x114, FIELD_WORD) to the jump sprite when player.speedY ~= 0 and it doesn't work.
Yes it does, but you have to do it from within onDraw, not onTick.

fern
Bot
Bot
Posts: 56
Joined: Sat Dec 02, 2017 8:59 pm

Re: Link Up Slash

Postby fern » Sun Dec 10, 2017 8:17 pm

Hoeloe wrote:
fern wrote: I've already tried setting player:mem(0x114, FIELD_WORD) to the jump sprite when player.speedY ~= 0 and it doesn't work.
Yes it does, but you have to do it from within onDraw, not onTick.
Ahhhhh, well that fixes the sprite, thank you! However, the character still uses the crouching hitbox. :(
I notice the sprite begins under the floor and when it gets to the top of the jump, it shifts up.
I tried setting player:mem(0x12E, FIELD_BOOL, false) but he still crouches in midair.

EDIT: Could someone tell me if I'm using PGE Calibrator correctly?

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

Re: Link Up Slash

Postby Hoeloe » Mon Dec 11, 2017 5:43 am

Try setting player.height.

fern
Bot
Bot
Posts: 56
Joined: Sat Dec 02, 2017 8:59 pm

Re: Link Up Slash

Postby fern » Mon Dec 11, 2017 7:57 pm

Hoeloe wrote:Try setting player.height.
I just tried this and it makes the character get stuck and slide under the floor. I also tried PlayerSettings.hitboxHeight and PlayerSettings.hitboxDuckHeight and they both seemed to have no effect.

I also tried PlayerSettings:setSpriteOffsetY() and it gave me the following error:
Image

Code: Select all

local function correctJump()
	if player.speedY ~= 0 and not player:isGroundTouching() and player:mem(0x114,FIELD_WORD) == 5 then
		player:mem(0x114, FIELD_WORD, 10)
		player:mem(0x12E, FIELD_BOOL, false)
		PlayerSettings:setSpriteOffsetY(5,5,11)
	end
end

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

Re: Link Up Slash

Postby Hoeloe » Mon Dec 11, 2017 8:23 pm

fern wrote:
Hoeloe wrote:Try setting player.height.
I just tried this and it makes the character get stuck and slide under the floor.
This is because the character's position is at the top left of the sprite. If you extend the height, it extends the hitbox down, meaning your hitbox goes into the floor. You need to not just extend the hitbox, but also move the player up by the same amount you extended it.

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

Re: Link Up Slash

Postby The0x539 » Mon Dec 11, 2017 8:30 pm

fern wrote:I also tried PlayerSettings:setSpriteOffsetY() and it gave me the following error:
Because you're trying to invoke setSpriteOffsetY on the PlayerSettings class. You're supposed to call it from a PlayerSettings object. You can get a PlayerSettings object by calling player:getCurrentPlayerSetting(). Stick the result into a variable and do stuff with it.

fern
Bot
Bot
Posts: 56
Joined: Sat Dec 02, 2017 8:59 pm

Re: Link Up Slash

Postby fern » Mon Dec 11, 2017 8:47 pm

Hoeloe wrote:
fern wrote:
Hoeloe wrote:Try setting player.height.
I just tried this and it makes the character get stuck and slide under the floor.
This is because the character's position is at the top left of the sprite. If you extend the height, it extends the hitbox down, meaning your hitbox goes into the floor. You need to not just extend the hitbox, but also move the player up by the same amount you extended it.
That's what I thought about doing, but I thought changing player.x onDraw() was gonna shoot him up in the air, but it worked, thank you!

fern
Bot
Bot
Posts: 56
Joined: Sat Dec 02, 2017 8:59 pm

Re: Link Up Slash

Postby fern » Mon Dec 11, 2017 8:48 pm

The0x539 wrote:
fern wrote:I also tried PlayerSettings:setSpriteOffsetY() and it gave me the following error:
Because you're trying to invoke setSpriteOffsetY on the PlayerSettings class. You're supposed to call it from a PlayerSettings object. You can get a PlayerSettings object by calling player:getCurrentPlayerSetting(). Stick the result into a variable and do stuff with it.
It's all good now, but this is good to know, thank you!


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 2 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari