Request: Lua code to stop Super Mushroom going left

Post here for help and support regarding LunaLua and SMBX2's libraries and features.

Moderator: Userbase Moderators

JustInPassing
Koopa
Koopa
Posts: 17
Joined: Fri Apr 14, 2017 7:55 am

Request: Lua code to stop Super Mushroom going left

Postby JustInPassing » Wed Feb 12, 2020 11:17 am

Hi, so I'm making a SMB1-themed level. I was wondering if there is any Lua code to stop the Super Mushroom going left when emerging from its ? block if you're facing right?

Thank you for reading.

Murphmario
2025 Egg Hunter
2025 Egg Hunter
Posts: 2389
Joined: Fri Dec 20, 2013 7:07 pm
Pronouns: he/him

Re: Request: Lua code to stop Super Mushroom going left

Postby Murphmario » Wed Feb 12, 2020 12:49 pm

You could probably call something when a Super Mushroom is spawned to force it to go right.

Cedur
Link
Link
Posts: 7073
Joined: Tue Jun 28, 2016 10:14 am
Flair: I'm gone, for chess and minesweeper
Pronouns: he/him

Re: Request: Lua code to stop Super Mushroom going left

Postby Cedur » Wed Feb 12, 2020 12:56 pm

So you always want to make it go right, or you don't want it to move at all? (the latter is trivial without Lua)

JustInPassing
Koopa
Koopa
Posts: 17
Joined: Fri Apr 14, 2017 7:55 am

Re: Request: Lua code to stop Super Mushroom going left

Postby JustInPassing » Wed Feb 12, 2020 12:58 pm

Cedur wrote:
Wed Feb 12, 2020 12:56 pm
So you always want to make it go right, or you don't want it to move at all? (the latter is trivial without Lua)
The former i.e. always go right.

Cedur
Link
Link
Posts: 7073
Joined: Tue Jun 28, 2016 10:14 am
Flair: I'm gone, for chess and minesweeper
Pronouns: he/him

Re: Request: Lua code to stop Super Mushroom going left

Postby Cedur » Wed Feb 12, 2020 1:11 pm

Would it be a problem to just place an invisible block left to it?

JustInPassing
Koopa
Koopa
Posts: 17
Joined: Fri Apr 14, 2017 7:55 am

Re: Request: Lua code to stop Super Mushroom going left

Postby JustInPassing » Thu Feb 13, 2020 12:24 am

Cedur wrote:
Wed Feb 12, 2020 1:11 pm
Would it be a problem to just place an invisible block left to it?
I've tried, and unless I'm doing something wrong, it would be a problem.

Hammerless Penguin
Snifit
Snifit
Posts: 203
Joined: Sat Sep 22, 2018 6:17 am
Flair: Just kicking that kirby to the curb!
Contact:

Re: Request: Lua code to stop Super Mushroom going left

Postby Hammerless Penguin » Thu Feb 13, 2020 1:18 am

Try this out.

Make a New layer for the block that contains the mushroom
Then make an event that triggers an invisible block to spawn on the left side for a short second when the block is hit.
When the event is finished go to options of the block that contains the mushroom and make sure the event is activated when Mario hits it. If the mushroom still moves to the left then make sure the time that the invisible block spawns is set to be longer.

It should work, if not then perhaps the only solution is to find out something with Luna lua or even a more simple solution is to just edit the configuration of the mushroom and set the speed to 0. The mushroom won’t move at all though.

JustInPassing
Koopa
Koopa
Posts: 17
Joined: Fri Apr 14, 2017 7:55 am

Re: Request: Lua code to stop Super Mushroom going left

Postby JustInPassing » Thu Feb 13, 2020 2:50 am

Hammerless Penguin wrote:
Thu Feb 13, 2020 1:18 am
Try this out.

Make a New layer for the block that contains the mushroom
Then make an event that triggers an invisible block to spawn on the left side for a short second when the block is hit.
When the event is finished go to options of the block that contains the mushroom and make sure the event is activated when Mario hits it. If the mushroom still moves to the left then make sure the time that the invisible block spawns is set to be longer.

It should work, if not then perhaps the only solution is to find out something with Luna lua or even a more simple solution is to just edit the configuration of the mushroom and set the speed to 0. The mushroom won’t move at all though.
Thanks, I got it to work with your help. Here is what I did, for future prosperity.

1) Create a Layer called "Invisible Blocks" (the name doesn't really matter, but makes things clear).
2) Create an Event called "Power-Ups - Hit" (again, name doesn't really matter but makes things clear).
3) In the Layers window, select "Invisible Blocks" and place the invisible block left of where the power-up will spawn.
4) In the Events window, select "Level - Start", select "Layer visibility" and hide the "Invisible Blocks" layer. Preferably, check "Disable smoke transition".
5) Select "Power-Ups - Hit" in the Events window, select "Layer visibility and show the "Invisible Blocks" layer. "Disable smoke transition" is preferable here too.
6) With "Power-Ups - Hit" selected in the Events window, select "Trigger Event" and select "Level - Start" with a minimum delay of 0.5 (0.4 or less will make the invisible blocks disappear before the Super/1-up Mushroom fully spawns).
7) Finally, place your power-up ? Block with the "Power-Ups - Hit" selected as a hit event in the ? Block's properties.

Do you want to hear what I said again?

Cedur
Link
Link
Posts: 7073
Joined: Tue Jun 28, 2016 10:14 am
Flair: I'm gone, for chess and minesweeper
Pronouns: he/him

Re: Request: Lua code to stop Super Mushroom going left

Postby Cedur » Thu Feb 13, 2020 3:51 am

Hammerless Penguin wrote:
Thu Feb 13, 2020 1:18 am
Try this out.

Make a New layer for the block that contains the mushroom
Then make an event that triggers an invisible block to spawn on the left side for a short second when the block is hit.
When the event is finished go to options of the block that contains the mushroom and make sure the event is activated when Mario hits it. If the mushroom still moves to the left then make sure the time that the invisible block spawns is set to be longer.

It should work, if not then perhaps the only solution is to find out something with Luna lua or even a more simple solution is to just edit the configuration of the mushroom and set the speed to 0. The mushroom won’t move at all though.

Well, now that I think of it, that's quite smart.

IAmPlayer
Volcano Lotus
Volcano Lotus
Posts: 560
Joined: Sun May 21, 2017 3:36 am
Flair: I'm a hellspawn.
Pronouns: he/him
Contact:

Re: Request: Lua code to stop Super Mushroom going left

Postby IAmPlayer » Thu Feb 13, 2020 5:52 am

I looked through my codes, and sure enough, I have it. Someone asked this before to me, so you can reuse this.

Code: Select all

local mushroom = {9, 184, 185}

function onTick()
    for k,v in ipairs(NPC.get(mushroom)) do
        if v:mem(0x138, FIELD_WORD) == 1 then
            v.direction = DIR_RIGHT
        end
    end
end


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari