Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Custom helper text for functions and classes

It would be nice if we could enter our own helper text (the popup text when typing the parameters for ellipse() for example) for functions or classes we've built. Maybe by using special optional syntax, where we define the function or class.

For example:

function doSomething( vel;"velocity", col;"color", a;"angle")
   ...
end

Or maybe this is already possible?

Comments

  • Posts: 2,020

    @Kirl no this isn't possible

    If you have a complex function, particularly one with multiple optional variables, then consider passing a dictionary of variables to the function eg:

    function myClass:init(p) --a single table of parameters
      self.vel, self.color, self.angle = p.vel, p.color, p.angle
    

    In Lua, if a function takes a single string or a single variable as its argument, you can omit the () from the call. So you can call the function like this:

    myInstance = myClass{vel = vec2(50,0), color = color(255,128), angle = math.random(360)}
    

    Although this is more typing (and slightly more resource intensive as you're creating a table), it does make the function call easier to read, and is particularly useful where there are multiple optional arguments

  • Posts: 181

    Thanks yojimbo, that is a nice alternative!

Sign In or Register to comment.