Page 1 of 1

Turrets range changer mod request

Posted: Thu Apr 30, 2020 6:16 pm
by matryona12
Can someone please create mod which would give ability to change turrets range in menu to any value? Or at least make a mod to increase laser and machinegun turret range to twice as in vanilla.
Tnx :D

Re: Turrets range changer mod request

Posted: Thu Apr 30, 2020 7:04 pm
by darkfrei
matryona12 wrote: Thu Apr 30, 2020 6:16 pm Can someone please create mod which would give ability to change turrets range in menu to any value? Or at least make a mod to increase laser and machinegun turret range to twice as in vanilla.
Tnx :D
First, you are need the name for your mod. For example "Turret Range Extension".

You are need to create the mod folder (for example "TurretRangeExtension_0.0.1") and prepare the file info.json inside. See: link
example
and:

1. The shortest mod, that makes range exactly twice larger than vanilla:
place this code in your mod folder into the file data.lua:

Code: Select all

data.raw["ammo-turret"]["gun-turret"].attack_parameters.range = 2*18 -- default is 18
data.raw["electric-turret"]["laser-turret"].attack_parameters.range = 2*24 -- default is 24


2. The mod with mod settings:
Create the file settings.lua, paste this code:

Code: Select all

data:extend({
    {
        type = "int-setting",
        name = "gun-turret-range",
        setting_type = "startup",
        minimum_value = 18/3,
        maximum_value = 3*18,
        default_value = 18
    },
    {
        type = "int-setting",
        name = "laser-turret-range",
        setting_type = "startup",
        minimum_value = 24/3,
        maximum_value = 3*24,
        default_value = 24
    }
})
This into the data.raw:

Code: Select all

data.raw["ammo-turret"]["gun-turret"].attack_parameters.range = settings.startup["gun-turret-range"].value
data.raw["electric-turret"]["laser-turret"].attack_parameters.range = settings.startup["laser-turret-range"].value
You can also add the locale for your mod:
/locale/EN/locale.cfg:

Code: Select all

[mod-setting-name]
gun-turret-range=Gun Turret Range
laser-turret-range=Laser Turret range
/locale/RU/locale.cfg:

Code: Select all

[mod-setting-name]
gun-turret-range=Дальность стрельбы турелей
laser-turret-range=Дальность стрельбы лазерных турелей

Re: Turrets range changer mod request

Posted: Thu Apr 30, 2020 8:20 pm
by matryona12
all those explanations from darkfrei
Thanks a lot, but because of my stupidity i managed to get it working from 100500 try.