Gork - Console Text RPG

Gork- Console Text Based RPG

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

How To play?
First, you need to activate it in your console type activate_gork
after that, just type the selections in console without the “-” Those are just to space them a bit.

What the :heart::heart::heart::heart: is Zork?
Zork was an old text based… never mind here’s wiki http://en.wikipedia.org/wiki/Zork

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 :smiley: 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.

Screen Shots.

http://puu.sh/bRJOw/e74f473650.png

http://puu.sh/bRJRS/dbb98fdc6e.png

Download

http://steamcommunity.com/sharedfiles/filedetails/?id=319993323 (Not sure if ws item is working properly)

To Do List:
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

Not sure what you’re talking about, but okay. :smiley: PM me?

Dude, this is an amazing idea…You’re very innovative I can tell :stuck_out_tongue:

Thanks!

voila:

http://puu.sh/bS2g7/ee03408741.png

[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("

“).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]

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

how so

Well… I honestly hate combining web language and lua, I have an OCD complex. :stuck_out_tongue: other than that… :smiley:
Want to explain how these pars lines and **** work?

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

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([[
	&lt;head&gt;
		&lt;script type="text/javascript" src="asset://garrysmod/html/js/thirdparty/jquery.js"&gt;&lt;/script&gt;
		&lt;script type="text/javascript" src="asset://garrysmod/html/js/lua.js"&gt;&lt;/script&gt;
		&lt;script type="text/javascript"&gt;function addLine(t){0==t.length&&(t=" "),t=t.replace(/[&lt;&gt;'"&\\]/g,function(t){return htmlEnts[t]}),-1==t.search(/[^ ]/g)&&(t=" "),$("#output").append("&lt;li&gt;"+t+"&lt;/li&gt;"),$("#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("

“).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
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]