title: Access or change a local variable, which inside a function, outside of it?
body: <p>I've a bit of a problem trying to make a mod for a particular game. You might have heard of it, it's called Don't Starve Together.</p>
  
  <p>Inside the game's data, there's a file called tuning.lua which handles a lot of the initial variables. Inside of it is just a function, under which are some local variables and a table/array/list called TUNING, which contains a bunch of global variables. The local variables underneath the function I cannot access as they're local, but I can't change anything there either, because they are local variables.</p>
  
  <p>So, instead I'm working from within a completely different file, which inside my mod, called modmain.lua. So, my question is, how can I take a local variable from the function that is inside the tuning.lua script and change it/use it from within modmain.lua? Here's a snippet of tuning.lua code:</p>
  
  <pre><code>TUNING = {} -- the table is created
  
  
  function Tune(overrides)
      if overrides == nil then
          overrides = {}
      end
      --the following are the local variables used in the game
      local seg_time = 30
      local total_day_time = seg_time*16
  
      local day_segs = 10
      local dusk_segs = 4
      local night_segs = 2
  
      --default day composition. changes in winter, etc
      local day_time = seg_time * day_segs
      local dusk_time = seg_time * dusk_segs
      local night_time = seg_time * night_segs
  
      local multiplayer_attack_modifier = 1
      local multiplayer_goldentool_modifier = 1
      local multiplayer_armor_durability_modifier = 0.7
      local multiplayer_armor_absorption_modifier = 1
      local multiplayer_wildlife_respawn_modifier = 1
  
      local wilson_attack = 34 * multiplayer_attack_modifier
      local wilson_health = 150
      local calories_per_day = 75
  
      local wilson_attack_period = .1
      -----------------------
  
      local perish_warp = 1--/200
  
      TUNING =
      {
      --global variables go here
      }
  end
  </code></pre>
  
  <p>So, lets say I wanted to take total_day_time and change it to 24 within modmain.lua. What code would I need to write there to do so? Or is this impossible? Basically, I'm trying to increase the amount of day segments (as well as extend the segment time) in the game and this seems to be the only place where it's accessed from. There is a mod out there that increases segment time, but there is no mod which increases segment amount. <a href="http://vignette2.wikia.nocookie.net/dont-starve-game/images/5/55/Summer_Day-Night_cycle.png/revision/latest?cb=20130305133916" rel="nofollow">Here's segments that I'm talking about, in case you have no idea.</a></p>