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

Don't [Crap] Your Pants

Started by Jan, 17 March 2013 - 07:55 AM
Jan #1
Posted 17 March 2013 - 08:55 AM
A few years ago, I found this awesome game:
http://www.kongregat...shit-your-pants

It is a 'horror', command-line controlled game where you have to avoid shitting your pants.

Some of you may already know this game, but I thought: It would be perfect to port to computercraft!


Here is the beta.. I need feedback on more commands and synonyms:

Spoiler

local time = 0
local text = ""
local state = {}
local timestep = 0
-- State
local function resetstate()
state.dooropen = false
state.sitting = false
state.pantsoff = false
state.timestep = 0
end
resetstate()
-- Writing stuff
local function readit(cmax)
  local x,y = term.getCursorPos()
  local width = term.getSize()
  local max = cmax or (width-2)
  term.setCursorBlink(true)
  local function disp()
    term.clearLine()
    term.setCursorPos(1,y)
    write(">") write(" "..text)
    term.setCursorPos(2+#text+1,y)
  end
  disp()
  while true do
    local a,b = os.pullEvent()
    if a=="char" and #text<max then
	  text = text..b
	  disp()
    elseif a=="key" then
	  if b==keys.enter then
	    print()
	    term.setCursorBlink(false)
	    local ok = text
	    text = ""
	    return ok
	  elseif b==keys.backspace then
	    text=text:sub(1,#text-1)
	    disp()
	  end
    elseif a=="timer" and b==time then
	  term.clearLine()
	  term.setCursorPos(1,y)
	  term.setCursorBlink(false)
	  return text,true
    end
  end
end
function printf(text)
  writef(text)
  print("")
end
function writef(text)
term.setBackgroundColor(1)
term.setTextColor(2^15)
write(text)
term.setBackgroundColor(2^15)
term.setTextColor(1) 

end
-- Game commands

local infos ={}
local syno = {}
-- Looking around
function infos.status()
  local mes = ""
  if state.sitting then
    mes = mes .. "You are sitting on the toilet"
    if state.pantsoff then
	  mes = mes .. " with your pants off"
    end
  else
    mes = mes .. "You are standing in a hall"
    if state.pantsoff then
	  mes = mes .. " with your pants off"
    end
    mes = mes .. ". There is a wooden door"
    if state.dooropen then
	  mes = mes .. ", it is open. There is a toilet behind the door"
    end
  end
  print(mes..".")
end
syno.status = {"look","watch","see","lookaround","examine","examineroom","examinehall"}
-- Pushing the door (also open)
function infos.pushdoor()
  if state.sitting then
    print("You can't reach the door because you are sitting.")
  else
    if state.dooropen then
	  print("You closed the door. Why would you that anyway?")
	  state.dooropen=false
    else
	  write("You tried ")
	  writef("pushing")
	  write(" the door but it won't open.")
	  print("")
    end
  end
end
syno.pushdoor = {"push","open","opendoor"}
function infos.pulldoor()
  if state.sitting then
    print("You can't reach the door because you are sitting.")
  else
    if state.dooropen then
	  print("You are pulling with all your strength, and suddenly you realize the door is already open.")
    else
	  print("You opened the door. There is a toilet behind the door. (what a suprise!)")
	  state.dooropen=true
    end
  end
end
syno.pulldoor = {"pull"}
function infos.sit()
  print("Sit on what?")
  text = "sit on "
end
syno.sit = {"sitdown"}
function infos.sittoilet()
  if state.sitting then
    print("You are already sitting.")
  else
    if state.dooropen then
	  print("You are sitting on the toilet.")
	  state.sitting = true
    else
	  print("I don't see any toilet here.")
    end
  end
end
syno.sittoilet = {"sitontoilet"}
function infos.stand()
  if state.sitting then
    print("You are now standing in the hall.")
    state.sitting = false
  else
    print("You are already standing.")
  end
end
syno.stand = {"standup","goofftoilet"}
function infos.pantsoff()
  if state.sitting then
    print("You can't do that while you are sitting.")
  else
    if state.pantsoff then
	  print("Your pants are already off. Put them on if you really want to put them off again.")
    else
	  print("You put your pants off.")
	  state.pantsoff=true
    end
  end
end
syno.pantsoff = {"putpantsoff","putoffpants"}
function infos.pantson()
  if state.sitting then
    print("You can't do that while you are sitting.")
  else
    if state.pantsoff then
	  print("Your put your pants back on. May I ask why?")
	  state.pantsoff=false
    else
	  print("You are already wearing your pants.")
    end
  end
end
syno.pantson = {"putpantson","putonpants"}
function infos.pants()
  print("Pants are awesome, aren't they?")
end
function infos.shit()
  state.timestep = 2
  time = os.startTimer(0.2)
end
function infos.help()
  print("Help who?")
  text = "help "
end
infos["help me"] = function()
  print("Hmmm... Maybe you could try looking around?")
end
-- Saving syno's
for mainword,others in pairs(syno) do
  for n,other in ipairs(others) do
    infos[other] = infos[mainword]
  end
end
-- evil timing mechanism
local tmes = {"* Hurry! Don't shit your pants! 35 seconds left.  *",
			  "* The pressure is getting higher! 10 seconds.	 *",
			  "* You are shitting !							  *"}
local tsec = {25,10,}
-- Play function
function lose()
  local timer = 0
  print("Press enter to continue...")
  readit(0)
  print("")
  if state.pantsoff then
    if state.sitting then
	  printf(" You won! ")	
	  print("Congratulations!")
    else
	  print("Oh no.... you shit on the floor.")
	  print("But luckely you had your pants off! so...")
	  printf(" You won! ")
    end
  else
    printf(" You lost!")
  end
  text=""
  print("")
  print("Press enter to continue...")
  readit(0)
end
function play()
  print("")
  print("You really need to take a shit...")
  printf("* You have 1 minute left. Good luck!			  *")
  resetstate()
  time = os.startTimer(2500)
  print("You are in a hall.")
  while true do

    ori,b = readit()
    a = ori:gsub(" a ",""):gsub("the",""):gsub("( )","")
    if b==true then
	  state.timestep=state.timestep+1
	  if state.timestep==3 then
	    printf(tmes[state.timestep])
	    lose()
	    break
	  end
	  printf(tmes[state.timestep])
	  time = os.startTimer(tsec[state.timestep])
    else
	  local func = infos[a]
	  if func then
	    func()
	  else
	    print("I don't know how to "..ori)
	  end
    end
  end
end

-- Main loop

while true do
  print()
  printf(" Don't Shit Your Pants! ")
  print("		  A survivor horror game.")
  print("")
  print([[Instructions:
- To start type "play".
- To view achievements type "awards".
Goal:
- Don't shit your pants.
]])
  while true do
    local a = readit()
    if a=="exit" or a=="quit" then
	  return
    elseif a=="play" then
	  play()
	  break
    else
	  print("Unknown command")
    end
  end
end
Shnupbups #2
Posted 18 March 2013 - 10:00 AM
You forgot that when you type '[that word]' on the main menu in the game you shit your pants.

EDIT: Censored
Lyqyd #3
Posted 19 March 2013 - 02:37 AM
Your topic title has been edited. This is a family-friendly forum. I'll leave the other references alone for now.
Jan #4
Posted 20 March 2013 - 04:57 AM
You forgot that when you type '[that word]' on the main menu in the game you shit your pants.
Oh yes xD

EDIT: Censored
Your topic title has been edited. This is a family-friendly forum. I'll leave the other references alone for now.
Oh sorry, English is not my first language. And yes, crap is a better word. But is 'to scap' a verb? And does 'To crap in your pants' make sense?

PS: If anyone plays the game and finds a command that is not recognised, please post them. I'll add more synonyms then. Also I need to fix the timer in the game
Lyqyd #5
Posted 20 March 2013 - 05:46 AM
Yes, "crap" can be used interchangeably in essentially all contexts the other word can be used in.