Dino Torch Direction

Need help with any SMBX game-related issues? Ask your questions here.

Moderator: Userbase Moderators

Turtle Guy
Buster Beetle
Buster Beetle
Posts: 88
Joined: Tue Sep 10, 2024 3:50 am
Flair: Spinysaurus
Pronouns: he/him/hem
Contact:

Dino Torch Direction

Postby Turtle Guy » Fri Sep 13, 2024 4:06 am

Hi. So I want to make a dino torch to "expel" it's fire only forward or upward. Tried the NPC config menu and item properties but both didn't had an option for that. I don't know any other method that edits NPCs
Image

deice
Rocky Wrench
Rocky Wrench
Posts: 637
Joined: Fri Jul 23, 2021 7:35 am

Re: Dino Torch Direction

Postby deice » Sat Sep 14, 2024 6:11 am

this has to be done through scripting. create a file called luna.lua in your level folder (if you only want to apply it to a single level) or in your episode folder (if you want it to apply to a whole episode), open it in a text editor, and place this inside:

Code: Select all

local FLAME_DIRECTION = 0 -- 0 will make it shoot sideways, change this to 1 to only make it shoot up

function onTick()
    for _, v in NPC.iterate(382) do
        v.ai3 = FLAME_DIRECTION
    end
end
note that this will apply to every dino torch inside a level/episode (depending on where you put the lua file)
if you want to apply it to a specific set of dino torches, that's going to be a little more complex. namely, for every dino torch you want to lock the direction of, you'll have to right click it, click "edit raw user data", and place this inside (again, 0 is for sideways, 1 is for up):

Code: Select all

{
    "flameDirection": 0
}
then, instead of the code in the lua file from earlier, you'd use something like this:

Code: Select all

function onTick()
    for _, v in NPC.iterate(382) do
        if(v.data._settings and v.data._settings.flameDirection) then
            v.ai3 = v.data._settings.flameDirection
        end
    end
end

Turtle Guy
Buster Beetle
Buster Beetle
Posts: 88
Joined: Tue Sep 10, 2024 3:50 am
Flair: Spinysaurus
Pronouns: he/him/hem
Contact:

Re: Dino Torch Direction

Postby Turtle Guy » Wed Sep 18, 2024 10:21 am

Sorry I'm a little confused. How i understand this is:
luna.lua file- bottom code
raw user data- middle code
is this how it works or am I missing something?

deice
Rocky Wrench
Rocky Wrench
Posts: 637
Joined: Fri Jul 23, 2021 7:35 am

Re: Dino Torch Direction

Postby deice » Fri Sep 27, 2024 2:07 pm

yes, that is how it works. are you having an issue while running the level?

mariobrigade2018
Eerie
Eerie
Posts: 719
Joined: Wed May 24, 2023 7:00 pm
Flair: OK in coding who dreams of making a Mario game
Pronouns: he/him

Re: Dino Torch Direction

Postby mariobrigade2018 » Fri Sep 27, 2024 2:59 pm

So that's what raw user data is for!

Turtle Guy
Buster Beetle
Buster Beetle
Posts: 88
Joined: Tue Sep 10, 2024 3:50 am
Flair: Spinysaurus
Pronouns: he/him/hem
Contact:

Re: Dino Torch Direction

Postby Turtle Guy » Mon Oct 14, 2024 9:36 am

deice wrote:
Fri Sep 27, 2024 2:07 pm
yes, that is how it works. are you having an issue while running the level?
Where do I put the code in the lua file?

deice
Rocky Wrench
Rocky Wrench
Posts: 637
Joined: Fri Jul 23, 2021 7:35 am

Re: Dino Torch Direction

Postby deice » Tue Oct 15, 2024 3:19 pm

Turtle Guy wrote:
Mon Oct 14, 2024 9:36 am
Where do I put the code in the lua file?
anywhere you want. unless the lua file already has an onTick method defined, in which case you'd simply take the code that's in the onTick i provided (for example):

Code: Select all

for _, v in NPC.iterate(382) do
    v.ai3 = FLAME_DIRECTION
end
and place it inside your existing onTick


Return to “Help and Support”

Who is online

Users browsing this forum: Ahrefs [Bot] and 3 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari