• Gork - Console Text RPG
    12 replies, posted
[b]Gork- Console Text Based RPG[/b] Wanted to play that old school game that your girl friend makes fun of you for? Well here you go! This game is done through the console of Garry's Mod, thought it would take away some of the effect if I made it done through the chat-box xD [b]How To play?[/b] First, you need to activate it in your console type [i]activate_gork[/i] after that, just type the selections in console without the "-" Those are just to space them a bit. [b]What the ♥♥♥♥ is Zork?[/b] Zork was an old text based.... never mind here's wiki [url]http://en.wikipedia.org/wiki/Zork[/url] If you look at the code, it's a bit bad, I was just making this for single player fun, by myself. As I worked on this detailed story line trying to duplicate Zork's story line it became terribly hard, due to Zork being written in MUD, a 1980's language. I tried. please only leave helpful and constructive comments :D I'm going to be adding more to the dialogue as I work to make this game 100% non-cheatble, probably by recoding the whole thing. And fixing some story issues. [b]Screen Shots.[/b] [IMG]http://puu.sh/bRJOw/e74f473650.png[/IMG] [IMG]http://puu.sh/bRJRS/dbb98fdc6e.png[/IMG] [b]Download[/b] [url]http://www.filedropper.com/gork[/url] [url]http://steamcommunity.com/sharedfiles/filedetails/?id=319993323[/url] (Not sure if ws item is working properly) [b]To Do List:[/b] 1.) Add a shit ton more dialogue 2.) Eliminate console commands 3.) More text art! 4.) Spacing
Wow I never imagined we'd see a text based RPG in Gmod of all places :v:
if you're interested i can send you the fake terminal for the MUSH i was working on that'd probably make things a little easier than concommands
[QUOTE=Luni;46100055]if you're interested i can send you the fake terminal for the MUSH i was working on that'd probably make things a little easier than concommands[/QUOTE] Not sure what you're talking about, but okay. :D PM me?
Dude, this is an amazing idea...You're very innovative I can tell :P
[QUOTE=bluebull107;46101430]Dude, this is an amazing idea...You're very innovative I can tell :P[/QUOTE] Thanks!
voila: [img]http://puu.sh/bS2g7/ee03408741.png[/img] [lua] function GM:CreateTerminal() if IsValid(self.Terminal) then return end local frame = vgui.Create("DFrame") frame:SetSize(680, 480) frame:SetTitle("") frame:ShowCloseButton(true) frame:SetDraggable(true) frame:Center() frame:MakePopup() function frame:AddLine(str) self.Browser:RunJavascript('addLine("' .. str:gsub("[\\\"]", "\\%1") .. '")') end local browser = vgui.Create("DHTML", frame) browser:Dock(FILL) browser:DockMargin(-2, -2, -2, -2) browser:SetAllowLua(true) browser:SetHTML([[ <head> <script type="text/javascript" src="asset://garrysmod/html/js/thirdparty/jquery.js"></script> <script type="text/javascript" src="asset://garrysmod/html/js/lua.js"></script> <script type="text/javascript">function addLine(t){0==t.length&&(t=" "),t=t.replace(/[<>'"&\\]/g,function(t){return htmlEnts[t]}),-1==t.search(/[^ ]/g)&&(t="&nbsp;"),$("#output").append("<li>"+t+"</li>"),$("#output-frame").scrollTop($("#output").height())}$(document).ready(function(){var t=$("#input");t.val(""),t.keydown(function(n){if(13==n.which){var u=t.val();if(0==u.length)return;u.split("\n").forEach(function(t){lua.Run("GAMEMODE:ParseInput(%s)",t)}),t.val(""),n.preventDefault()}})}),htmlEnts={"<":"&lt;",">":"&gt;","'":"&apos;",'"':"&quot;","&":"&amp;","\\":"\"};</script> <style>*{margin:0;padding:0}html{height:100%}body{margin:0;padding:0;height:100%}#output-frame{position:absolute;top:0;left:0;right:0;bottom:50px;overflow-x:hidden;overflow-y:scroll;background:#000;color:silver}#output{margin:5px;list-style-type:none;font-family:monospace;font-size:10pt}#input-frame{position:absolute;height:48px;left:0;right:0;bottom:0;background:#000}li{white-space:pre-wrap}#cssfix{position:absolute;top:2px;left:2px;right:2px;bottom:2px}#input{width:100%;height:97%;border:0;resize:none;overflow-x:hidden;overflow-y:hidden;background:#000;color:silver;font-family:monospace;font-size:10pt}#input:focus{border:0;outline:0}</style> </head> <body> <div id="output-frame"><ul id="output"></ul></div> <div id="input-frame"><div id="cssfix"><textarea id="input"></textarea></div></div> </body>]]) browser:InvalidateLayout() frame:RequestFocus() frame.Browser = browser self.Terminal = frame end function GM:ParseInput(str) -- parse commands here self.Terminal:AddLine(">" .. str) print(str) end[/lua]
[QUOTE=Luni;46101604]voila: [img]http://puu.sh/bS2g7/ee03408741.png[/img] [lua] function GM:CreateTerminal() if IsValid(self.Terminal) then return end local frame = vgui.Create("DFrame") frame:SetSize(680, 480) frame:SetTitle("") frame:ShowCloseButton(true) frame:SetDraggable(true) frame:Center() frame:MakePopup() function frame:AddLine(str) self.Browser:RunJavascript('addLine("' .. str:gsub("[\\\"]", "\\%1") .. '")') end local browser = vgui.Create("DHTML", frame) browser:Dock(FILL) browser:DockMargin(-2, -2, -2, -2) browser:SetAllowLua(true) browser:SetHTML([[ <head> <script type="text/javascript" src="asset://garrysmod/html/js/thirdparty/jquery.js"></script> <script type="text/javascript" src="asset://garrysmod/html/js/lua.js"></script> <script type="text/javascript">function addLine(t){0==t.length&&(t=" "),t=t.replace(/[<>'"&\\]/g,function(t){return htmlEnts[t]}),-1==t.search(/[^ ]/g)&&(t="•"),$("#output").append("<li>"+t+"</li>"),$("#output-frame").scrollTop($("#output").height())}$(document).ready(function(){var t=$("#input");t.val(""),t.keydown(function(n){if(13==n.which){var u=t.val();if(0==u.length)return;u.split("\n").forEach(function(t){lua.Run("GAMEMODE:ParseInput(%s)",t)}),t.val(""),n.preventDefault()}})}),htmlEnts={"<":"<",">":">","'":"'",'"':""","&":"&","\\":"\"};</script> <style>*{margin:0;padding:0}html{height:100%}body{margin:0;padding:0;height:100%}#output-frame{position:absolute;top:0;left:0;right:0;bottom:50px;overflow-x:hidden;overflow-y:scroll;background:#000;color:silver}#output{margin:5px;list-style-type:none;font-family:monospace;font-size:10pt}#input-frame{position:absolute;height:48px;left:0;right:0;bottom:0;background:#000}li{white-space:pre-wrap}#cssfix{position:absolute;top:2px;left:2px;right:2px;bottom:2px}#input{width:100%;height:97%;border:0;resize:none;overflow-x:hidden;overflow-y:hidden;background:#000;color:silver;font-family:monospace;font-size:10pt}#input:focus{border:0;outline:0}</style> </head> <body> <div id="output-frame"><ul id="output"></ul></div> <div id="input-frame"><div id="cssfix"><textarea id="input"></textarea></div></div> </body>]]) browser:InvalidateLayout() frame:RequestFocus() frame.Browser = browser self.Terminal = frame end function GM:ParseInput(str) -- parse commands here self.Terminal:AddLine(">" .. str) print(str) end[/lua] it's surprisingly small when you take the ansi color parsing out and minify the CSS and JS[/QUOTE] Honestly, I'm not too sure about this method. It's obviously better than lots of concommands.
Aww, this is really neat! Text adventures are always something I meant to get more into so I'll give this a go later on
[QUOTE=SwikCoder;46101895]Honestly, I'm not too sure about this method.[/QUOTE] how so
[QUOTE=Luni;46103489]how so[/QUOTE] Well.... I honestly hate combining web language and lua, I have an OCD complex. :P other than that... :D Want to explain how these pars lines and **** work?
[QUOTE=SwikCoder;46105922]Well.... I honestly hate combining web language and lua, I have an OCD complex. :P other than that... :D Want to explain how these pars lines and **** work?[/QUOTE] player input automatically calls GAMEMODE:ParseInput(), if you rename it make sure you also update it in the Javascript code that runs the HTML input box that's all you really need to care about in the html/js portion
[QUOTE=Luni;46106040]player input automatically calls GAMEMODE:ParseInput(), if you rename it make sure you also update it in the Javascript code that runs the HTML input box that's all you really need to care about in the html/js portion[/QUOTE] I think I'll port all the dialogue to this, if everything works out. Edit: [lua] function GM:CreateTerminal() if IsValid(self.Terminal) then return end local frame = vgui.Create("DFrame") frame:SetSize(680, 480) frame:SetTitle("") frame:ShowCloseButton(true) frame:SetDraggable(true) frame:Center() frame:MakePopup() function frame:AddLine(str) self.Browser:RunJavascript('addLine("' .. str:gsub("[\\\"]", "\\%1") .. '")') end local browser = vgui.Create("DHTML", frame) browser:Dock(FILL) browser:DockMargin(-2, -2, -2, -2) browser:SetAllowLua(true) browser:SetHTML([[ <head> <script type="text/javascript" src="asset://garrysmod/html/js/thirdparty/jquery.js"></script> <script type="text/javascript" src="asset://garrysmod/html/js/lua.js"></script> <script type="text/javascript">function addLine(t){0==t.length&&(t=" "),t=t.replace(/[<>'"&\\]/g,function(t){return htmlEnts[t]}),-1==t.search(/[^ ]/g)&&(t="&nbsp;"),$("#output").append("<li>"+t+"</li>"),$("#output-frame").scrollTop($("#output").height())}$(document).ready(function(){var t=$("#input");t.val(""),t.keydown(function(n){if(13==n.which){var u=t.val();if(0==u.length)return;u.split("\n").forEach(function(t){lua.Run("GAMEMODE:ParseInput(%s)",t)}),t.val(""),n.preventDefault()}})}),htmlEnts={"<":"&lt;",">":"&gt;","'":"&apos;",'"':"&quot;","&":"&amp;","\\":"\"};</script> <style>*{margin:0;padding:0}html{height:100%}body{margin:0;padding:0;height:100%}#output-frame{position:absolute;top:0;left:0;right:0;bottom:50px;overflow-x:hidden;overflow-y:scroll;background:#000;color:silver}#output{margin:5px;list-style-type:none;font-family:monospace;font-size:10pt}#input-frame{position:absolute;height:48px;left:0;right:0;bottom:0;background:#000}li{white-space:pre-wrap}#cssfix{position:absolute;top:2px;left:2px;right:2px;bottom:2px}#input{width:100%;height:97%;border:0;resize:none;overflow-x:hidden;overflow-y:hidden;background:#000;color:silver;font-family:monospace;font-size:10pt}#input:focus{border:0;outline:0}</style> </head> <body> <div id="output-frame"><ul id="output"></ul></div> <div id="input-frame"><div id="cssfix"><textarea id="input"></textarea></div></div> </body>]]) browser:InvalidateLayout() frame:RequestFocus() frame.Browser = browser self.Terminal = frame end concommand.Add("gork",CreateTerminal) [/lua] [lua] [ERROR] lua/autorun/client/terminalgork.lua:34: attempt to index global 'self' (a nil value) 1. unknown - lua/autorun/client/terminalgork.lua:34 2. unknown - lua/includes/modules/concommand.lua:69 [/lua]
Sorry, you need to Log In to post a reply to this thread.