TheOddler / FactorioWorld

A mod for factorio that changes the map into a real-world map.
25 stars 3 forks source link

Add settings.lua #5

Closed sirlaige closed 4 years ago

sirlaige commented 6 years ago

I was playing with your mod and figured it would be nice if you added a settings file. This means you wont have to unzip the mod to change the map scale. Here is what I came up with and hope you add it to your mod.

In your control.lua --Choose your scale here! --local scale = 6 local scale = settings.global["map-gen-scale"].value

In a new setting.lua I made data:extend({ { type = "string-setting", name = "map-gen-scale", setting_type = "runtime-global", default_value = 6, allowed_values = {6, 12, 18, 24}, order = "a" }, })

This made a mod settings entry in game that let me change the map scale without having to change the control.lua each time. The setting can be found when starting a new game. Before clicking the generate button. Click mod settings. It is under the Map tab.

You would have to add localization. [mod-setting-name] map-gen-scale=Map Size

This type of setting has a drop down menu and I just set up a few generic scales {6, 12, 18, 24}

Setting is a great new feature from 0.15 and it is fairly customize-able! I hope you will consider adding this to mod. I feel this feature is one not used enough in the modding community.

TheOddler commented 6 years ago

This is a good suggestion! I indeed didn't update it since 0.14, other than to make it work on the later versions. I'll look into it this weekend ;)

sirlaige commented 6 years ago

Thanks!

Here is a link that explains the basics of the different mod settings types. https://wiki.factorio.com/Tutorial:Mod_settings

TheOddler commented 6 years ago

I just pushed an update to the repo here. Would you mind testing it?

I added settings for the map scale, the spawn position, and whether to use the larger map data. I made them startup settings, as changing them at rumtime would break the consistency of the generated map.

TheOddler commented 6 years ago

I changed the settings type to global-runtime as you suggested. The startup type isn't saved per savegame, and still allows you to change the settings between startups of factorio. So it doesn't achieve what I was trying to.

Global-runtime isn't perfect either though. I can just ignore runtime changes, but can't prevent the user to change them and restarting for them to take effect. I added a warning about this when the player tries to, but still, not perfect as a solution. They do are save into the savegame now though, so that's good :D

sirlaige commented 6 years ago
Please forgive me for not being around.  My work can take me away for long periods of time, and I didn't notice this right away when I returned home.  Excuse me for the very late response.  Thanks for doing the update.  Here are my test findings and suggestions.    

-The spawn coordinates X and Y is great. I saw the warning about it not being good to spawn in water. I set it to a water location to test it. I died right away in the water, but no game errors. This is exactly what I expected to happen; good.
-The Y coordinate seemed odd to me. I increased the Y coordinate and spawned further south. What I expected to happen was increasing Y would place me further north. Is this how it is meant to be? -While I like having custom coordinates, perhaps you could also add in drop-down menu with 12-16 options for preset spawn coordinates. Locations on each continent that is both central but also by the ocean for simplicity. This is so players do not need to experiment with custom coordinates to get close to where they want to be.
Something like this! { type = "string-setting", name = "spawn-location", setting_type = "runtime-global", default_value = "flanders-belgium", allowed_values = {"flanders-belgium", "cairo-egypt", "custom"}, order = "ba" }, Localization for the values have the name before it to work [string-mod-setting] spawn-location-flanders-belgium=Flanders, Belgium spawn-location-cairo-egypt=Cairo, Egypt spawn-location-custom=Custom

Possible drop-down menu options/locations:

  1. Custom - Uses the custom coordinate a player puts in the X and Y boxes.
  2. Europe (default)- Flanders Belgium is perfect central and very easy to know where to go from there.
  3. Europe- Gibraltar is well-known, good for Iberia, and going into Africa
  4. Africa- Cairo Egypt is a good spot to go into Middle East or into Africa.
  5. Africa- Cape town is on the southern portion of Africa.
  6. Asia- Seoul, Korea. Russia, China and Japan are close by.
  7. Asia- Calcutta, India. Good for going into Indo-china, China, or further into India.
  8. Oceania- Darwin, Australia. Big Northern city close to Pupa and Indonesia.
  9. N. America- D.C. is fairly close to the capital of Canada, but is by the ocean.
  10. N. America- Las Angeles. West coast and easy to move into Mexico.
  11. C. America- Panama. Easy to move into North or South America
  12. S. America- Rio de Janeiro is probably the most well-known location on the continent.
  13. Antarctica- Fossil Bluff is nearest the tip of S. America.
  14. Disabled- Factorio will use vanilla map generation, and won’t generate the Earth.

This is awesome. Thanks so much for making this mod.

TheOddler commented 6 years ago

Thanks for the suggestions! I like the idea with preset spawn points. I'll put it on my todo list :D No eta yet for this though.

About the y coordinate going south, that's just a consequence of some implementation details. Never really noticed it myself as being weird. Basically what is happening is that the spawn point stays at 0,0, but the whole world is shifter by those coordinates. Giving the illusion the spawn point changed. Probably not going to change this, since this would break save games of people already using the mod (well, newly generated parts of the world would shift).

sirlaige commented 6 years ago

Awesome thank you!

jonTucich commented 6 years ago

Hi,

I didn't see these changes in the version I have and didn't realize you had already made these. I made similar changes in my local copy and they work fine.

I also did a bit of spawn point testing and came up with these values:

--local spawn = {x =  248 * scale, y =  320 * scale}  -- Alaska
--local spawn = {x = 1532 * scale, y =  128 * scale}  -- Greenland
--local spawn = {x = 1024 * scale, y =  512 * scale}  -- Chicago (US)
--local spawn = {x = 1152 * scale, y = 1024 * scale}  -- South America
--local spawn = {x = 2064 * scale, y =  406 * scale}  -- Flanders (EU)
--local spawn = {x = 2134 * scale, y = 1016 * scale}  -- West Africa  
--local spawn = {x = 2304 * scale, y = 1024 * scale}  -- Central Africa  
--local spawn = {x = 2384 * scale, y =  384 * scale}  -- Eastern Europe
--local spawn = {x = 2384 * scale, y =  640 * scale}  -- Sinai
--local spawn = {x = 3072 * scale, y =  384 * scale}  -- Southern Russia
--local spawn = {x = 3072 * scale, y =  640 * scale}  -- Southern China
--local spawn = {x = 3584 * scale, y = 1280 * scale}  -- Australia

I tested using a scale of 2 - I've never played with the default scale of 6, always smaller.

Also, as a comment in the mods area suggested, if you want to get a single instance of the world and use the Max X, Max Y feature of the map generation, these are the settings that worked best in my testing: --local spawn = {x = 2134 scale, y = 1016 scale} -- West Africa
--Max X: multiple of 4,800 --Max Y: multiple of 1,700 I don't know if it is worthwhile to put these in the settings.lua, but they could be added to the info / doc so they are easy for people to know.

This is a great mod and it is the one I have been using for a few years.

thanks, jon

TheOddler commented 4 years ago

I just added this in the code, will release later today. I used the spawn locations from the CitiesOfEarth mod: https://github.com/HySpeed/CitiesOfEarth