Another fix for events
This commit is contained in:
13
src/main.lua
13
src/main.lua
@@ -200,13 +200,20 @@ local function renderFrames()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Runs basalt once
|
--- Runs basalt once, can be used to update the UI manually, but you have to feed it the events
|
||||||
--- @shortDescription Runs basalt once
|
--- @shortDescription Runs basalt once
|
||||||
--- @vararg any The event to run with
|
--- @vararg any The event to run with
|
||||||
--- @usage basalt.update()
|
--- @usage basalt.update()
|
||||||
function basalt.update(...)
|
function basalt.update(...)
|
||||||
updateEvent(...)
|
local f = function(...)
|
||||||
renderFrames()
|
updateEvent(...)
|
||||||
|
renderFrames()
|
||||||
|
end
|
||||||
|
local ok, err = pcall(f, ...)
|
||||||
|
if not(ok)then
|
||||||
|
errorManager.header = "Basalt Runtime Error"
|
||||||
|
errorManager.error(err)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Stops the Basalt runtime
|
--- Stops the Basalt runtime
|
||||||
|
|||||||
@@ -44,11 +44,12 @@ end
|
|||||||
local function parseEvents(content)
|
local function parseEvents(content)
|
||||||
local events = {}
|
local events = {}
|
||||||
for line in content:gmatch("[^\r\n]+") do
|
for line in content:gmatch("[^\r\n]+") do
|
||||||
|
|
||||||
local name, description = line:match("%-%-%-@event%s+([%w_]+)%s+(.+)")
|
local name, description = line:match("%-%-%-@event%s+([%w_]+)%s+(.+)")
|
||||||
if name then
|
if name then
|
||||||
local functionName = name:gsub("_(%w)", function(c) return c:upper() end)
|
-- Entferne das "on" Präfix falls vorhanden
|
||||||
functionName = "on" .. functionName:sub(1,1):upper() .. functionName:sub(2)
|
local baseName = name:match("^on(.+)") or name
|
||||||
|
-- Konvertiere erste Buchstabe zu Großbuchstaben
|
||||||
|
local functionName = "on" .. baseName:sub(1,1):upper() .. baseName:sub(2)
|
||||||
|
|
||||||
events[#events + 1] = {
|
events[#events + 1] = {
|
||||||
name = name,
|
name = name,
|
||||||
@@ -127,11 +128,9 @@ local function generateClassContent(className, properties, combinedProperties, e
|
|||||||
table.insert(content, string.format("--- Gets the %s", combinedProp.description))
|
table.insert(content, string.format("--- Gets the %s", combinedProp.description))
|
||||||
table.insert(content, string.format("---@generic Element: %s", className))
|
table.insert(content, string.format("---@generic Element: %s", className))
|
||||||
table.insert(content, "---@param self Element")
|
table.insert(content, "---@param self Element")
|
||||||
local returns = {}
|
|
||||||
for _, prop in ipairs(combinedProp.properties) do
|
for _, prop in ipairs(combinedProp.properties) do
|
||||||
table.insert(returns, prop.type)
|
table.insert(content, string.format("---@return %s %s", prop.type, prop.name))
|
||||||
end
|
end
|
||||||
table.insert(content, string.format("---@return %s", table.concat(returns, " ")))
|
|
||||||
table.insert(content, string.format("function %s:get%s()",
|
table.insert(content, string.format("function %s:get%s()",
|
||||||
className,
|
className,
|
||||||
combinedProp.name:sub(1,1):upper() .. combinedProp.name:sub(2)
|
combinedProp.name:sub(1,1):upper() .. combinedProp.name:sub(2)
|
||||||
|
|||||||
Reference in New Issue
Block a user