Commit c52ccfbc authored by Danny SMc's avatar Danny SMc

Fixed example plugin

parent f4599295
......@@ -12,10 +12,16 @@ Plugin.example = {};
--// Create init function
function Plugin.example.entry()
--// Sets screen colour
base.screen.colour("lightBlue")
--// Center text and write
base.draw.textc("Initialising Example Plugin", 9, false, "white", "lightBlue")
--// Wait one second
sleep(1)
--// This is the logo for the home menu
local exampleicon = {
{"c:c: ","c:c: ","c:c: ","c:c: ","c:c: ","c:c: ","c:c: ","c:c: ","c:c: ","c:c: ","c:c: ","c:c: ","c:c: ","c:c: "};
{"c:c: ","c:c: ","c:c: ","c:c: ","c:c: ","c:c: ","c:c: ","c:c: ","c:c: ","c:c: ","c:c: ","c:c: ","c:c: ","c:c: "};
......@@ -32,18 +38,68 @@ end
--// Create actual function
function program.example.new()
--// Set screen colour before drawing menu
base.screen.colour("lightBlue")
base.draw.textc("Nice one! Example plugin is now usable", 10, false, "white", "lightBlue");
--// Set base scroll value
local scroll = 0;
local exampleData = {"Data1";"Data2";"Data3";"Data4";"Data5";"Data6";"Data7";"Data8";"Data9";"Data10";"Data11";"Data12";"Data13";"Data14";"Data15";"Data16";"Data17";"Data18";"Data19";}
--// Draw menubar with title
program.draw.menubar("Example")
--// Render function for on screen drawing, useful when you want to do scrolling etc
local function render(scroll)
base.draw.textc("Nice one! Example plugin is now usable", 19, false, "white", "lightBlue");
for i=1, 14 do
base.draw.texta(tostring(i+scroll) .. " -> " .. tostring(exampleData[i+scroll]), 3, i+3, false, "grey", "lightBlue")
end
end
--// Run render with scroll first to draw screen
render(scroll)
--// Create event loop
while true do
--// Wait/Catch for events
local args = { os.pullEvent() }
--// If the timer event fires redraw menu so the clock works
if args[1] == "timer" then
--// Re-draw menu for clock
program.draw.menubar("Example")
--// On mouse click
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Example", args[3], args[4])
end
--// On mouse scroll
elseif args[1] == "mouse_scroll" then
--// On scroll up
if args[2] == -1 then
--// Check scroll is bigger than 0 otherwise do nothing
if scroll > 0 then
--// Increment scroll value
scroll = scroll -1
--// Redraw screen with scroll
render(scroll)
end
--// On scroll down
elseif args[2] == 1 then
--// If scroll + screensize (usually 14) is smaller than the length of the exampleData count then scroll down
if scroll + 14 < #exampleData then
--// Increment scroll
scroll = scroll + 1
--// Redraw screen with scroll
render(scroll)
end
end
end
end
end
\ No newline at end of file
......@@ -223,16 +223,6 @@ Internal.MenuEntries = {};
DiscoverApp = {
Register = {
NameSpace = function(name)
if not program[name] then
program[name] = {};
return true;
else
printError("Your namespace is used by another plugin!!")
sleep(1.5)
return false;
end
end;
MenuIcon = function(iconname, icondata)
if Internal.Icons[iconname] == nil then
Internal.Icons[iconname] = icondata;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment