Page 1 of 1

Droped items?

Posted: Fri Apr 26, 2013 4:27 pm
by ficolas
Can we spawn items on the floor by the code? I think this was added in 0.3, but im not sure how or if we can do it.

Re: Droped items?

Posted: Fri Apr 26, 2013 9:35 pm
by kovarex

Code: Select all

game.createentity{name="item-on-ground", position=game.player.character.position, stack={name="iron-plate"}}
I will work on the documentation for a whole day after the 0.4 release I promise :)

Re: Droped items?

Posted: Fri Apr 26, 2013 9:36 pm
by ficolas
:) haha thanx

In my opinion, the best way to documentate things, is to write them in a note on your desktop while you are making it, because I allways forget something.

Re: Droped items?

Posted: Fri Apr 26, 2013 10:03 pm
by ficolas
game.findentities doesnt find droped items :(
This makes transport belts be stuck when the code places more than one item at the same place :(

Re: Droped items?

Posted: Fri Apr 26, 2013 10:15 pm
by kovarex
ficolas wrote:game.findentities doesnt find droped items :(
This makes transport belts be stuck when the code places more than one item at the same place :(
I can check later, but I doubt it.
To avoid collisions, it is better (and faster) to use game.canplaceentity

Re: Droped items?

Posted: Fri Apr 26, 2013 10:16 pm
by ficolas
kovarex wrote:
ficolas wrote:game.findentities doesnt find droped items :(
This makes transport belts be stuck when the code places more than one item at the same place :(
I can check later, but I doubt it.
To avoid collisions, it is better (and faster) to use game.canplaceentity
But will that work with transport belts?

Re: Droped items?

Posted: Fri Apr 26, 2013 10:21 pm
by ficolas
Also, how do I use canplaceentity? I tried by using a table ({x,y}) and it says string expected, got nil.

How can you tell if you can place an entity with just a string? dont you need a table with the position and the name of the entity? :S

Re: Droped items?

Posted: Sun Apr 28, 2013 2:30 pm
by rk84
Same way you create entity.

Code: Select all

if game.canplaceentity({ name = "iron-chest", position = {0,0}}) then
	game.createentity({ name = "iron-chest", position = {0,0}, force=game.player.force})
end