Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- CONCEPT/SKETCH, NOT FINAL
- local handles = {} -- Interface System applications are formatted as tables, like almost everything in lua.
- handles.intsys = true -- This is indeed an Interface System program. This might not actually be very useful.
- handles.sysver = 0 -- Intended system version, fails if it's higher.
- local window = nil
- local bananaText = "Banana"
- local function onBanana() bananaText = "No more banana" end
- local function getBananaText() return bananaText end
- -- Main function, this is executed as a coroutine. Instead of using os.sleep, you will do coroutine.yield
- function handles.main()
- window = intsys.makeWindow() -- Creates the window with all of its preset functions.
- window.title = "Hello Mario." -- if nil then the window is drawn with no title.
- -- Enables/disables the button on the titlebar.
- window.canClose = true
- window.canResize = true
- window.setSize(100, 100)
- -- window.add will add a control to the list of controls for the window.
- -- A control is a table of.. functions and stuff.
- -- If formatted correctly, you can make your own!
- -- A generic persistant text control, that just draws text on redraw.
- window.add(window.makeText(5, 5, "Hello Luigi."))
- -- Buttons take a function reference to execute, if not nil.
- window.add(window.makeButton(5, 20, "Banana", onBanana))
- -- These controls can use functions to get their text from as well.
- -- This marks it as an "active" control. When windows redraw, the function is ran.
- window.add(window.makeText(5, 30, getBananaText))
- -- If you wanted the button to change its text for example
- --window.add(window.makeButton(5, 20, getBananaText, onBanana))
- -- These controls most likely lack features that will be present later on.
- -- It is possible there will be handles to the window such as "update" and "redraw".
- -- Adds the window to the internal list, so it is updated and redrawn, etc. Marks "exists" as true.
- intsys.registerWindow(window)
- -- Infinite looping program, this is usually how you would do your update logic.
- -- window.exists returns false if the window no longer is registered. You can probably re-register it if you wanted to.
- -- After the coroutine is no longer valid, Interface System will automatically de-list the program.
- while window.exists do
- coroutine.yield()
- end
- -- De-init down here if necessary.
- end
- return handles -- Returns the program's handles back to Interface System.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement