Undocumented game.canplaceentity changes?

Place to get help with not working mods / modding interface.
Degraine
Filter Inserter
Filter Inserter
Posts: 282
Joined: Wed Aug 13, 2014 10:49 am
Contact:

Undocumented game.canplaceentity changes?

Post 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?
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: Undocumented game.canplaceentity changes?

Post 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
Degraine
Filter Inserter
Filter Inserter
Posts: 282
Joined: Wed Aug 13, 2014 10:49 am
Contact:

Re: Undocumented game.canplaceentity changes?

Post 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.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15875
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Undocumented game.canplaceentity changes?

Post 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.
If you want to get ahold of me I'm almost always on Discord.
Degraine
Filter Inserter
Filter Inserter
Posts: 282
Joined: Wed Aug 13, 2014 10:49 am
Contact:

Re: Undocumented game.canplaceentity changes?

Post by Degraine »

Posted, thank you for the reminder.
Post Reply

Return to “Modding help”