Ja was soll ich sagen, ich release eine kleine Klasse um sehr einfach
Buttons, Bilder und Fenster zu erstellen. Da ich eine andere umfangreichere
Klasse erstellt habe, die einem anderen Prinzip folgt stelle ich diese kleine Klasse
einfach zu Download bereit. Sie ist sehr simpel gehalten und sollte sich gut
um neue Methoden erweitern lassen.
Ich release das Script unter der GPL Lizenz! Wenn ihr es downloaded stimmt ihr dieser zu.
Die Doku ist nicht vollständig und in englisch geschrieben.
Lua
--[[
shape.newWindow(x FLOAT, y FLOAT, width FLOAT, height FLOAT, color(use tocolor()), visible BOOL)
returns a window object
instance variables:
x
y
width
height
color
visible
buttons{} -- contains all child buttons
titles{} -- contains all child titles
images{} -- contains all child images
instance methodes:
delete() -- calls the destructor for this object, it removes everything included all events childs etc...
newButton(x FLOAT, y FLOAT, width FLOAT, height FLOAT, color(use tocolor()), visible BOOL, text STRING)
returns a button object
instance variables:
x
y
width
height
color
visible
text
instance methodes:
newClickFunctions -- adds a function wich is called when the button got pressed
newImage(x FLOAT, y FLOAT, width FLOAT, height FLOAT, visible BOOl, path STRING)
returns an image object
instance variables:
x
y
width
height
visible
path
newTitle(color (use tocolor()), visible BOOL, text STRING)
returns a title object
instance variables:
color
visible
text
There are some more functions in the window instance wich not need to be changed.
If a button is invisible he wont trigger any function, is the window invisible
all childs are invisible too and buttons wont trigger any function too.
The title adds a close button wich will call the destructor when pressed.
]]
Alles anzeigen
Ein kleines Beispiel:
Lua
addEventHandler("onClientResourceStart", getRootElement(), function()
showCursor(true)
window = shape.newWindow(0.33 * resolutionWidth, 0.1 * resolutionHeight, 0.33 * resolutionWidth, 0.6 * resolutionHeight, tocolor(0, 0, 255, 100), true)
title = window.newTitle(tocolor(0, 255, 0, 255), true)
title.newText("Willkommen auf Shape's Dev-Server...", tocolor(255, 0, 0, 255), 1, "arial", "center", "center")
image = window.newImage(0.34 * resolutionWidth, 0.15 * resolutionHeight, 0.31 * resolutionWidth, 0.50 * resolutionHeight, true, "shape.png")
local frame = 0
addEventHandler("onClientRender", getRootElement(), function()
frame = frame + 1
if (window) then
if (frame == 15) then
frame = 0
local r = math.random(1, 255)
local g = math.random(1, 255)
local b = math.random(1, 255)
local a = math.random(1, 255)
window.color = tocolor(r, g, b, a)
end
else
removeEventHandler("onClientRender", getRootElement(), debug.getinfo(1,"f").func)
end
end
)
end
)
Alles anzeigen