Page 1 of 1

Allow for shorter, rather than longer, reach.

Posted: Tue Dec 01, 2020 7:39 pm
by adamwong246
TL;DR
I would like to limit my reach to only 1 tile, rather than the default of 6.
What ?
By default you can place and destroy items within a box of 6 tiles surrounding your character. I would like to reduce that to 1, so you can only build in your surrounding tiles. As best I understand it, this would require a change to `character_build_distance_bonus`, which ATM must be between 0 and 123. In order to preserve other mods, this range should be extended to -6 to 123
Why ?
I need more of a challenge. I believe the game could be better balanced by reducing your reach, because this would force you to use drones. It's far too tempting to do everything manually, when the game really ought to push you to rely upon blueprints and drones.

See more details here
https://mods.factorio.com/mod/far-reach ... 5b0579f7f9

Re: Allow for shorter, rather than longer, reach.

Posted: Tue Dec 01, 2020 7:44 pm
by Koub
[Koub] I'm moving this to "Modding interface requests", because I'm pretty sure reach won't be reduced in vanilla, but it makes sense to request for it for modding purpose - as it's already possible to increase reach, why not decrease it.

Re: Allow for shorter, rather than longer, reach.

Posted: Tue Dec 01, 2020 7:54 pm
by Choumiko
What's wrong with doing it in data stage? https://wiki.factorio.com/Prototype/Cha ... d_distance
Unless you just want to use a console command

Re: Allow for shorter, rather than longer, reach.

Posted: Tue Dec 01, 2020 8:14 pm
by adamwong246
Koub wrote:
Tue Dec 01, 2020 7:44 pm
[Koub] I'm moving this to "Modding interface requests", because I'm pretty sure reach won't be reduced in vanilla, but it makes sense to request for it for modding purpose - as it's already possible to increase reach, why not decrease it.
This change is more significant that just changing a mod interface. I should know, I downloaded the FarReach mod and attempted to make the change myself! It was how I discovered that `character_build_distance_bonus` must be >= 0. If you'd like I can share my work.

Re: Allow for shorter, rather than longer, reach.

Posted: Tue Dec 01, 2020 8:26 pm
by adamwong246
My modification of `settings.lua` in the Far Reach mod

Code: Select all

data:extend({
    {
        name = "far-reach-build-distance-bonus",
        setting_type = "runtime-global",
        --minimum_value = 0,
        minimum_value = -6,
    },
    {
        name = "far-reach-reach-distance-bonus",
        setting_type = "runtime-global",
        --minimum_value = 0,
        minimum_value = -6,
    },
    {
        name = "far-reach-resource-reach-distance-bonus",
        setting_type = "runtime-global",
        --minimum_value = 0,
        minimum_value = -6,
    }
})

This change allows you to set negative numbers in the mod settings HOWEVER it produces the error `Given value has to larger than or equal to: 0` with a stack trace referring to a line in `control.lua`

`player.character_build_distance_bonus = settings["far-reach-build-distance-bonus"].value`

Re: Allow for shorter, rather than longer, reach.

Posted: Tue Dec 01, 2020 8:37 pm
by Xorimuth
adamwong246 wrote:
Tue Dec 01, 2020 8:14 pm
Koub wrote:
Tue Dec 01, 2020 7:44 pm
[Koub] I'm moving this to "Modding interface requests", because I'm pretty sure reach won't be reduced in vanilla, but it makes sense to request for it for modding purpose - as it's already possible to increase reach, why not decrease it.
This change is more significant that just changing a mod interface. I should know, I downloaded the FarReach mod and attempted to make the change myself! It was how I discovered that `character_build_distance_bonus` must be >= 0. If you'd like I can share my work.
This subforum is for requesting mod interface changes from the devs, which is exactly what you are doing.

Please don't ignore Choumiko's suggestion. It would be very easy to make a mod that does what you want using https://wiki.factorio.com/Prototype/Cha ... d_distance.

Re: Allow for shorter, rather than longer, reach.

Posted: Tue Dec 01, 2020 8:39 pm
by Koub
adamwong246 wrote:
Tue Dec 01, 2020 8:14 pm
Koub wrote:
Tue Dec 01, 2020 7:44 pm
[Koub] I'm moving this to "Modding interface requests", because I'm pretty sure reach won't be reduced in vanilla, but it makes sense to request for it for modding purpose - as it's already possible to increase reach, why not decrease it.
This change is more significant that just changing a mod interface. I should know, I downloaded the FarReach mod and attempted to make the change myself! It was how I discovered that `character_build_distance_bonus` must be >= 0. If you'd like I can share my work.
I think it's spot on : allowing the modding API to accept a negative number, or whatever solution that makes sense to the devs to allow a shorter-than-6 minimum reach is a modding interface request. Once the game allows mods to go below 6 reach, THEN it becomes a simple modding issue.

Re: Allow for shorter, rather than longer, reach.

Posted: Tue Dec 01, 2020 8:41 pm
by Deadlock989
Koub wrote:
Tue Dec 01, 2020 8:39 pm
I think it's spot on : allowing the modding API to accept a negative number, or whatever solution that makes sense to the devs to allow a shorter-than-6 minimum reach is a modding interface request. Once the game allows mods to go below 6 reach, THEN it becomes a simple modding issue.
The point is being missed here. The base reach property is on the character. The bonus property is just that, a bonus. You can achieve a reach of less than the default (10) if you modify the character's build_distance property, as Choumiko and Xorimuth have pointed out.

