Disable placement of specific structures
Disable placement of specific structures
Is it possible to disable placement of structures like laser towers without preventing laser tower tech or turrets?
Same goes for solar panels.
Same goes for solar panels.
Re: Disable placement of specific structures
During prototype/data stage or during runtime?Tami wrote:Is it possible to disable placement of structures like laser towers without preventing laser tower tech or turrets?
Same goes for solar panels.
Re: Disable placement of specific structures
Example with /permissions settings.
Would be great to disable placement of certain structures.
If not possible with permissions (as it is yet), maybe a simble lua command script could help too if there is one. Keep in mind that the laser turrets needs to be build for certain receipe, but not be placed, same for solar for certain receipes.
Would be great to disable placement of certain structures.
If not possible with permissions (as it is yet), maybe a simble lua command script could help too if there is one. Keep in mind that the laser turrets needs to be build for certain receipe, but not be placed, same for solar for certain receipes.
Re: Disable placement of specific structures
You will have to listen to on_built_event, something like this:Tami wrote:Example with /permissions settings.
Would be great to disable placement of certain structures.
If not possible with permissions (as it is yet), maybe a simble lua command script could help too if there is one. Keep in mind that the laser turrets needs to be build for certain receipe, but not be placed, same for solar for certain receipes.
Code: Select all
script.on_event(defines.events.on_built_entity, function(event)
local entity = event.created_entity
local player = game.players[event.player_index]
if entity.name == "laser-turret" then
entity.destroy()
player.insert{name = "laser-turret", count = 1}
player.print("Placing laser turrets is not allowed")
return
end
if entity.name == "entity-ghost" and entity.ghost_name == "laser-turret" then
entity.destroy()
player.print("Don't build ghosts or blueprints of laser turrets either.")
return
end
end)
Re: Disable placement of specific structures
Thank you very much
-
- Manual Inserter
- Posts: 2
- Joined: Sat Aug 13, 2022 3:02 am
- Contact:
Re: Disable placement of specific structures
From where do we listen ? Is this accomplished with your syntax contained within Control.lua in the Entities folder, or somewhere else ?Klonan wrote: Tue Oct 24, 2017 5:44 pmYou will have to listen to on_built_event, something like this:Tami wrote:Example with /permissions settings.
Would be great to disable placement of certain structures.
If not possible with permissions (as it is yet), maybe a simble lua command script could help too if there is one. Keep in mind that the laser turrets needs to be build for certain receipe, but not be placed, same for solar for certain receipes.
Code: Select all
script.on_event(defines.events.on_built_entity, function(event) local entity = event.created_entity local player = game.players[event.player_index] if entity.name == "laser-turret" then entity.destroy() player.insert{name = "laser-turret", count = 1} player.print("Placing laser turrets is not allowed") return end if entity.name == "entity-ghost" and entity.ghost_name == "laser-turret" then entity.destroy() player.print("Don't build ghosts or blueprints of laser turrets either.") return end end)
I'm new to modding, and trying to remove the module slots from assembling-machine-2 and add pipe/fluid input to the assembling-machine (grey one).
https://mods.factorio.com/mod/TierOnePr ... 6deb3409ff
EDIT !! - I meant to say that I am trying to prevent the placement of solar panels and accumulators as structures... since that's related to this thread here/// but I am also trying to change the assembling machines too !!
p.s. perhaps I will post this in a new forum thread, but I did want to reply here since it seems like an open question .
thanks
Jason
Re: Disable placement of specific structures
Urgs, entity.destroy() will destroy the entity so the entity is lost. It should be returned to the player.Klonan wrote: Tue Oct 24, 2017 5:44 pmYou will have to listen to on_built_event, something like this:Tami wrote:Example with /permissions settings.
Would be great to disable placement of certain structures.
If not possible with permissions (as it is yet), maybe a simble lua command script could help too if there is one. Keep in mind that the laser turrets needs to be build for certain receipe, but not be placed, same for solar for certain receipes.
Code: Select all
script.on_event(defines.events.on_built_entity, function(event) local entity = event.created_entity local player = game.players[event.player_index] if entity.name == "laser-turret" then entity.destroy() player.insert{name = "laser-turret", count = 1} player.print("Placing laser turrets is not allowed") return end if entity.name == "entity-ghost" and entity.ghost_name == "laser-turret" then entity.destroy() player.print("Don't build ghosts or blueprints of laser turrets either.") return end end)
I think a better solution to preventing placing entites, at least when you want to do it for all players for the whole game, is to simply remove the place_result property from the item:
https://wiki.factorio.com/Prototype/Item#place_result
-
- Manual Inserter
- Posts: 2
- Joined: Sat Aug 13, 2022 3:02 am
- Contact:
Re: Disable placement of specific structures
mrvn wrote: Mon Apr 24, 2023 1:02 pm
I think a better solution to preventing placing entites, at least when you want to do it for all players for the whole game, is to simply remove the place_result property from the item:
https://wiki.factorio.com/Prototype/Item#place_result
Yea that sounds good, as I didn't even look into the result of this code. I have been too preoccupied with the original issue. Where do we put this code ?
In other words, which folder location, and which filename ?
Control.lua ? Entities.lua ? in the root directory ? in the scripts folder ?
Re: Disable placement of specific structures
data.lua up to data-final-fixes.lua
This is changing the prototype. Nothing runtime and can't be changed at runtime.
This is changing the prototype. Nothing runtime and can't be changed at runtime.
Re: Disable placement of specific structures
I have more questions than answers but:
If you want to prevent the placement in order to maintain status for an achievement, then it is probably too late to catch it after it has been placed and remove it. I am not sure, but that would be my guess.
Again I am not sure, entity flags include "placeable-player" which seems to mean the player is allowed or able to place the entity... you can probably remove that flag or something
I do not know if that will prevent bots from placing one on a ghosted blueprint either but would like to find out
If you want to prevent the placement in order to maintain status for an achievement, then it is probably too late to catch it after it has been placed and remove it. I am not sure, but that would be my guess.
Again I am not sure, entity flags include "placeable-player" which seems to mean the player is allowed or able to place the entity... you can probably remove that flag or something
I do not know if that will prevent bots from placing one on a ghosted blueprint either but would like to find out
Re: Disable placement of specific structures
Easy enough to test yourself or read up on the definition of the flag.hackamod wrote: Wed Apr 26, 2023 9:31 pm I have more questions than answers but:
If you want to prevent the placement in order to maintain status for an achievement, then it is probably too late to catch it after it has been placed and remove it. I am not sure, but that would be my guess.
Again I am not sure, entity flags include "placeable-player" which seems to mean the player is allowed or able to place the entity... you can probably remove that flag or something
I do not know if that will prevent bots from placing one on a ghosted blueprint either but would like to find out