Modding Help How to transfer and receive value in Lua to another Lua?

Discussion in 'Starbound Modding' started by PaulFors, Jul 21, 2019.

  1. PaulFors

    PaulFors Intergalactic Tourist

    How to pass a value from a.lua to b.lua?

    let's say that in my a.lua I have this variable code.

    Code:
    value = 5
    My problem is, how can I pass the value from a.lua to b.lua?

    thanks in advance....
     
  2. bk3k

    bk3k Oxygen Tank

    I'm not sure what exactly the application is that you're trying to store a value you need in a separate .lua file, but that's pretty basic. Supposing these are in /scripts/ then add this in your b.lua

    Code:
    require "/scripts/a.lua"
    This is usually done at the top, but it could be done anywhere even conditionally.
    That will append the contents of a.lua into the same environment. If by chance you already had "value" defined in b.lua, the "value" of a.lua will over-write it. There are tons of examples of this in vanilla code anyhow.
     
  3. PaulFors

    PaulFors Intergalactic Tourist

    Code:
    require "/scripts/a.lua"
    not suitable for beamaxe.lua (b.lua). ERROR

    I need to prohibit an alternative manipulator attack when the value of a variable from a.lua = 1.

    I'm doing something wrong.:(
     

Share This Page