Allow for shorter, rather than longer, reach.

Place to get help with not working mods / modding interface.
Post Reply
User avatar
adamwong246
Fast Inserter
Fast Inserter
Posts: 148
Joined: Tue Dec 01, 2020 5:01 am
Contact:

Allow for shorter, rather than longer, reach.

Post 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

Koub
Global Moderator
Global Moderator
Posts: 7175
Joined: Fri May 30, 2014 8:54 am
Contact:

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

Post 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.
Koub - Please consider English is not my native language.

Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

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

Post 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

User avatar
adamwong246
Fast Inserter
Fast Inserter
Posts: 148
Joined: Tue Dec 01, 2020 5:01 am
Contact:

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

Post 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.

User avatar
adamwong246
Fast Inserter
Fast Inserter
Posts: 148
Joined: Tue Dec 01, 2020 5:01 am
Contact:

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

Post 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`

Xorimuth
Filter Inserter
Filter Inserter
Posts: 623
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

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

Post 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.
My mods
Content: Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Remote Configuration | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings

Koub
Global Moderator
Global Moderator
Posts: 7175
Joined: Fri May 30, 2014 8:54 am
Contact:

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

Post 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.
Koub - Please consider English is not my native language.

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

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

Post 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.
Image

User avatar
adamwong246
Fast Inserter
Fast Inserter
Posts: 148
Joined: Tue Dec 01, 2020 5:01 am
Contact:

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

Post 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.

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

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

Post 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.
Image

Xorimuth
Filter Inserter
Filter Inserter
Posts: 623
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

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

Post 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.
My mods
Content: Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Remote Configuration | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings

Koub
Global Moderator
Global Moderator
Posts: 7175
Joined: Fri May 30, 2014 8:54 am
Contact:

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

Post 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.
Koub - Please consider English is not my native language.

User avatar
adamwong246
Fast Inserter
Fast Inserter
Posts: 148
Joined: Tue Dec 01, 2020 5:01 am
Contact:

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

Post 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.

User avatar
adamwong246
Fast Inserter
Fast Inserter
Posts: 148
Joined: Tue Dec 01, 2020 5:01 am
Contact:

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

Post 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.

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

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

Post by Deadlock989 »

Congrats. Be warned, modding is at least as addictive as the actual game.
Image

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

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

Post 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.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Modding help”