Disable creeper attacks, spawning, buildings
Disable creeper attacks, spawning, buildings
I'd like to either make or use a mod that disables all creeper attacks, spawning, and buildings. Kinda like a "peaceful" mode. I am unsure as how to go about doing this for the control.lua file. Any help?
Factorio Modder
Solar Expansion
Solar Expansion
Re: Disable creeper attacks, spawning, buildings
Needs to edit the freeplay.lua in the core folder, read the code and u may be able to know how to do it.
Re: Disable creeper attacks, spawning, buildings
The core should not be edited because then the mod is not portable. Mod needs to be a self standing package.
The creeper spawners generation can't be disabled at the moment becaused it is hardcoded in the map generator. This will change soon and it will be possible to set the rate of creeper spawners in the map generation gui in the same fashion as the frequency of resources is set, etc.
On the other hand, the regular creeper attacks can be disabled. Creeper attacks logic is coded in the core/lualib/freeplay.lua. The freeplay.lua exposes an interface to manipulate the attacking logic. The script interfaces are described on the wiki: https://forums.factorio.com/wiki/inde ... interfaces
In this case you are probably looking for something like this (not tested - check the freeplay.lua for the interface definition):
The creeper spawners generation can't be disabled at the moment becaused it is hardcoded in the map generator. This will change soon and it will be possible to set the rate of creeper spawners in the map generation gui in the same fashion as the frequency of resources is set, etc.
On the other hand, the regular creeper attacks can be disabled. Creeper attacks logic is coded in the core/lualib/freeplay.lua. The freeplay.lua exposes an interface to manipulate the attacking logic. The script interfaces are described on the wiki: https://forums.factorio.com/wiki/inde ... interfaces
In this case you are probably looking for something like this (not tested - check the freeplay.lua for the interface definition):
Code: Select all
local attackdata = remote.call("freeplay", "getattackdata")
attackdata.enabled = false
remote.call("freeplay", "setattackdata", attackdata)
Re: Disable creeper attacks, spawning, buildings
Since I tried something like this last night (but wasn't sure I wasn't making a silly mistake from being tired) I figured I'd test this but I got the same error as before which is As for disabling the creeper spawners...If you just want to disable them from spawning creepers you can useslpwnd wrote:In this case you are probably looking for something like this (not tested - check the freeplay.lua for the interface definition):Code: Select all
local attackdata = remote.call("freeplay", "getattackdata") attackdata.enabled = false remote.call("freeplay", "setattackdata", attackdata)
Code: Select all
if data.raw["unit-spawner"] then
data.raw["unit-spawner"].maximum_count_of_owned_units = 0
end
For peaceful mode could maybe do something along the lines of
Code: Select all
creepers_destroyed=creepers_destroyed or game.findentities{{game.player.character.position.x,game.player.character.position.y},{game.player.character.position.x,game.player.character.position.y}} --I've had issues with oninit sometimes
game.onevent(defines.events.onchunkgenerated, function(event)
creepers_destroyed=game.findentities{{event.area.x,event.area.y},{event.area.x,event.area.y}}
end)
for k,v in pairs(creepers_destroyed) do
if v.type == "unit-spawner" or v.type == "unit" or not v.force.equals(game.player.force) then if v.health v.die() else v.destroy() end end --probably don't need the v.health test but better safe than sorry
end
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me
Or drop into #factorio on irc.esper.net
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me
Or drop into #factorio on irc.esper.net
Re: Disable creeper attacks, spawning, buildings
So I tried it as well. I was getting the same error as long as I had the code for changing attackdata in the global scope. Once moved to the onload function it works just fine. That makes sense because in the freeplay.lua script the glob.attackdata is nil in the global scope. It "comes to existence" only in the oninit / onload function. So it works well but can be a bit confusing.FreeER wrote: Since I tried something like this last night (but wasn't sure I wasn't making a silly mistake from being tired) I figured I'd test this but I got the same error as before which is
attackdata.png (27.21 KiB) Viewed 8 times
As for the solutions to eliminating existing creepers. Good job - they are nice workarounds. I haven't thought of that.
Re: Disable creeper attacks, spawning, buildings
I guess this means it would be difficut to create a mod that would allow you to become 'friendly' with the creepers by turning the waves off midgame (though i suppose you could have the oninit code check the glob table for an isfriendly value before turning the wave off and then simply telling the player to save the game and reload it to give the creepers time to spread the word lol)slpwnd wrote:So I tried it as well. I was getting the same error as long as I had the code for changing attackdata in the global scope. Once moved to the onload function it works just fine. That makes sense because in the freeplay.lua script the glob.attackdata is nil in the global scope. It "comes to existence" only in the oninit / onload function. So it works well but can be a bit confusing.
Why thank youAs for the solutions to eliminating existing creepers. Good job - they are nice workarounds. I haven't thought of that.
I'll try to work some of these into the tutorial I've got on the wiki for everyone else as well.
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me
Or drop into #factorio on irc.esper.net
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me
Or drop into #factorio on irc.esper.net
Re: Disable creeper attacks, spawning, buildings
You understood him wrong, as I did first.FreeER wrote:I guess this means it would be difficut to create a mod that would allow you to become 'friendly' with the creepers by turning the waves off midgame (though i suppose you could have the oninit code check the glob table for an isfriendly value before turning the wave off and then simply telling the player to save the game and reload it to give the creepers time to spread the word lol)slpwnd wrote:So I tried it as well. I was getting the same error as long as I had the code for changing attackdata in the global scope. Once moved to the onload function it works just fine. That makes sense because in the freeplay.lua script the glob.attackdata is nil in the global scope. It "comes to existence" only in the oninit / onload function. So it works well but can be a bit confusing.
He said, that you can't do it in the global context (outside function onload, ontick etc).
But you can access it midgame.