Page 1 of 1

[0.10.6][kovarex] game.canplaceentity+item-on-ground fails

Posted: Thu Aug 07, 2014 4:40 pm
by Rseding91
I'm not sure if this is expected or not but game.canplaceentity() always returns false when trying to check "item-on-ground".

Running this from the in-game console will always return false:

Code: Select all

game.player.print(tostring(game.canplaceentity({name = "item-on-ground", position = {game.player.position.x + 1, game.player.position.y}})))
It's simply checking if it can place an "item-on-ground" entity 1 tile to the right of the player.

Re: [0.10.6][kovarex] game.canplaceentity+item-on-ground fai

Posted: Fri Aug 08, 2014 7:12 am
by kovarex
You are right.

The problem is, that the game internally creates the object and test if it can be placed (as well as testing the special condition, like resources for mining drill, water for offshore pump etc.).
For the item-on-ground it needs to have additional parameter to know what kind of stack it should create.
It doesn't matter what kind of stack you put there now, but who knows, maybe it can change in the future.

The command is like this then, but note that it will only work in version 0.10.7+

Code: Select all

game.player.print(tostring(game.canplaceentity({name = "item-on-ground", position = {game.player.position.x + 1, game.player.position.y}, stack={name= "iron-plate"}})))
So it is solved for 0.10.7