This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Left4Cake's profile picture

Steam program using PhP

Started by Left4Cake, 08 July 2012 - 03:08 PM
Left4Cake #1
Posted 08 July 2012 - 05:08 PM
This code will connect to my php pages to get steam stats, a few steam friends, and an ASCII version of the users icon.


Spoilerterm.clear()
term.setCursorPos( 1, 1 )
print("Welcome to Steam")
print("")
local tArgs = { … }
if #tArgs < 2 then
print("First input weather or not the profile has a /profiles/ or /id/ in the url")
print("1 = profile, 2 = id")
type = read()
print("")
print("Now enter profile nubmer or custom id")
id = read()
else
type = tArgs[1]
id = tArgs[2]
end
print("")
if type == "1" then
lru = "profiles=" .. id
error = false
elseif type == "2" then
lru = "id=" .. id
error = false
else
print("error:invald input")
error = true
end
if error == false then
print("")
print("Plese select an action:")
print("1 - display icon")
print("2 - show gameplay stats")
print("3 - show five freinds")
action = read()
if action == "1" then
action = "icon"
error2 = false
elseif action == "2" then
action = "stats"
error2 = false
elseif action == "3" then
action = "freinds"
error = false
else
print("error:invald input")
error2 = true
end
if error2 == false then
term.clear()
term.setCursorPos( 1, 1 )
url = "http://www.lozengia.com/tmas/Downloads/Minecraft/computercraft/steam.php?" .. lru .. "&amp;action=" .. action
local file = http.get(url)
local hash = file:readAll()
print(hash)
end
end
input = read()
term.clear()
term.setCursorPos( 1, 1 )
Jackster #2
Posted 08 July 2012 - 05:42 PM
Not bad. Not sure about the image thing but otherwise cool.