Jump to content

eksorz

Members
  • Posts

    4
  • Joined

  • Last visited

eksorz's Achievements

Vic

Vic (3/54)

0

Reputation

  1. No, like this: Button({ ... }) iprint(debug.traceback())
  2. I printed the traceback method you gave me right after creating the Button object. In the line I printed, it said "in main chunk", I don't know what it means.
  3. I am sure that the problem is not in the injectModules() function. There is a prepared Window class next to the Button class, I can use it as Window({...}) by using the injectModules() function. Similarly, I can print the button and get the argument variables by using Button({...}). Only function operations return "nil" value.
  4. Hi, I created a constructor function to create an object. Inside this function, a function named "onClick" is defined and this function is mandatory because I am writing a DX library. However, when I create the object, even if I define the onClick function inside the object, it always returns the value as "nil". I did a few tests, it has nothing to do with mouse locations or anything else. The button click function works, the only problem is that I cannot define the onClick function. -- // Button.lua constructor: function createButton(config) local self = setmetatable({}, Button) self.x = config.x self.y = config.y self.width = config.width self.height = config.height self.text = config.text or "Button" self.color = config.color or "blue" self.fade = config.fade ~= false self.onClick = config.onClick or false -- // This always returns false, even if I added onClick function. self.alpha = self.fade and 0 or 255 self.fade_step = 15 self.visible = true self.currentColor = Theme.colors.button[self.color].background table.insert(activeButtons, self) return self end -- // Example.lua, example for using: loadstring(exports.ui:injectModules())() local btn = Button({ x = 20, y = 60, width = 100, height = 30, text = "Click", color = "blue", fade = true, onClick = function(self) outputChatBox("Clicked the button.") -- // It's not working. end })
×
×
  • Create New...