math.random returns the same numbers

  • #40, z sebastianThursday, 17. November 2016, 15:20 hodinky 8 years ago
    when you make it local inside a function, its only available inside the function

    Kapitán

    2346 Posts


  • #41, z afrlmeThursday, 17. November 2016, 15:58 hodinky 8 years ago
    As Sebastian says, you need to declare it as local inside of a function if you want it to only be accessible from inside of the function & sorry, I didn't realize what you was talking about. I was referring to these myself...
    function name(var1, var2)
    
      var1 = Objects[var1]
    
      var2 = Scenes[var2]
    
    end
    
    
    
    name("rock", "beach")

    The input variables of your function become local automatically. Manually declared variables will either need to be set local by you or left as global.

    Imperátor

    7285 Posts

  • #42, z ke4Thursday, 17. November 2016, 17:06 hodinky 8 years ago
    Oh interesting, didn't know that. Anyway what i meant exactly is if it's not declared as local, is it as global for the whole engine or is as local for the current script. That it would be accessible outside of the function but only in the same script

    Zabiják klíčů

    810 Posts

  • #43, z afrlmeThursday, 17. November 2016, 18:17 hodinky 8 years ago
    local is local inside of whatever you declare a variable.

    If you declare a variable inside of the main script then any function or loop block inside of the same script can access it. If you declare a local variable inside of a function or loop block then it will only be accessible from inside of that function or loop block.

    Imperátor

    7285 Posts

  • #44, z ke4Thursday, 17. November 2016, 20:01 hodinky 8 years ago
    Thanks for explaining razz

    Zabiják klíčů

    810 Posts

  • #45, z afrlmeThursday, 17. November 2016, 20:09 hodinky 8 years ago
    Thanks for explaining razz

    No problem at all mate. smile

    Imperátor

    7285 Posts