z_mirror/MouseOverConstruction

git clone https://git.raiguard.me/z_mirror/MouseOverConstruction

Caleb HeuerFix item duplication when constructing pyanodons wind turbines7c145b8

trunk
686 B28 linesraw
1local common = require("scripts.common")
2
3--- @param player LuaPlayer
4--- @param entity LuaEntity
5--- @return boolean
6return function(player, entity)
7  if not entity.valid then
8    return false
9  end
10
11  if not player.mod_settings["moc-enable-construction"].value then
12    return false
13  end
14
15  if entity.type ~= "entity-ghost" then
16    return false
17  end
18
19  local entity_prototype = entity.ghost_prototype --[[@as LuaEntityPrototype]]
20
21  if not common.check_can_place_entity(player, entity, entity_prototype) then
22    return false
23  end
24
25  local new_entity = common.build(player, entity, entity_prototype, entity.quality)
26
27  return new_entity and new_entity.valid and true or false
28end