My questions are these:
1. Is it possible to extend a tile for another property that is read/write accessible in-game?
2. Is it possible to assign a value to that property on chunk creation?
Context:
I would like to store a height value to each tile on chunk creation. Later, in game I would like to access and modify that value. I have the idea for a mod where each water tile has a defined depth and filling in that water tile costs an amount of landfill according to its depth.
Possible to add value to tile on chunk creation?
Re: Possible to add value to tile on chunk creation?
Not directly. You would have create and store the height value yourself during the on_chunk_generated event.
Re: Possible to add value to tile on chunk creation?
Thanks for the answer. Now I know in what direction I should continue to explore the possibilities.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Possible to add value to tile on chunk creation?
Elevation used to be an API accessible value (TileProperties in 0.13.20), and as far as i remember they said in several FFFs that water and cliff generation are based on the height of the terrain. It's just not visible on a 2D plane. Was probably removed when the map generator was rewritten.
But apart from that, dynamically changing the cost of building something isn't easily possible, and even if it was, how would you communicate to the player how much filling a particular tile will cost?
But apart from that, dynamically changing the cost of building something isn't easily possible, and even if it was, how would you communicate to the player how much filling a particular tile will cost?
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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Possible to add value to tile on chunk creation?
Hi eradicator!eradicator wrote: ↑Tue May 07, 2019 12:46 pmElevation used to be an API accessible value (TileProperties in 0.13.20), and as far as i remember they said in several FFFs that water and cliff generation are based on the height of the terrain. It's just not visible on a 2D plane. Was probably removed when the map generator was rewritten.
But apart from that, dynamically changing the cost of building something isn't easily possible, and even if it was, how would you communicate to the player how much filling a particular tile will cost?
Thanks for taking interest in this question. Possible ways to indicate height/depth are:
- Implement a buildable tool (let's call it depth sonar). Holding it and clicking on water tiles outputs the depth.
- Maybe it is possible without a special tool (as i do not like these "a tool for a single purpose, rarely used, taking up a full inventory slot" solutions). Maybe it is possible with an activation button in the new quickbar. I would need to explore this idea.
- The output for sure can go to the console.
- Maybe the output can be shown as a number attached to the cursor (my favorite solution).
- I think the output can - as of version 0.17 - be shown as a floating text (like the error messages when you want to build something but for a reason it is not possible). The text appears above the tile clicked, slowly floats up and then disappears.
So in the best case I click an activation/deactivation button in the new quickbar and just hover over water tiles. The depth then is shown next to the cursor. In the worst case I need to implement a tool, the user needs to click on a water tile with and the depth is then shown as console output.
My dream for this mod idea and I think for a massive amount of other applications would be a custom map overlay. But pittily custom map overlays are not possible in factorio. Yet. May be the devs will implement this api feature after the release as it really would make sense. This is a slightly different topic but I want to write an API-request for this.
Re: Possible to add value to tile on chunk creation?
That is good to know and I will look into this. I read some pretty sophisticated articles about map gen algorithms. But from what I understood the map gen algo that is used while chunk creation is encapsulated. It creates a height value for each tile at chunk creation time, which indeed, like you wrote, is used to create the shoreline and also the cliffs (which are disconnected heightlines). But it seems that algo can not store that value for later use in-game. From what I have seen asked and answered on the forum, I have the impression knowledge about this is rare. I might need to code a prototype to explore this in full for myself. But I hope for more input on this topic first.eradicator wrote: ↑Tue May 07, 2019 12:46 pmElevation used to be an API accessible value (TileProperties in 0.13.20) and as far as i remember they said in several FFFs that water and cliff generation are based on the height of the terrain. It's just not visible on a 2D plane. Was probably removed when the map generator was rewritten.
...
What I for sure could do is add a height/depth value to each water tile somewhen after chunk creation. eduran gave me a good pointer to the on_chunk_created event. At the most basic implementation I would need to iterate over new water tiles periodically and assign a value to them. But I would like to somehow use the map gen algo. The reason is, only it can generated good depth values. Low depth values near the shore and high depth values far out in the water. If I iterate over water tiles without the map gen algo, what depth should I assign to it? I have various ideas but none of them are nice. The easiest - a random value, is especially ugly.
Re: Possible to add value to tile on chunk creation?
How about instead just defining a a bunch of tile types for different water depths? And then either deduct the correct amount of landfill based on the tile, or have each application of landfill reduce the depth by 1.
This would start consuming too many tile types if you want hundreds of possible depths, but I doubt more than 10 or so depths add significant gameplay.
This would start consuming too many tile types if you want hundreds of possible depths, but I doubt more than 10 or so depths add significant gameplay.
Re: Possible to add value to tile on chunk creation?
That is a very interesting suggestion. And this is something that actually could be done using the map gen algo during chunk creation. It is a really good suggestion, I think right now. Thanks a lot!
Re: Possible to add value to tile on chunk creation?
FYI
I created a separate idea and project theread here, to bundle everything connected with the deep water mod idea.
I created a separate idea and project theread here, to bundle everything connected with the deep water mod idea.