Page 1 of 1

Dino Torch Direction

Posted: Fri Sep 13, 2024 4:06 am
by Turtle Guy
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

Re: Dino Torch Direction

Posted: Sat Sep 14, 2024 6:11 am
by deice
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

Re: Dino Torch Direction

Posted: Wed Sep 18, 2024 10:21 am
by Turtle Guy
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?

Re: Dino Torch Direction

Posted: Fri Sep 27, 2024 2:07 pm
by deice
yes, that is how it works. are you having an issue while running the level?

Re: Dino Torch Direction

Posted: Fri Sep 27, 2024 2:59 pm
by mariobrigade2018
So that's what raw user data is for!

Re: Dino Torch Direction

Posted: Mon Oct 14, 2024 9:36 am
by Turtle Guy
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?

Re: Dino Torch Direction

Posted: Tue Oct 15, 2024 3:19 pm
by deice
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