[GUIDE] Level Creating and Modding

Place to post guides, observations, things related to modding that are not mods themselves.
Milaha
Inserter
Inserter
Posts: 23
Joined: Thu Feb 21, 2013 11:52 pm
Contact:

Re: Guide for Level Creating and Modding

Post by Milaha »

How hard would it be to add something to fill all of the turrets on the map with ammo at the start of the game? Looking at making a custom map now, but the prospect of manually filling all the enemy turrets is.... daunting.

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Guide for Level Creating and Modding

Post by kovarex »

You could do it using script, It would just search all entities at the start of the game.
It would just add the ammo to all turrets.
I can write the sample here if you want to.

Another thing would be to add copy/paste in the editor (even for larger structures, more buildings)

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Guide for Level Creating and Modding

Post by ficolas »

How do I assign items ID?
where is the file to do that?
Error in assignID "nameoftheitem" not recognized as id of item

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Guide for Level Creating and Modding

Post by kovarex »

Items are defines in data/prototype-definitions/items

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Guide for Level Creating and Modding

Post by ficolas »

Weird, I alredy placed the file there...

Edit: Capital letters... Fixed it.

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Guide for Level Creating and Modding

Post by ficolas »

Code: Select all

Content Title
Sprite "C:/Program
Files\Factorio\data\resources\icons/electric-furnace.png" couldn't be loaded
... why? D:

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Guide for Level Creating and Modding

Post by kovarex »

Do you have the file there?
(Every item needs to have icon picture)

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Unknown Key in gui

Post by FreeER »

perhaps this should be obvious but how do you fix the "Unknown key:"entity-name.iron-furnace" (on gui and when you hover over the entity)
As is fairly obvious I'm creating an iron furnace right now (currently is 2x as fast but is more wasteful on coal). I'd rather like for the name to show up as Iron Furnace rather than entity-name.whatever however :) So far that is my only problem

P.S. I didn't think this question warranted it's own topic so I figured I'd post in this one.
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Guide for Level Creating and Modding

Post by kovarex »

You need to add the value into locale/<language>/entity-name.cfg
<code>
iron-furnace=Iron furnace
</code>

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Guide for Level Creating and Modding

Post by ficolas »

yes, electric furnace.png is there, im sure :S

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Guide for Level Creating and Modding

Post by kovarex »

ficolas wrote:yes, electric furnace.png is there, im sure :S
Are you sure the file name is correct?, as you wrote electric furnace.png (with space).
Note, that it is also case sensitive.

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Guide for Level Creating and Modding

Post by ficolas »

the problem was that I named it electric-furnace.png, when I removed the .png it worked.

And also, for the lua stuff, for example, the "insert" function, what is the ussage?

insert( type,name,position,health,force,readablename,name,count)??

And how do I get the player position?
and to use onunitdied, I do
table=onunitdied() ?
and like so I can do
if table[name]==creeper then
and so?

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Guide for Level Creating and Modding

Post by kovarex »

ficolas wrote: And also, for the lua stuff, for example, the "insert" function, what is the ussage?

insert( type,name,position,health,force,readablename,name,count)??
You are probably reffering to the create entity function:
https://forums.factorio.com/wiki/inde ... eateentity
ficolas wrote: And how do I get the player position?

Code: Select all

  game.getplayer().position
ficolas wrote: and to use onunitdied, I do
table=onunitdied() ?
and like so I can do
if table[name]==creeper then
and so?
You can do:

Code: Select all

game.onevent = function(event)
  if event.name == "onunitdied" and 
     event.unit == "creeper" then
    game.getplayer().print("You just killed creeper hooray")
  end
end

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Guide for Level Creating and Modding

Post by ficolas »

No, im refering to the insert, to add items to an entity (I want to add items to the player), and can to make the code be for all the games, in freeplay, in campaigns, etc. I should place the lua script in the lualib?

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Guide for Level Creating and Modding

Post by kovarex »

It is not possible to create code for all types of games now.

Inserting example is in the lualib/freeplay.lua:

Code: Select all

game.getplayer().insert{name="iron-plate", count=8}
game.getplayer().insert{name="pistol", count=1}
game.getplayer().insert{name="basic-bullet-magazine", count=10}

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Guide for Level Creating and Modding

Post by ficolas »

Well, at least I can modify the freeplay.lua, but the freeplay.lua is ejecuted once or its beeing ejecuted all the time?
I added this to the end of the freeplay but it is not working

if event.name == "onunitdied" then
glob.player.insert{name = "small-alien-artifact", count = 1}
end

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: Guide for Level Creating and Modding

Post by rk84 »

ficolas wrote:Well, at least I can modify the freeplay.lua, but the freeplay.lua is ejecuted once or its beeing ejecuted all the time?
I added this to the end of the freeplay but it is not working

if event.name == "onunitdied" then
glob.player.insert{name = "small-alien-artifact", count = 1}
end
Is it inside game.onevent -function? Have you defined glob.player?
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Guide for Level Creating and Modding

Post by ficolas »

rk84 wrote:
ficolas wrote:Well, at least I can modify the freeplay.lua, but the freeplay.lua is ejecuted once or its beeing ejecuted all the time?
I added this to the end of the freeplay but it is not working

if event.name == "onunitdied" then
coun=math.random(1,5)
glob.player.insert{name = "small-alien-artifact", count = coun}
end
Is it inside game.onevent -function? Have you defined glob.player?
glob.player is alredy. defined in freeplay, and I didnt put it inside game.onevent function, just at the end of the code

Also, I dont know why but I cant make the shadows of furnaces in photoshop, how can I make them?
Last edited by ficolas on Wed Feb 27, 2013 11:09 pm, edited 1 time in total.

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Guide for Level Creating and Modding

Post by kovarex »

Yes, you need to put it inside the function


Btw, your code will add it directly to the player inventory, even if your turret (or anybody else) kills creeper on the other side of map.
You can also specify what entity drops when it is killed by adding this to the entity definition in json:

You can even add more values there, and all are applied, this example is from enemy spawner

Code: Select all

"loot":
    [
      {
        "item": "alien-artifact",
        "probability": 1,
        "count-min": 2,
        "count-max": 10
      }
    ],

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Guide for Level Creating and Modding

Post by ficolas »

Aaah that exists! lol
I tried adding a resource entity to the corpse, but that didnt work

Also, can I create a furnace-like machine (something that converts X into Y using Z) without modifing any non lua/json file?
I dont think I can do it with lua, because is almost only for events but maybe with the json creating a new type or something??

Post Reply

Return to “Modding discussion”