Edit: Oups, I accidently edited your post instead of writing mine ....
You asked how to create entity on the position where something died.
[GUIDE] Level Creating and Modding
Re: Guide for Level Creating and Modding
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...
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...
Re: Guide for Level Creating and Modding
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.
(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 ...
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
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 ...
Re: Guide for Level Creating and Modding
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)?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}
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
~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
Re: Guide for Level Creating and Modding
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?
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?
Re: Guide for Level Creating and Modding
This is only possible using the findentities function, but that would be slow if you had to search all the map.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"
I could think of having something like force.getallentitieswithname("underground-drill") ....
Not possible now, we could add it.ficolas wrote: And the rotation of that block?
It is possible, https://forums.factorio.com/wiki/inde ... #getenergyAnd if that block is receiving power?
Not possible now in lua.And make that block use power?
We will.I think that should work, but anyways, I hope you add an easier way
Re: Guide for Level Creating and Modding
how do I use the findentity function
maybe I can just scan an area near the player, so it is not that slow?
maybe I can just scan an area near the player, so it is not that slow?
Re: Guide for Level Creating and Modding
And do the maps have a seed or something? I need a random number that is the same for a map, allways