Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local files = {
- ["init"] = "require \"UIButton\"\
- require \"UIContainer\"\
- require \"UITabs\"\
- require \"UIText\"\
- \
- local function quit()\
- application:stop() term.clear() term.setCursorPos(1,1) \
- end\
- \
- application.view:createShortcut(\"terminate\",\"ctrl-t\",quit)\
- local close = application.view:addChild(UIButton(application.view.width-1,0,1,1,\"X\"))\
- close.colour = colors.red\
- close.textColour = colors.black\
- close.onClick = quit\
- \
- local peripherals = peripheral.getNames()\
- \
- for i,v in ipairs(peripherals) do\
- local p = peripheral.wrap(v)\
- if not p.listMethods then\
- table.remove(peripherals,i)\
- end\
- end\
- \
- local tabs = application.view:addChild(UITabs(1,1,application.view.width-2,peripherals))\
- \
- local m_cont = application.view:addChild(UIContainer(1,3,application.view.width-2,application.view.height-4))\
- \
- local text_cont = UIContainer(1,3,application.view.width-2,application.view.height-4)\
- local back_btn = text_cont:addChild(UIButton(0,0,text_cont.width-1,1,\"Back\"))\
- back_btn.textColour = colors.red\
- \
- local m_texts = {}\
- \
- local function display_method(pname,mname)\
- m_cont:remove()\
- text_cont:remove()\
- application.view:addChild(text_cont)\
- for _,text in ipairs(m_texts) do\
- text:remove()\
- end\
- local p = peripheral.wrap(pname)\
- local m = p.getAdvancedMethodsData(mname)\
- local y = 1\
- local header = \"@tb\" .. mname .. \"(\"\
- for i,v in ipairs(m.args) do\
- if m.args[i+1] then\
- header = header .. ((v.optional and \"@t9[\") or \"@t9\") .. v.name .. ((v.optional and \"]@t7, \") or \"@t7, \")\
- else\
- header = header .. ((v.optional and \"@t9[\") or \"@t9\") .. v.name .. ((v.optional and \"]\") or \"\")\
- end\
- end\
- header = header .. \"@tb)\"\
- local header_text = text_cont:addChild(UIText(0,y,text_cont.width-1,1,header))\
- header_text.internalWidth = header_text.width - 1\
- header_text.height = header_text:getContentHeight()\
- table.insert(m_texts,header_text)\
- y = y + header_text.height + 1\
- \
- local desc = ((m.description ~= \"\" and m.description) or \"@t8<No description found>\")\
- local desc_text = text_cont:addChild(UIText(1,y,text_cont.width-2,1,desc))\
- desc_text.internalWidth = desc_text.width - 1\
- desc_text.height = desc_text:getContentHeight()\
- table.insert(m_texts,desc_text)\
- y = y + desc_text.height + 1\
- \
- if #m.args > 0 then\
- local args_text = text_cont:addChild(UIText(0,y,text_cont.width-1,1,\"Arguments\"))\
- args_text.internalWidth = args_text.width - 1\
- args_text.height = args_text:getContentHeight()\
- table.insert(m_texts,args_text)\
- y = y + args_text.height + 1\
- \
- for i,v in ipairs(m.args) do\
- local arg = \"@t9\"..v.name..\"@t7: \" .. ((v.description ~= \"\" and v.description) or \"@t8<No description found>\")\
- local arg_text = text_cont:addChild(UIText(1,y,text_cont.width-2,1,arg))\
- arg_text.internalWidth = arg_text.width - 1\
- arg_text.height = arg_text:getContentHeight()\
- table.insert(m_texts,arg_text)\
- y = y + arg_text.height\
- end\
- y = y + 1\
- end\
- if m.returnTypes ~= \"()\" then\
- local ret = \"Returns @t9\" .. m.returnTypes\
- local ret_text = text_cont:addChild(UIText(0,y,text_cont.width-1,1,ret))\
- ret_text.internalWidth = ret_text.width - 1\
- ret_text.height = ret_text:getContentHeight()\
- table.insert(m_texts,ret_text)\
- y = y + ret_text.height\
- end\
- text_cont:setVerticalOffset(0)\
- end\
- \
- local m_btns = {}\
- \
- local function show_method_buttons(pname)\
- m_cont:remove()\
- text_cont:remove()\
- application.view:addChild(m_cont)\
- local p = peripheral.wrap(pname)\
- local m = (p.getAdvancedMethodsData and p.getAdvancedMethodsData()) or {}\
- -- remove old children\
- for _,btn in ipairs(m_btns) do\
- btn:remove()\
- end\
- m_btns = {}\
- -- add new buttons\
- local ypos = 0\
- for name,data in pairs(m) do\
- local b = m_cont:addChild(UIButton(0,ypos,m_cont.width-1,1,name))\
- function b:onClick()\
- display_method(pname,name)\
- end\
- table.insert(m_btns,b)\
- ypos = ypos + 1\
- end\
- m_cont:setVerticalOffset(0)\
- end\
- \
- function back_btn:onClick()\
- show_method_buttons(peripherals[tabs.selected])\
- end\
- \
- function tabs:onSelect()\
- show_method_buttons(peripherals[self.selected])\
- end";
- }
- if not fs.exists "Flare" then
- print "Downloading Flare"
- local h = http.get "http://pastebin.com/raw.php?i=SD25GhYf"
- if h then
- local f, err = load( h.readAll(), "installer", nil, _ENV or getfenv() )
- h.close()
- f()
- else
- return error( "Cannot install Flare", 0 )
- end
- end
- local loader
- local h = fs.open( "Flare/run.lua", "r" )
- if h then
- loader = h.readAll()
- h.close()
- else
- error( "failed to read Flare", 0 )
- end
- local f, err = load( loader, "Flare", nil, _ENV or getfenv() )
- if not f then
- error( "there was a problem with Flare!: " .. err, 0 )
- end
- f( files, "init", ... )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement