Reply To: General Programming/Lua question

Home Forums General Programming General Programming/Lua question Reply To: General Programming/Lua question

#120469
dnaldoog
Participant
  • Topics: 4
  • Replies: 480
  • Total: 484
  • ★★

In the lua editor, Right click on the lua cube and create a function by clicking on Add Method.

Then you can access that function globally and call it from multiple parts of your panel.


------global------function
myRandom = function()
    return (math.random(0, 512))
end
------global------function
a = function()
    local b = myRandom()
    return b + b
end

b = function(n)
    if n == true then
        return myRandom()
    end
end

console(tostring(a()))
console("" .. b(true))
console(tostring(myRandom()))

Regards,

  • This reply was modified 1 year, 6 months ago by dnaldoog.
Ctrlr