[MOD 0.11.19+] Increments

Topics and discussion about specific mods
User avatar
XyLe
Fast Inserter
Fast Inserter
Posts: 124
Joined: Fri Oct 31, 2014 10:45 am
Contact:

Re: [MOD 0.11.19+] Increments

Post by XyLe »

I've just updated the mod, awesome work, thanks !!

one problem though - with my save not everything is fine, e.g. there is day/night cycle but there's no technology for night vision or lights, also i don't see any gui for activating handcrafting.

please tell me what i have to do to have full functionality when loading a saved game.

btw, if you wanna encourage machine crafting - just make handcrafting a lot slower. like 4 times slower. that way people will be able to craft a chest or a tool without trouble but for complex stuff it'll be a pain to craft everything by hand.

Justin Festa
Inserter
Inserter
Posts: 28
Joined: Wed Feb 04, 2015 12:07 pm
Contact:

Re: [MOD 0.11.19+] Increments

Post by Justin Festa »

ya i just noticed that migration wasnt working for saves... working on it

User avatar
XyLe
Fast Inserter
Fast Inserter
Posts: 124
Joined: Fri Oct 31, 2014 10:45 am
Contact:

Re: [MOD 0.11.19+] Increments

Post by XyLe »

thank you very much :)

Justin Festa
Inserter
Inserter
Posts: 28
Joined: Wed Feb 04, 2015 12:07 pm
Contact:

Re: [MOD 0.11.19+] Increments

Post by Justin Festa »

well im having difficulty finding out how to reload in a save, it doesnt look like any mode does it (that ive checked so far) and the wiki is no help as usual.... IF anyone with the knowhow is reading this let me know how to update in a save specific files like control.lua

Justin Festa
Inserter
Inserter
Posts: 28
Joined: Wed Feb 04, 2015 12:07 pm
Contact:

Re: [MOD 0.11.19+] Increments

Post by Justin Festa »

Unless someone wants to go over my files and figure it out, v1.2 breaks saves. You will have to start over. Unfortunately I'm too new to this to figure it out at the moment.

User avatar
XyLe
Fast Inserter
Fast Inserter
Posts: 124
Joined: Fri Oct 31, 2014 10:45 am
Contact:

Re: [MOD 0.11.19+] Increments

Post by XyLe »

I think treefarm had no problems with saved games. But i'm not 100% sure, it was a while ago.

Justin Festa
Inserter
Inserter
Posts: 28
Joined: Wed Feb 04, 2015 12:07 pm
Contact:

Re: [MOD 0.11.19+] Increments

Post by Justin Festa »

im still looking on a way to fix, it involves changing the structure of my code. I have to do it anyways for the planned eclipse events and whatnot, but it might be a while like next week unless I magically figure it out.

i mean to be specific the gui code is created when a player is first created, and it should prolly be on load. Unfortunately im not sure of what commands to use on load so it will be a while ;)

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

Re: [MOD 0.11.19+] Increments

Post by Choumiko »

If i understand correctly the problem is that in old saves the gui isn't created?
Add the following function in your control.lua, remove the corresponding code from onplayercreated/oninit/onload and add the function call to oninit/onload

Code: Select all

function initGlob()
  --day/night extender cycle code
  glob.counter = glob.counter or 0
  counter = glob.counter 
  glob.freeze_state = (type(glob.freeze_state) == "nil" ) and false or glob.freeze_state
  freeze_state = glob.freeze_state

  for pi, player in pairs(game.players) do
    if not player.gui.top.label1 then
      --hand crafting toggle
      player.gui.top.add{name= "label1", type = "label", caption = "Machine Crafting Only"}
      local button = player.gui.top.add{name = "toggle", type = "button", caption = "ON"}
      button.style.fontcolor = {r = 0, g = 1, b = 0}
    end
  end
end
For a simple toggle i would only add a console command though (Script interfaces) or even just have the player change a value in a config.lua (depending on how often you expect the player wanting to change modes)
Justin Festa wrote:well im having difficulty finding out how to reload in a save, it doesnt look like any mode does it (that ive checked so far) and the wiki is no help as usual.... IF anyone with the knowhow is reading this let me know how to update in a save specific files like control.lua
In my mods i use a initGlob() function, that gets called oninit and onload, looks like this

Code: Select all

function initGLob()
    if glob.version == nil or glob.version < "0.1.1" then
      glob = {}
      glob.settings = {}
      glob.version = "0.1.1"
    end
--snipped stuff (glob.something = glob.something or defaultValue, etc)
    if glob.version < "0.1.8" then
      glob.settings.poleDistance = nil
      glob.settings.poleSide = nil
      if glob.medium then
        glob.settings.straight = defaultsMediumStraight
        glob.settings.diagonal = defaultsMediumDiagonal
      else
        glob.settings.straight = defaultsStraight
        glob.settings.diagonal = defaultsDiagonal
      end
      glob.version = "0.1.8"
    end
    GUI.init()
    glob.version = "0.2.4"
end
Sort of a handmade migration for glob. If it starts to get too messy you can remove old stuff and the player then has to first upgrade to the older version and then to the latest (for really old saves you even have to do it for vanilla Factorio)

Justin Festa
Inserter
Inserter
Posts: 28
Joined: Wed Feb 04, 2015 12:07 pm
Contact:

Re: [MOD 0.11.19+] Increments

Post by Justin Festa »

ok ill see if this helps, thanks alot

User avatar
XyLe
Fast Inserter
Fast Inserter
Posts: 124
Joined: Fri Oct 31, 2014 10:45 am
Contact:

Re: [MOD 0.11.19+] Increments

Post by XyLe »

Hey i wanna make a mod for a couple of electricity-related things, would it be ok if i took 1 of your files to be a part of my mod? I only want an upgraded substation and yours would fit perfectly so i can't be bothered writing basically the same code from scratch. What do you think?

Justin Festa
Inserter
Inserter
Posts: 28
Joined: Wed Feb 04, 2015 12:07 pm
Contact:

Re: [MOD 0.11.19+] Increments

Post by Justin Festa »

by all means =)

User avatar
XyLe
Fast Inserter
Fast Inserter
Posts: 124
Joined: Fri Oct 31, 2014 10:45 am
Contact:

Re: [MOD 0.11.19+] Increments

Post by XyLe »

Thank you very much! )

Kelidoskoped
Burner Inserter
Burner Inserter
Posts: 12
Joined: Tue Mar 29, 2016 11:45 pm
Contact:

Re: [MOD 0.11.19+] Increments

Post by Kelidoskoped »

DL just for the truck, NO MOAR TRAINS! Now to make an autopilot.. FACTORIO UBERS

Post Reply

Return to “Mods”