gamepad.src
// gamepad client
shell = get_shell
localmachine = shell.host_computer
game_path = "/root/game.shr"
local = user_input("[0] - remote"+char(10)+"[1] - local"+char(10)+"||: ",0,1).to_int
if local then
game_file = localmachine.File(game_path)
else
print("<b>Establishing remote connection</b>...")
game_shell = shell.connect_service(user_input("server ip:> "),user_input("server pt:> ").to_int,user_input("user:> "),user_input("pass:> "))
game_file = game_shell.host_computer.File(game_path)
end if
if not game_file then return game_path+" not found."
IO = null
gaming = true
while gaming
if IO == game_file.get_content then
// skip
else
print(game_file.get_content)
IO = user_input("||: ",0,1)
game_file.set_content(IO)
end if
end while
//gamepad server
shell = get_shell
localmachine = shell.host_computer
game_path = "/root/game.shr"
game_file = localmachine.File(game_path)
if not game_file then return game_path+" not found."
IO = game_file.get_content
left = function()
return "LEFT"
end function
right = function()
return "RIGHT"
end function
up = function()
return "UP"
end function
down = function()
return "DOWN"
end function
get_action = function(arg)
arg = arg[0].trim
print(arg)
action = {}
action.LeftArrow = left
action.RightArrow = right
action.UpArrow = up
action.DownArrow = down
if action.hasIndex(arg) then
a = @action[arg]
return a
else
return ""
end if
end function
gaming = true
while gaming
if IO == game_file.get_content then
wait(.1)
else
IO = get_action(game_file.get_content.split(char(10)))
game_file.set_content(IO)
end if
end while