Re: Allow for shorter, rather than longer, reach.

Posted: Tue Dec 01, 2020 8:43 pm
by adamwong246
Choumiko wrote:
Tue Dec 01, 2020 7:54 pm
What's wrong with doing it in data stage? https://wiki.factorio.com/Prototype/Cha ... d_distance
Unless you just want to use a console command
I am still very much a beginner so much of factorios mod development is still a mystery to me. I'm not sure what "would be wrong with doing in the data stage" :?: I guess I need to RTFM because wtf is the data stage? :lol: It sounds to me like you are saying that this could be set earlier in the mod loading process. I am looking at https://lua-api.factorio.com/0.14.8/Dat ... %2Dupdates. and it sounds like perhaps `build_distance` could be set when `data.lua` is ran.

I hope I am not "ignoring" mods advice, it's just I have downloaded the mod's source and my investigation led me to believe this couldn't be done with a mod. I may be wrong and and if this can be achieved with a mod I definitely want the post moved to the appropriate subforum.

Also, a console command would be nice I guess but it's not really what I am trying to achieve. It's not a thing I want to toggle on/off.

Re: Allow for shorter, rather than longer, reach.

Posted: Tue Dec 01, 2020 8:46 pm
by Deadlock989
adamwong246 wrote:
Tue Dec 01, 2020 8:43 pm
I guess I need to RTFM because wtf is the data stage? :lol:
I recommend starting here, the tutorials were updated for 1.0.

Re: Allow for shorter, rather than longer, reach.

Posted: Tue Dec 01, 2020 9:07 pm
by Xorimuth
adamwong246 wrote:
Tue Dec 01, 2020 8:43 pm
Choumiko wrote:
Tue Dec 01, 2020 7:54 pm
What's wrong with doing it in data stage? https://wiki.factorio.com/Prototype/Cha ... d_distance
Unless you just want to use a console command
I am still very much a beginner so much of factorios mod development is still a mystery to me. I'm not sure what "would be wrong with doing in the data stage" :?: I guess I need to RTFM because wtf is the data stage? :lol: It sounds to me like you are saying that this could be set earlier in the mod loading process. I am looking at https://lua-api.factorio.com/0.14.8/Dat ... %2Dupdates. and it sounds like perhaps `build_distance` could be set when `data.lua` is ran.

I hope I am not "ignoring" mods advice, it's just I have downloaded the mod's source and my investigation led me to believe this couldn't be done with a mod. I may be wrong and and if this can be achieved with a mod I definitely want the post moved to the appropriate subforum.

Also, a console command would be nice I guess but it's not really what I am trying to achieve. It's not a thing I want to toggle on/off.
Yep, mods are comprised of the data stage (data.lua), which is ran once when the game is loaded, and the control stage (control.lua), which is ran when a save is loaded, and allows you to set event hooks to run code during the game. That link is a good explanation, but somehow you found the one for v0.14.8... this is the up-to-date page: https://lua-api.factorio.com/latest/Data-Lifecycle.html

In this case, Far Reach uses the 'bonus reach' in the control stage, whereas you will have to delve into the data stage in order to do what you want here.

Re: Allow for shorter, rather than longer, reach.

Posted: Tue Dec 01, 2020 10:02 pm
by Koub
[Koub] OK I get it now, it's more a modding help than a request for a modding API : it's already moddable. Thanks Choumiko and Deadlock989.

Re: Allow for shorter, rather than longer, reach.

Posted: Tue Dec 01, 2020 10:26 pm
by adamwong246
Thank you for the pointers I think I have this one in the bag!

in `data.lua`

Code: Select all

data.raw["character"]["character"].build_distance = 0
data.raw["character"]["character"].reach_distance = 0
data.raw["character"]["character"].reach_resource_distance = 0
makes things suitably hardcore! :twisted: There are a few more properties I might want to add but I can't quite tell because the https://wiki.factorio.com/Prototype/Cha ... d_distance docs are missing description fields.

Re: Allow for shorter, rather than longer, reach.

Posted: Tue Dec 01, 2020 11:36 pm
by adamwong246
Check it out ya'll, my first mod! https://mods.factorio.com/mod/short_reach

Thanks for the help, we can close this thread now I think.

Re: Allow for shorter, rather than longer, reach.

Posted: Wed Dec 02, 2020 12:01 am
by Deadlock989
Congrats. Be warned, modding is at least as addictive as the actual game.

Re: Allow for shorter, rather than longer, reach.

Posted: Mon Dec 07, 2020 12:53 am
by eradicator
Choumiko wrote:
Tue Dec 01, 2020 7:54 pm
What's wrong with doing it in data stage? https://wiki.factorio.com/Prototype/Cha ... d_distance
What's "wrong" with it is that you do not know which character prototype the player will be using (i.e. bobclasses, skin mods, clone mods). Neither can you know which character prototypes are even meant to be used by the player.

TL;DR: There's no such thing as a mod perfectly compatible with every other mod.