Posted 23 March 2015 - 10:44 AM
Hello.
I've been working on new object API (that will add buttons etc.) and i want it to be easy in use. I mean:
Making button:
Example code:
I've been working on new object API (that will add buttons etc.) and i want it to be easy in use. I mean:
Making button:
obj.createButton(top left corner: x cord, y cord, down right corner: x cord, y cord, text on button, color (0-15),id)
The problem is, that i do not know how to make custom event (i mean API user's code waits with event:
local evnt = { os.pullEvent("button_click") }
When this event code is waiting, my API waits for normal mouse click on button using
mouse_click
So how to make that custom event? Can it use multiple parameters? IS IT EVEN POSSIBLE? Oh. and can API access local variables in code that uses it?Example code:
os.loadAPI("obj")
os.loadAPI("ccb") --another api i am working at. it is used to draw custom size box. ya know? buttons mostly base on it. (drawing button). also this api also prints text on box. so obj api is type of api that uses another api.
obj.createButton(1,1,5,5,test,4,3)
while true do
local evnt = { os.pullEvent("button_click")
if evnt == 3 then --tests for click of button with id 3
term.setCursorPos(8, 8)
print("writed")
sleep(5)
term.clear() --term.clear() clear entire terminal. it also HIDES button. You can always reviwe button with it's old parameters (cords,id,text,color) by using obj.reviweButton(id)
obj.reviweButton(3)
end
end
Edited on 23 March 2015 - 10:02 AM