Page 1 of 1

[0.11.20] Displaying range of turrets [v1.0.0]

Posted: Wed Jun 10, 2015 11:27 pm
by kds71
Note: If you are using Factorio 0.12.x, you can get updated version of this mod here.

Another mod inspired by a reddit post.

This mod adds an item that allows you to check range of a turret.
Since version 0.0.3 it works with vanilla, DyTech and MoMods turrets only. All supported turrets (and their respective ranges) are listed in config.lua file in this mod - if you have a modded turret that is not listed here (or it is listed, but you are using a mod that changes range of this turret), you will have to edit config.lua file.

Features:
  • adds a new technology called "turrets range probing" (requires electronics and turrets)
  • adds a new item, "turret probe" with recipe unlocked by this technology
How to use:
  • click on a turret with a turret probe in your hand to see a range of this turret
  • click elsewhere (still with a turret probe in your hand) to remove displayed range from the screen
  • you may click on several turrets in a row to see their range together (to check for overlapping etc.)
Screenshot
I marked it with [0.11.20] because this is the version of Factorio that I'm currently using, but it probably works with older versions as well.

I would be grateful for your feedback :)
Changelog

Re: [WIP][0.11.20] Displaying range of turrets [v0.0.2]

Posted: Thu Jun 11, 2015 9:48 pm
by Doublespin
You can read out with data.raw table.
Search the site for "turret" then you will find the diffrent categories. I think most mods will add their turrets into these existing categories but if they make their own then you probably will have to adjust your code manually to them.

You can read them out with the pairs loop
And you should use the data-updates.lua which is loaded after the the diffrent mods. I dont know if it is possible with control.lua

Re: [WIP][0.11.20] Displaying range of turrets [v0.0.2]

Posted: Thu Jun 11, 2015 9:56 pm
by kds71
Both data.lua and data-updates.lua (where data.raw is accessible) are processed when the game is being loaded. I need to read the range of turrets while the game is running, so control.lua is my only option - and you can't access data.raw from there.

Re: [WIP][0.11.20] Displaying range of turrets [v0.0.2]

Posted: Thu Jun 11, 2015 10:03 pm
by Doublespin
I dont know much about lua and factorio but maybe this will work???
save the name of the turrets with their range as a table.
In the control.lua you can cycle through the table with pairs so you wont need any hard coded names
You can fill the table with names and ranges in the data-updates.lua

Re: [WIP][0.11.20] Displaying range of turrets [v0.0.2]

Posted: Thu Jun 11, 2015 10:16 pm
by kds71
I'm affraid it is still impossible :) There is no way to create any variable that will be shared between data.lua (or data-updates.lua) and control.lua.

Well, I'm going to submit a request for implementing that as a new feature in the modding API, for now I'm going to simply hardcode turret ranges from the most popular mods in my control.lua file, it should be sufficient for a while.

Re: [WIP][0.11.20] Displaying range of turrets [v0.0.2]

Posted: Thu Jun 11, 2015 10:25 pm
by Doublespin
Ok just for the theory:
You can make a valid recipe with the free choice of name. So this will be your variable. The recipe can be disabled and hided. So a player wont see anything of it.
This name can be written in data-updates-lua and accessed in control.lua, right?? To make sorting easier you can create a crafting category.

I not saying you should do this(this sounds more like hacking :D), im just interested if it is possible :)

Re: [WIP][0.11.20] Displaying range of turrets [v0.0.2]

Posted: Thu Jun 11, 2015 11:30 pm
by -root
this could be one of those incredibly handy mods...

is there anyway to make it like roboports where if you hover the mouse over it, it shows you the range? having to use an item to view the range isn't exactly ideal, i get there are limits in the modding API though....

Re: [WIP][0.11.20] Displaying range of turrets [v0.0.2]

Posted: Thu Jun 11, 2015 11:32 pm
by kds71
-root wrote:is there anyway to make it like roboports where if you hover the mouse over it, it shows you the range? having to use an item to view the range isn't exactly ideal, i get there are limits in the modding API though....
Yeah, it is not possible with current state of modding API :(

More positive note: I added support for DyTech and MoMods turrets and I exposed all turret ranges to config file, so you can add your own turrets rather easily now :)

Re: [0.11.20] Displaying range of turrets [v1.0.0]

Posted: Sat Jul 18, 2015 3:16 pm
by Peter34
Can more be done now, with the extra modding options in alpha 12?

Re: [0.11.20] Displaying range of turrets [v1.0.0]

Posted: Tue Jul 28, 2015 12:28 pm
by Talguy
Bump :)

Would be awesome if this supports 0.12 :)

Re: [0.11.20] Displaying range of turrets [v1.0.0]

Posted: Wed Aug 12, 2015 12:07 pm
by kds71
I updated this mod to work with Factorio 0.12.x, sorry for the delay.
Can more be done now, with the extra modding options in alpha 12?
Nope, sorry - there is still no way to read the range of a turret in Factorio 0.12.

Re: [0.11.20] Displaying range of turrets [v1.0.0]

Posted: Wed May 18, 2016 3:34 pm
by Mozleron
Having not delved into the depths that is the Factorio modding system, I'm wondering if there is a way to hook/piggyback on the mechanism used to see the connection range from power poles to see the firing range of turrets? It's clearly a system the devs put into place to display the functional range of an object. I'm just curious about how modular they made that bit of functionality, because it seems like it should be pretty easy to port to other objects in the game.

Re: [0.11.20] Displaying range of turrets [v1.0.0]

Posted: Wed May 18, 2016 6:05 pm
by Adil
Nope, you can't have arbitrary overlay display for arbitrary entity in game.
Also, there were no connection range display last time I've checked (0.12.30). There's only coverage overlay and that one is hardcoded to be square at that.
Though, there might be some trick with data.lua scripting, I'll try to make that today.

Re: [0.11.20] Displaying range of turrets [v1.0.0]

Posted: Thu May 19, 2016 12:49 am
by Adil
Well, did it.
You still need updated version of this mod for inspecting them post-build.