Made sprites for a missile turret, how do I implement it in

Place to get help with not working mods / modding interface.
Post Reply
YorikNoir
Manual Inserter
Manual Inserter
Posts: 1
Joined: Tue Nov 11, 2014 3:13 pm
Contact:

Made sprites for a missile turret, how do I implement it in

Post by YorikNoir »

Hi, first time posting in the forum!

I created some sprites for a missile turret. I've looked at editing the files myself but I'm stumped. Can someone please point out to me how to successfully implement it into the game?



Here's the sprite sheets & icon:
http://www.filedropper.com/missile-turret

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Made sprites for a missile turret, how do I implement it

Post by bobingabout »

For starters, you should make a mod, you shouldn't edit base game files directly, mostly due to updating the game.
not only would your modifications likely prevent the automatic update, but it would also be lost when you did update.

so a mod is the way to go.


For a rocket turret, I would recomend using the gun turret as a base, so, first we need to bring up the code for the gun turret. We should also provide ourselves with a platform for entering the new code, so create a new text document. Right click somewhere where you want to create the file, then point to new, then click text document, rename it something along the lines of "missile-turret.lua", if you're doing this, you probably want windows to show file extensions, otherwise you'll end up with "missile-turret.lua.txt". if you don't want to, or know how to turn this option on, you can always just use notepad to save the file with name "missile-turret.lua", and it should use .lua as the file extension.

Once you have this lua file, open it in a simple text editor, nothing fancy like microsoft word, they don't like saving in ansi/ascii or utf8, it likes to use it's own file format with formatting (font styles etc) or whatever, which is a format that Factorio won't be able to read. I would recomend Wordpad over notepad, because it is friendlier to work with, but notepad will more easilly give you the file format you require.


Okay, lets start gathering the code we need to edit.
open up data\base\prototypes\item to begin with, and open the file demo-turret.lua, this will contain the item for the gun turret, and only the gun turret, copy the whole thing to your new file. change the tags "name=" and "place_result" to read missile-turret instead of gun-turret, you can also change the order tag too, but I'd leave the icon for now.

open up data\base\prototypes\recipe\demo-turret.lua, copy everything in there to your new file too, make the same changes to this code, and change the ingredients if you want. you might want to comment out enabled=false with a -- comment line to make it easier to obtain the item, but a normal route would be to make it unlock via a research.

open up data\base\prototypes\entity\demo-turrets.lua (yes, it has an S on the end, where the other 2 didn't) and copy the section from the { before the type="ammo-turret", and "name=gun-turret" tags down to the }, line before "type=corpse", paste this into your own file. make sure it has a data:extend({ line before, and }) line after this section, as the other 2 sections we copied have.
Change "gun-turret" to "missile-turret" on the "name=" line and the result in the minable line.

Now we currently have an item named missile turret, that is clone of the gun turret. this is where it starts to get a little harder.

Go down to the prepared_animation tag, and within the curley brackets that follow, you need to update the information to match your own graphics, width and height will be easiest, these are the dimentions of a single frame in your sprite sheet, this wants to be the area of the whole frame, so from top left corner, to the top left corner of the next frame to the right for the width, and top left corner to the top left corner of the frame below for the height. Filename will depend on a few things, such as the name of the mod you create, and the directory structure of your mod, but the filename wants to be that of your "ready to fire" turret.

the "gun_turret_extention" value is a function at the very top of the demo-turrets.lua file, you can copy this section into your file, and edit accordingly, making sure you edit your turret code to point to the new function.


Next, open up data\base\prototypes\item\gun.lua and find the rocket launcher. Copy the "attack_parameters" section over the top of the attack_parameters section of your turret, this should make it fire missiles instead of being a gun.

The next phase is to actually make this into a mod, which means it nees a folder inside tthe mods folder, including the info.json file, and data.lua that includes the line "requires("missile-turret")", including any directory information within your mod for the location of missile-turret.lua.


This should definitely give you a head start, but if you need any further information, just ask.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

User avatar
MaxAstro
Burner Inserter
Burner Inserter
Posts: 13
Joined: Sun Nov 09, 2014 7:53 am
Contact:

Re: Made sprites for a missile turret, how do I implement it

Post by MaxAstro »

Nice missile turret sprite, BTW. Do you mind if I use it?
"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark Twain

"True friends stab you in the front." - Oscar Wilde

Post Reply

Return to “Modding help”