Page 1 of 1

Muzzle fire animation / fuel deactivation

Posted: Sat Feb 25, 2017 11:04 am
by Odynius
Hey guys,

I'm just working on a mod that implements bunkers into Factorio and am pretty happy with it, except two points which you can maybe help me with:

Just one note, so you can follow me better: I used the "car" entity, so the player is able to enter the building and fire out of it. Of course it can't drive.

First problem: Can I adjust the Muzzle fire animatin? Right now it's in the middle of the texture, but ideally it should be at the windows, which would also depend on the direction of the target. (Model is the Terran bunker from SC2)

Second Problem: Even though i set the burner consumption to 0 it gives me the no fuel symbol, when there is none. This isn't to bad, because you just have to put some coal or whatever in it, and then it's gone, since it can't drive - therefore can't consume anything - but if I release it, I would like to make at as realistic as possible.

Thx guys!

Re: Muzzle fire animation / fuel deactivation

Posted: Sat Feb 25, 2017 1:33 pm
by Adil
Does it fire its own guns, or the player's ones?

Those triangle icons are the bane of the modding, you cannot really make them go away without inserting some dummy fuel\connecting to dummy power source.

Re: Muzzle fire animation / fuel deactivation

Posted: Sat Feb 25, 2017 4:53 pm
by Odynius
Thank you for your answer.

I guess, I'm just going to live with the fuel problem then.

It's using its own gun, just like the car does. I assume this might be somehow connected to the gun_turret node? I'm new to modding and didn't deal with that until now.

Re: Muzzle fire animation / fuel deactivation

Posted: Sat Feb 25, 2017 7:52 pm
by Adil
Well, car turret is defined in /data/items/gun.lua and its definition has field `projectile_creation_distance`. That probably will help with gunshots.

Re: Muzzle fire animation / fuel deactivation

Posted: Sat Feb 25, 2017 10:28 pm
by Odynius
Oh I should have taken a closer look. Gonna try it out. Thanks mate!

Re: Muzzle fire animation / fuel deactivation

Posted: Sat Feb 25, 2017 10:42 pm
by Nexela
Second Problem: Even though i set the burner consumption to 0 it gives me the no fuel symbol, when there is none. This isn't to bad, because you just have to put some coal or whatever in it, and then it's gone, since it can't drive - therefore can't consume anything - but if I release it, I would like to make at as realistic as possible.
Create an on build script that inserts 1 piece of coal into entity when placed


control.lua

Code: Select all

local function on_built(event)
    if event.created_entity,name == "my-entities-name" then
        event.created_entity.insert({name="coal", amount=1})
    end
end
script.on_event({defines.events.on_built_entity, defines.events.on_robot_built_entity}, on_built)

Re: Muzzle fire animation / fuel deactivation

Posted: Sun Feb 26, 2017 10:19 am
by Odynius
Okay, I got that fire animation going now!

And thanks to Nexela, I will try to implement that. I have never worked with "if, then"-functions though - do i just put it at the top of my entity.lua?

Re: Muzzle fire animation / fuel deactivation

Posted: Sun Feb 26, 2017 11:38 am
by Adil
The code he provided you, is self contained, you indeed can put it in any place of control.lua. The important part is the `script.on_event({defines.events.on_built_entity, defines.events.on_robot_built_entity}, on_built)`, which binds the defined function to relevant ingame events.

Re: Muzzle fire animation / fuel deactivation

Posted: Sun Feb 26, 2017 3:49 pm
by Odynius
All righty. God bless the factorio community!

EDIT: In case someone else wants to use Nexelas control.lua. I found a small typo, this one is working:

Code: Select all

local function on_built(event)
    if event.created_entity.name == "my-entities-name" then
        event.created_entity.insert({name="coal", amount=1})
    end
end
script.on_event({defines.events.on_built_entity, defines.events.on_robot_built_entity}, on_built)

Re: Muzzle fire animation / fuel deactivation

Posted: Wed Mar 08, 2017 10:21 pm
by Wybbw
****SOLVED***

hi I im making a gun mod and was wondering where u found the script animation for the muzzle fire. ive got tracers going and bullet casing dropping I just want that muzzle flash. I am new at this and deff not lazy and have been searching perhaps you could point me in the right direction.

Re: Muzzle fire animation / fuel deactivation

Posted: Wed Aug 16, 2017 10:34 pm
by foodfactorio
oh hi, if you did the terran building mod, nice work :)

there was a recent problem i found where i couldnt load the mod with another mod, and posted here with a screenshot of the error, if you happen to have a chance to help?
viewtopic.php?f=51&t=45001&start=820#p303008