So then, after being inspired by seeing vvoman's color image downloader and making my own from scratch at a 256*256 resolution I thought what else could I make with the same sort of set up. I then came up with the idea to make an rss viewer and here it is! It like vvoman's downloader uses php, lua and e2 and in a very similar way. To use this you will need a small web server on your pc with php and the simplepie (SimplePie: Super-fast, easy-to-use, RSS and Atom feed parsing in PHP.) rss parser on it as that made my life a lot easier! When you have it all set up you open your server, run the lua script in gmod and spawn the e2 and console screen and wire them up. Then you wait for the e2 to tell you it's really and you can then view rss feeds on your console screen! It's a known issue that if the url to the feed has a question mark in it it will not work, it will simply break. Below I will post some images and the code for all three things, it will help to know your way round each language to set them up.



e2
Code:
@name RSS Reader
@inputs Screen:wirelink
@outputs
@persist Data:array ChatArray:array Busy Print
@trigger
runOnChat(1)
runOnFile(1)
if(first()){
Busy=1
timer("ready",11000)
Screen[2041]=1
}
if(clk("ready")){
Busy=0
print("RSS Feed Reader Ready")
Screen[2041]=0
}
if(lastSpoke()==owner()){ChatArray=lastSaid():explode(" ")}
if(ChatArray[1,string]=="!rss"&!Busy){
fileRemove("e2feed.txt")
concmd("rss_load "+ChatArray[2,string]:replace("http://","HTTP"):replace(" ","%20"))
Busy=1
Screen[2041]=1
Print=0
}
if(ChatArray[1,string]=="[rss_file_generated]"&Busy&!Print){
fileLoad("e2feed.txt")
print("Loading Feed.")
Print=1
hideChat(1)
}
if(fileClk("e2feed.txt")){
Screen[2041]=0
print("Printing Feed.")
Data=fileRead("e2feed.txt"):explode("!%BREAK%!")
TitleLength=Data[1,string]:length()
BodyStart=ceil(TitleLength/29)
Screen:writeString(Data[1,string],0,0,900)
Screen:writeString(Data[2,string]:sub(9):replace("&mdash",""),0,BodyStart)
Busy=0
} lua (credit to vvoman for this, used his code mostly, with permission)
Code:
print("RSS php and e2 communication layer loaded!\n")
function loadRSS(ply,cmd,args)
print("Refreshing RSS Data File!\n")
url=args[1]
print("URL: "..tostring(url))
function callBackLoadRSS(contents, size)
print(contents)
RunConsoleCommand("say", "[rss_file_generated]")
end
http.Get("http://localhost/rssgen.php?feed="..tostring(url), "", callBackLoadRSS)
end
concommand.Add("rss_load", loadRSS) php (64x)
Code:
<?php
require_once('simplepie/simplepie.inc');
$url = str_replace("HTTP","http://",$_GET["feed"]);
$url = str_replace("%20"," ",$url);
$feed = new SimplePie();
$feed->set_feed_url($url);
$feed->strip_htmltags(array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style', 'a', 'img', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'br', 'div', 'i', 'em', 'strong', 'p','&mdash'));
$feed->init();
$feed->handle_content_type();
$item = $feed->get_item(1);
$string = $item->get_title();
$string .= "!%BREAK%!";
$string .= $item->get_description();
$fh = fopen("C:\Program Files (x86)\Steam\steamapps\<Your username here>\garrysmod\garrysmod\data\e2files\e2feed.txt", 'w') or die("can't open file");
fwrite($fh, $string);
fclose($fh);
echo $string; php (32x)
Code:
<?php
require_once('simplepie/simplepie.inc');
$url = str_replace("HTTP","http://",$_GET["feed"]);
$url = str_replace("%20"," ",$url);
$feed = new SimplePie();
$feed->set_feed_url($url);
$feed->strip_htmltags(array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style', 'a', 'img', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'br', 'div', 'i', 'em', 'strong', 'p','&mdash'));
$feed->init();
$feed->handle_content_type();
$item = $feed->get_item(1);
$string = $item->get_title();
$string .= "!%BREAK%!";
$string .= $item->get_description();
$fh = fopen("C:\Program Files\Steam\steamapps\<Your username here>\garrysmod\garrysmod\data\e2files\e2feed.txt", 'w') or die("can't open file");
fwrite($fh, $string);
fclose($fh);
echo $string;
Bookmarks