Skip to content

Commit

Permalink
Add Ui:setVar & Ui:format
Browse files Browse the repository at this point in the history
- self Ui:setVar(var, value) - Sets a variable in the ui table to the given value. Useful to set any variable in the ui instance table while function chaining.
- self Ui:format(fn, ...) - runs a function fn(self, ...) to format the ui instance in some way while function chaining.
  • Loading branch information
Lemonymous committed Oct 23, 2022
1 parent 645ec9e commit 9e97455
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions scripts/mod_loader/ui/widgets/base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,18 @@ function Ui:endUi()
return self.parent
end

-- Sets a variable in the ui table to the given value.
function Ui:setVar(var, value)
self[var] = value
return self
end

-- Run a function fn(self, ...) to format the ui object in some way.
function Ui:format(fn, ...)
fn(self, ...)
return self
end

function Ui:show()
self.visible = true

Expand Down

0 comments on commit 9e97455

Please sign in to comment.