[GUIDE] Level Creating and Modding

Place to post guides, observations, things related to modding that are not mods themselves.
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 »

Edit: Oups, I accidently edited your post instead of writing mine ....
You asked how to create entity on the position where something died.

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 »

Sorry for double post, if I write more than 15 lines I need to start another comment because im using the mobile phone.

That will prevent farming the small artifacts (100 small artifacts=one alien artifact), and if more than 50 creepers are killed in 10 mins (I may change the numbers later), any small artifact will be droped, so grinding will be less efficient at least...

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 (Check https://forums.factorio.com/wiki/inde ... onunitdied)
The event also contains unit, that is handler to the just died unit, so you can use it's position.

Code: Select all

  if event.name == "onunitdied" then -- Just a note, use "==" not "="
    killCount=killCount+1
    if killCount<=50 then -- then is mandatory
      game.createentity(name="big-tree", position=event.unit.position)
    end
  end
(I didn't test it)

Note, that lot of entities can't be created this way, and we must allow it somehow.
This includes the item-on-ground entity, it is now not possible to specify the item name, so it is not possible to create it.
But you could create chests containing the item, but that is probably not what you want :)

P.S. I will try to think about some general way to create more specialised entities in the meantime ...

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

Re: Guide for Level Creating and Modding

Post by FreeER »

kovarex wrote: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}
are you saying you can't create code for scenarios (because obviously you can for story missions and you just pointed out an example for freeplay)?
because if you are, I copied the control.lua from one of the story folders and modified it to give me the items I wanted in my custom scenario (I'm using one to make it easy to test the mod effects) that way i start with coal and iron ore and such without having to open a chest and grab it. I would assume that you could also use the same code in control.lua as you can in the other lua documents.

of course if you meant something else you can ignore this post lol
btw, i noticed that if you are in a custom scenario and you hit 'replay game' in the menu it simply opens up the load save menu (you can't actually restart the current scenario without quitting and going back through play>custom scenario)
<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

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, he is saying that you cant create code for freeplay, scenarios and campaign at the same time.
Another thing I want to know, can I get the postion of all entityes with name "underground-drill"
And the rotation of that block?
And if that block is receiving power?
And make that block use power?

And I figured a shitty way of making items be droped to the ground, I think:
-create an unit at the position
-remove all the unit's health, the unit will have the " loot" with the item you need to drop.

I think that should work, but anyways, I hope you add an easier way :)
And another thing, to make block items names, we need to edit language files or we can create language files?

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:No, he is saying that you cant create code for freeplay, scenarios and campaign at the same time.
Another thing I want to know, can I get the postion of all entityes with name "underground-drill"
This is only possible using the findentities function, but that would be slow if you had to search all the map.
I could think of having something like force.getallentitieswithname("underground-drill") ....
ficolas wrote: And the rotation of that block?
Not possible now, we could add it.
And if that block is receiving power?
It is possible, https://forums.factorio.com/wiki/inde ... #getenergy
And make that block use power?
Not possible now in lua.
I think that should work, but anyways, I hope you add an easier way :)
We will.

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 use the findentity function
maybe I can just scan an area near the player, so it is not that slow?

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 »

And do the maps have a seed or something? I need a random number that is the same for a map, allways

Post Reply

Return to “Modding discussion”