Page 3 of 3
Re: Guide for Level Creating and Modding
Posted: Wed Feb 27, 2013 11:10 pm
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.
Re: Guide for Level Creating and Modding
Posted: Wed Feb 27, 2013 11:44 pm
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...
Re: Guide for Level Creating and Modding
Posted: Thu Feb 28, 2013 12:23 am
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 ...
Re: Guide for Level Creating and Modding
Posted: Thu Feb 28, 2013 3:39 am
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)
Re: Guide for Level Creating and Modding
Posted: Thu Feb 28, 2013 10:52 am
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?
Re: Guide for Level Creating and Modding
Posted: Thu Feb 28, 2013 12:05 pm
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.
Re: Guide for Level Creating and Modding
Posted: Thu Feb 28, 2013 12:46 pm
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?
Re: Guide for Level Creating and Modding
Posted: Thu Feb 28, 2013 2:52 pm
by ficolas
And do the maps have a seed or something? I need a random number that is the same for a map, allways