local
function load(std, data)
data._menu = 1
data._msg = 'loading...'
std.http.get('http://t.gamely.com.br/games.json')
data._msg = std.http.error
end)
data._msg = tostring(std.http.status)
end)
data._list = std.json.decode(std.http.
body)
data._msg = nil
end)
:run()
end
local function keys(std, data)
if data._game then return end
if not data._list then return end
data._menu = std.math.
clamp2(data._menu + std.key.axis.y, 1, #data._list)
if std.key.press.a then
data._game = {}
std.http.get(data._list[data._menu].raw_url)
data._game = std.node.load(std.http.body)
std.node.spawn(data._game)
std.bus.emit('init')
std.bus.emit('i18n')
end)
:run()
end
end
local function draw(std, data)
if data._game then return end
std.draw.clear(0x333333FF)
std.draw.color(std.color.white)
if data._msg then
std.text.put(1, 1, data._msg)
return
end
while index <= #data._list
do
std.text.put(32,
index, data._list[
index].version)
end
std.draw.color(std.color.red)
std.text.put(1, data._menu, '>', 1)
end
local function quit(std, data)
std.bus.abort()
std.node.kill(data._game)
data._msg = 'loading angain...'
data._game = nil
end
local P = {
meta={
title='Launcher Games',
description='online multi game list',
author='Rodrigo Dornelles',
version='1.0.0'
},
config={
require='http math.random math json i18n'
},
callbacks={
load=load,
key=keys,
draw=draw,
quit=quit
}
}
return P
local function index(array, func, reverse)
std.array.index
local function success(handler_func)
local function body(content)
local function error(handler_func)
local function failed(handler_func)
local function clamp2(value, value_min, value_max)
std.math.clamp2
local function load(application)
create new node