Page 2 of 3

Re: Guide for Level Creating and Modding

Posted: Sun Feb 24, 2013 2:02 pm
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.

Re: Guide for Level Creating and Modding

Posted: Sun Feb 24, 2013 7:11 pm
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)

Re: Guide for Level Creating and Modding

Posted: Mon Feb 25, 2013 10:56 pm
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

Re: Guide for Level Creating and Modding

Posted: Mon Feb 25, 2013 11:47 pm
by kovarex
Items are defines in data/prototype-definitions/items

Re: Guide for Level Creating and Modding

Posted: Tue Feb 26, 2013 3:11 pm
by ficolas
Weird, I alredy placed the file there...

Edit: Capital letters... Fixed it.

Re: Guide for Level Creating and Modding

Posted: Tue Feb 26, 2013 11:16 pm
by ficolas

Code: Select all

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

Re: Guide for Level Creating and Modding

Posted: Wed Feb 27, 2013 12:52 am
by kovarex
Do you have the file there?
(Every item needs to have icon picture)

Unknown Key in gui

Posted: Wed Feb 27, 2013 8:58 am
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.

Re: Guide for Level Creating and Modding

Posted: Wed Feb 27, 2013 10:13 am
by kovarex
You need to add the value into locale/<language>/entity-name.cfg
<code>
iron-furnace=Iron furnace
</code>

Re: Guide for Level Creating and Modding

Posted: Wed Feb 27, 2013 2:26 pm
by ficolas
yes, electric furnace.png is there, im sure :S

Re: Guide for Level Creating and Modding

Posted: Wed Feb 27, 2013 3:00 pm
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.

Re: Guide for Level Creating and Modding

Posted: Wed Feb 27, 2013 8:33 pm
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?

Re: Guide for Level Creating and Modding

Posted: Wed Feb 27, 2013 8:45 pm
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

Re: Guide for Level Creating and Modding

Posted: Wed Feb 27, 2013 9:19 pm
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?

Re: Guide for Level Creating and Modding

Posted: Wed Feb 27, 2013 9:59 pm
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}

Re: Guide for Level Creating and Modding

Posted: Wed Feb 27, 2013 10:12 pm
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

Re: Guide for Level Creating and Modding

Posted: Wed Feb 27, 2013 10:47 pm
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?

Re: Guide for Level Creating and Modding

Posted: Wed Feb 27, 2013 10:56 pm
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?

Re: Guide for Level Creating and Modding

Posted: Wed Feb 27, 2013 11:02 pm
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
      }
    ],

Re: Guide for Level Creating and Modding

Posted: Wed Feb 27, 2013 11:07 pm
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??