Post here for help and support regarding LunaLua and SMBX2's libraries and features.
|
|
|
|
-
Giggs-Chan
- Rex
- Posts: 34
- Joined: Mon Aug 22, 2022 12:21 pm
-
Contact:
Postby Giggs-Chan » Fri Nov 18, 2022 10:29 am
For some reason, when you hit a block with a coin in it as Luigi, you don't get the coin right away. You have to jump on top of the block and collect it. Is there any way to fix this and why was this implemented in the first place?
|
|
|
|
|
|
|
|
|
-
deice
- Volcano Lotus
- Posts: 541
- Joined: Fri Jul 23, 2021 7:35 am
Postby deice » Fri Nov 18, 2022 12:42 pm
Giggs-Chan wrote: ↑Fri Nov 18, 2022 10:29 am
For some reason, when you hit a block with a coin in it as Luigi, you don't get the coin right away. You have to jump on top of the block and collect it. Is there any way to fix this and why was this implemented in the first place?
this same effect occurs with blocks that hold multiple coins as well. luigi or link hitting them will make all the coins pop out at once instead of requiring the player to hit it multiple times. it was probably implemented just cause redigit thought it would make for an interesting mechanic.
a way to patch this out could be:
Code: Select all function onBlockHit(eventObj, hitBlock, fromUpper, playerOrNil)
if(hitBlock.isValid and hitBlock.contentID < 1000 and playerOrNil and playerOrNil.character == CHARACTER_LUIGI) then
eventObj.cancelled = true
playerOrNil.character = CHARACTER_MARIO
hitBlock:hit(fromUpper, playerOrNil, hitBlock:mem(0x04, FIELD_WORD))
playerOrNil.character = CHARACTER_LUIGI
end
end
and while this is kinda hacky, i can't really think of a better solution personally as passing the same character to block:hit() would cause an infinite recursion, crashing the game.
|
|
|
|
|
|
|
|
|
-
Mushroom King
- Blooper
- Posts: 175
- Joined: Sun May 25, 2014 5:09 am
Postby Mushroom King » Sun Nov 20, 2022 3:56 pm
Worst, Luigi will not have the right amount if it's more than 21 coins, meaning he got less. More precisely, it is impossible for Luigi to get more than 21 coins in one block.
|
|
|
|
|
|
|
|
|
-
Giggs-Chan
- Rex
- Posts: 34
- Joined: Mon Aug 22, 2022 12:21 pm
-
Contact:
Postby Giggs-Chan » Mon Nov 21, 2022 8:08 am
Mushroom King wrote: ↑Sun Nov 20, 2022 3:56 pm
Worst, Luigi will not have the right amount if it's more than 21 coins, meaning he got less. More precisely, it is impossible for Luigi to get more than 21 coins in one block.
Probably cuz 9 plus 10 is 21 LOL
Added in 4 hours 59 minutes 17 seconds:
deice wrote: ↑Fri Nov 18, 2022 12:42 pm
Giggs-Chan wrote: ↑Fri Nov 18, 2022 10:29 am
For some reason, when you hit a block with a coin in it as Luigi, you don't get the coin right away. You have to jump on top of the block and collect it. Is there any way to fix this and why was this implemented in the first place?
this same effect occurs with blocks that hold multiple coins as well. luigi or link hitting them will make all the coins pop out at once instead of requiring the player to hit it multiple times. it was probably implemented just cause redigit thought it would make for an interesting mechanic.
a way to patch this out could be:
Code: Select all function onBlockHit(eventObj, hitBlock, fromUpper, playerOrNil)
if(hitBlock.isValid and hitBlock.contentID < 1000 and playerOrNil and playerOrNil.character == CHARACTER_LUIGI) then
eventObj.cancelled = true
playerOrNil.character = CHARACTER_MARIO
hitBlock:hit(fromUpper, playerOrNil, hitBlock:mem(0x04, FIELD_WORD))
playerOrNil.character = CHARACTER_LUIGI
end
end
and while this is kinda hacky, i can't really think of a better solution personally as passing the same character to block:hit() would cause an infinite recursion, crashing the game.
Could you please post a file with the Luigi coin fix in it?
|
|
|
|
|
|
|
|
|
-
deice
- Volcano Lotus
- Posts: 541
- Joined: Fri Jul 23, 2021 7:35 am
Postby deice » Tue Nov 22, 2022 12:48 pm
Giggs-Chan wrote: ↑Mon Nov 21, 2022 1:07 pm
Could you please post a file with the Luigi coin fix in it?
create a file in your episode folder (the same one that holds your world.wld file) if you want it to apply to your whole episode, or inside a level's custom folder (the one containing custom assets such as graphics) if it's necessary just for one level, name it "luna.lua" (without the quotation marks) and then copy and paste the code i posted inside it.
|
|
|
|
|
|
|
|
|
-
Giggs-Chan
- Rex
- Posts: 34
- Joined: Mon Aug 22, 2022 12:21 pm
-
Contact:
Postby Giggs-Chan » Tue Nov 22, 2022 1:31 pm
Alright, Thank you. I'm also waiting for Hatsune Blake to update the minimalist HUD.
Last edited by Giggs-Chan on Mon Nov 28, 2022 8:15 am, edited 1 time in total.
|
|
|
|
|
|
|
|
|
-
Giggs-Chan
- Rex
- Posts: 34
- Joined: Mon Aug 22, 2022 12:21 pm
-
Contact:
Postby Giggs-Chan » Sat Nov 26, 2022 8:27 pm
Ok, I put the code into the lunalua file, and this happened. What did I do wrong?
|
|
|
|
|
|
|
|
|
-
Marioman2007
- Lakitu
- Posts: 465
- Joined: Tue Aug 25, 2020 3:19 am
- Flair: Dr. Bones
- Pronouns: He/Him
Postby Marioman2007 » Sat Nov 26, 2022 10:23 pm
Try changing this line.
Code: Select all if(hitBlock.isValid and hitBlock.contentID < 1000 and playerOrNil and playerOrNil.character == CHARACTER_LUIGI) then
to
Code: Select all if(hitBlock.isValid and hitBlock.contentID >= 1 and hitBlock.contentID <= 99 and playerOrNil and playerOrNil.character == CHARACTER_LUIGI) then
The original code checks if a block has no npcs in it, this code checks if the block has coins in it since in this case we only want the coins to be affected.
|
|
|
|
|
|
|
|
|
-
Giggs-Chan
- Rex
- Posts: 34
- Joined: Mon Aug 22, 2022 12:21 pm
-
Contact:
Postby Giggs-Chan » Sun Nov 27, 2022 1:20 pm
I also figured out that Toad has the same problem with the blocks except this time, it's worse. It shows SMB2 coins. Do I just copy and paste and replace "LUIGI" with "TOAD"? If so, where?
|
|
|
|
|
|
|
|
|
-
deice
- Volcano Lotus
- Posts: 541
- Joined: Fri Jul 23, 2021 7:35 am
Postby deice » Sun Nov 27, 2022 2:05 pm
Giggs-Chan wrote: ↑Sun Nov 27, 2022 1:20 pm
I also figured out that Toad has the same problem with the blocks except this time, it's worse. It shows SMB2 coins. Do I just copy and paste and replace "LUIGI" with "TOAD"? If so, where?
if you want to prevent this effect completely, regardless of character, you can use the following code instead of the previously posted one:
Code: Select all function onBlockHit(eventObj, hitBlock, fromUpper, playerOrNil)
if(hitBlock.isValid and hitBlock.contentID > 0 and hitBlock.contentID < 100 and playerOrNil and (player.character ~= CHARACTER_PEACH and player.character ~= CHARACTER_MARIO)) then
eventObj.cancelled = true
local prevChar = player.character
playerOrNil.character = CHARACTER_MARIO
hitBlock:hit(fromUpper, playerOrNil, hitBlock:mem(0x04, FIELD_WORD))
playerOrNil.character = prevChar
end
end
Last edited by deice on Mon Nov 28, 2022 3:08 am, edited 2 times in total.
|
|
|
|
|
|
|
|
|
-
Marioman2007
- Lakitu
- Posts: 465
- Joined: Tue Aug 25, 2020 3:19 am
- Flair: Dr. Bones
- Pronouns: He/Him
Postby Marioman2007 » Sun Nov 27, 2022 9:06 pm
deice wrote: ↑Sun Nov 27, 2022 2:05 pm
if you also want to remove the feature where toad can hit a block multiple times at once, replace
with the number 1.
I think it's better to not specify the hit count, I remember running into a bug when I specified that as 1.
|
|
|
|
|
|
|
|
|
-
deice
- Volcano Lotus
- Posts: 541
- Joined: Fri Jul 23, 2021 7:35 am
Postby deice » Mon Nov 28, 2022 3:08 am
Marioman2007 wrote: ↑Sun Nov 27, 2022 9:06 pm
I think it's better to not specify the hit count, I remember running into a bug when I specified that as 1.
actually, (now that i've had time to test the code) it seems that memory offset 0x04 doesn't get updated before onBlockHit, meaning that the code I used already removes the feature by default and there's no need to change anything.
|
|
|
|
|
Return to “LunaLua Help”
Users browsing this forum: No registered users and 0 guests
|