View Single Post
Old 05-06-2019, 08:44 PM   #471
Human being with feelings
Lokasenna's Avatar
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,081

Originally Posted by tXShooter View Post
That's bloody brilliant!

(What does the params {36} do?)
When you create a button the normal way:

GUI.Button:new("my_btn", 1, 32, 32, 64, 22, "Click me!", do_the_thing, 4)
...any parameters given after do_the_thing are bundled and then passed to that function when the button calls it.

When creating a button as an object:

GUI.Button:new("my_btn", {
  z = 1,
  x = 32,
  y = 32,
  w = 64,
  h = 22,
  caption = "Click me!",
  func = do_the_thing,
  params = {4},
... you have to bundle the parameters up yourself into a table and provide it as params. For the script the code above is from, the function inserts a MIDI note with a few specific values, and the parameter is just the note number.
Lokasenna is offline   Reply With Quote