Today I will show you a demonstration of the Mooshine core interpreter running two different Lua programs which utilise the Firefox browser.
The first program as outlined below tests the standard module:
-------------------------------
-- test standard module
-------------------------------
print("\n" .. std.version() .. "\n") -- print version
std.msg("Hello from Moonshine!") -- display message
local ans = std.prompt("Enter number:") -- display prompt
It does the following...
- Prints the version of the standard module in the interpreter
- Displays a message box in the browser
- Displays a prompt for user input
The second program retrieves the latest XKCD comic panel (a example of which is in this post) from the XKCD atom feed and displays it in a new browser window...
----------------------------------
-- display latest xkcd web
-- comic from the xkcd atom feed
-- in a new browser window
----------------------------------
-- make a request for xkcd comic feed
feed = net.httpreq("http://xkcd.com/atom.xml")
-- match comic panel
img = string.match(feed,
"http\:\/\/imgs.xkcd.com\/comics\/[%w%_]+.png")
-- display comic panel in a new window
std.window(img)
The current version of the Moonshine core interpreter is an executable written in C with embedded Lua. Most of the functionality itself comes from the included modules.
To properly work as part of my extension, I will rewrite the core intepreter in C++ as an XPCOM component (which use classes).
See the demonstration (animated GIF)
Image courtesy of xkcd (CC-BY-NC)