Page 1 of 1

Undocumented game.canplaceentity changes?

Posted: Tue Mar 17, 2015 1:46 pm
by Degraine
So I'm trying to use game.canplaceentity to check whether an item-on-ground entity can be placed. It uses the name and position arguments, but when I test it, I always get this error: No such node (stack)

Which is confusing to me, since stack is never specified for canplaceentity (though it is for createentity on the next line). The name parameter is simply "item-on-ground", and the position table I pass to it is just a pair of xy coordinates. Even when I put a pair of coordinates directly into the table, like so:

Code: Select all

if game.canplaceentity{name = "item-on-ground", position = {x = -29.14, y = -9.75}} then
It still gives me that error. I'm at a loss here, the release notes and the wiki say nothing about a stack parameter for canplaceentity. Can anyone shed light on this?

And should I mark the item-on-ground as player/neutral force when it's created? Would it affect anything if I left it as the default (enemy) value?

Re: Undocumented game.canplaceentity changes?

Posted: Tue Mar 17, 2015 1:59 pm
by Choumiko
Here's what i use to drop one piece of raw wood on the ground (item being "raw-wood" and count = 1)

Code: Select all

      local position = game.findnoncollidingposition("item-on-ground", self.driver.position, 100, 0.5)
      game.createentity{name = "item-on-ground", position = position, stack = {name = item, count = count}}
Maybe canplaceentity needs to know the itemname even for item-on-ground?

As for the force, i guess enemy is fine

Re: Undocumented game.canplaceentity changes?

Posted: Thu Mar 19, 2015 4:52 am
by Degraine
Turns out you were right, it wanted to know the stack data as well. I've run into my old foe, however - a bug that for some reason reports true even when another item-on-ground is already occupying the space it's checking.

Re: Undocumented game.canplaceentity changes?

Posted: Fri Mar 20, 2015 4:30 pm
by Rseding91
Degraine wrote:Turns out you were right, it wanted to know the stack data as well. I've run into my old foe, however - a bug that for some reason reports true even when another item-on-ground is already occupying the space it's checking.
If that's true, then you should report it as that's a bug.

Re: Undocumented game.canplaceentity changes?

Posted: Sun Mar 22, 2015 6:45 am
by Degraine
Posted, thank you for the reminder.