Anmelden
|
Sprache
български (Bulgarisch)
čeština (Tschechisch)
Dansk (Dänisch)
Nederlands (Niederländisch)
Englisch
Suomi (Finnisch)
Français (Französisch)
Ελληνικά (Griechisch)
Magyar (Ungarisch)
Italiano (Italienisch)
日本語 (Japanisch)
한국어 (Koreanisch)
Norsk (Norwegisch)
Polski (Polnisch)
Português (Portugiesisch)
Português-Brasil (Brasil. Portugiesisch)
Română (Rumänisch)
Русский (Russisch)
简体中文 (Vereinfachtes Chinesisch)
Español (Spanisch)
Svenska (Schwedisch)
繁體中文 (Traditionelles Chinesisch)
ไทย (Thai)
Türkçe (Türkisch)
Українська (Ukrainisch)
Helfen Sie uns, Steam zu übersetzen
If you don't know how these ideas work, then don't read this yet until you've done all of them:
connecting, slurping, memories, floppy usage
Okay you have been warned.
-------- Everything below this line should be considered a Spoiler ----
---- I didn't use spoiler tags because they interfere with your ---
---- ability to cut and paste from the text in the spoiler section ---
------------------------------------------------------------------------------------------------------
Introducing Slurpie DB:
The system to manage your own slurpable computer alias list:
This is composed of two parts: a server computer and a floppy you keep with you and walk around with. There are two different programs, one for the server, and one to keep on the floppy.
Part 1: The server side.
=================
1.1 Choose a server computer that fits the following criteria:
----------------------------------------
1.1.1 - It must be somewhere you can easily access its console on a regular basis.
1.1.2 - It must be some computer no other Person uses (don't use a desk machine).
1.1.3 - It must be able to Connect()
1.1.4 - It must be able to use Memories (SaveMemory(), LoadMemory())
1.1.5 - It must have a console (no headless computers).
Choosing one of the extraneous humidity reporting computers as a server fits these criteria. I'm using the humidity computer at the foot of the stairs in the Lodge_underwater room in my game.
1.2 Install the following program on it to act as the server functionalitry:
####### AssertFunc()
# Ensure needed function is there or bomb out:
void AssertFunc( string fName )
if HasFunction(fName)
#good
else
string msg = "Error: This computer can't"
msg += " do the "+fName+"() function."
msg += " Run it on one that can."
Say(msg)
Quit()
end
end
AssertFunc("GetMemories")
AssertFunc("LoadMemory")
AssertFunc("SaveMemory")
AssertFunc("Connect")
AssertFunc("Input")
ClearText()
Print(Name())
var keys = GetMemories()
loop
Print("")
Print("Slurpie DB.")
Print("")
Print("Currently knows " + (Count(keys)) + " hosts.")
Print("")
if Count(keys) > 0
var max = Count(keys)
max = max - 1 # why can't I do Count(keys)-1?
number i = Input("host [0.."+max+"] : ")
if i < 0 or i >= Count(keys)
Print("out of range")
else
Print(keys[ i ])
Print(" With Nickname " + LoadMemory(keys[ i ]))
string c = Input("(S)lurp, (D)elete, or (N)either? ")
if c == "s" or c == "S"
Connect(keys[ i ])
Slurp()
else if c == "d" or c == "D"
string yn = Input("Confirm? (y/n) ")
if yn == "y" or yn == "Y"
EraseMemory( keys[ i ] )
keys = GetMemories() #list is smaller now
end
end
end
else
break # don't keep looping the message if input is
# being skipped.
end
end
Part 2: The floppy program you carry with you
--------------------------------------------
2.1 Copy this floppy program (see below) onto a trash floppy you'll carry around with you at all times:
2.2 (Edit the line that says string slurpieDB = ...... to make it match the name
of whichever computer you installed the server onto in Part 1 above.(
2.3 To use it: Walk up to a computer you want to add to the slurp DB, or one that is already in the slurp DB, and replace its program with BootFromFloppy(), and use your floppy on it.
It will ask for a nickname for the machine. Type something short that will print nicely on a menu, so it won't have to use the super long name. Then it will ask you if you want to
slurp now. If you say no, then there's nothing else to do - you added the machine to the list, but that's it. You can revert the computer's program back to the original and be on your way. On the other hand if you want to slurp now, you will get a menu showing you all the other machines you've added to the list (there needs to be at least 2 machines on the list for this to work). You can pick the one you want with the arrows and hit space. It will get the real machine name, connect to it, and slurp you.
########
########
######## EDIT THIS SETTING:
########
########
# Change to the name of the computer where you
# installed the Slurpie DB server program:
string slurpieDB = "Lodge_Underwater_MediumSewerComputer_MediumSewerComputer_1"
# Note: the following aren't used but I left them in for
# use in the future if Height() and Width() ever get fixed.
#
# Maybe edit these some times? I think everything
# uses the same universal font but I'm not sure:
number fontHeight = 10
number fontWidth = 8
# There should be no edits required past this line
# -----------------------------------------------------
####### AssertFunc()
# Ensure needed function is there or bomb out:
void AssertFunc( string fName )
if HasFunction( fName )
#good
else
string msg = "Error: This computer can't"
msg += " do the "+fName+"() function."
msg += " Run it on one that can."
Say( msg )
Quit()
end
end
AssertFunc( "Name" )
AssertFunc( "Connect" )
AssertFunc( "Slurp" )
AssertFunc( "HasFloppy" )
AssertFunc( "Input" )
AssertFunc( "GetUser" )
AssertFunc( "Height" )
AssertFunc( "Width" )
########## GetNumDisplayRows
# A workaround to get the screen height in rows
# from the user looking at the screen, since
# Height() appears to be hardcoded to 256 regardless
# of screen size in version 1.0.6 of Heart.Break(),
# and there's no way to calculate it:
number GetNumDisplayRows()
ClearText()
loop i from 35 to 4
Print(i)
end
Print("3 Screen height query:")
Print("2 What is the biggest")
PrintS("1 number you see?")
number n = Input(" ")
ClearText()
return n
end
########## PickMenu()
#
# This function is more complex than I wanted, and I
# should probably break it up into smaller functions
# at some point now that I got it working.
#
# Returns a number for how far into
# the PickMenu the choice was. Returns
# -1 if the user quits.
#
number PickMenu( string title, var picks )
# These aren't actually usable at the moment,
# because Width() and Height() just return the same
# thing all the time, so these values aren't being
# used yet:
number textHeight = Int(Height() / fontHeight)
number textWidth = Int(Width() / fontWidth)
number pick = -1
number topIndex = 0
number max = Count(picks)
max -= 1 # needs to be an extra step because Count() does
# not like being used in an expression in Sprak.
number topDisplayRow = 1
number numDisplayRows = GetNumDisplayRows() - 1
if numDisplayRows < 1
numDisplayRows = 1
end
number pickDisplayRow = 1 + Int(numDisplayRows / 2)
# Ensure keypress is released from whatever prev
# thing was happening. to avoid "bounceback"
loop
if IsKeyPressed("space")
#continue
else
break
end
end
ClearText()
bool picked = false
loop
# ----- Redraw display, only if pick is
# ----- outside currently showing choices:
# ----- (causes new screenful when arrowing
# ----- past the ends of the shown sublist.)
if pick < topIndex or pick >= topIndex + numDisplayRows
if pick < topIndex
topIndex = (pick - numDisplayRows) + 1
if topIndex < -1
topIndex = -1
pick = -1
end
end
if pick >= topIndex + numDisplayRows
topIndex = pick
end
ClearText()
Print(" ") # forces all graphic primitives erased
Text(0,0,title+": ")
PrintMenuSubset( slurpie, pick, picks, topIndex, topDisplayRow, numDisplayRows)
end
# ---- Draw where the pick is now:
Text(0,topDisplayRow + (pick - topIndex), "->")
number oldPick = pick
DisplayGraphics()
# ---- Move the pick on arrows, or accept current
bool keyPressed = false
loop
if IsKeyPressed("up")
pick -= 1
if pick < -1
pick = -1
end
keyPressed = true
end
if IsKeyPressed("down")
pick += 1
if pick > max
pick = max
end
keyPressed = true
end
if IsKeyPressed("space")
picked = true
keyPressed = true
end
Sleep(0.1) # just to prevent busy loop
if keyPressed
break
end
end
if picked
break
else
# pick has moved, so erase where it was before
Text(0,topDisplayRow + (oldPick - topIndex), " ")
end
end
return pick
end
####### PrintMenuSubset
void PrintMenuSubset( var slurpie, number pick, var picks, number topIndex, number topDisplayRow, number numDisplayRows)
number nMinusOne = numDisplayRows - 1 #workaround Sprak bug
loop row from 0 to nMinusOne
number i = row + topIndex
number screenRow = topDisplayRow + row
if HasIndex(picks,i)
string str = "["+i+"] " + picks[ i ]
Text(2, screenRow, str)
else if i == -1
Text(2, screenRow, "<<quit>>")
end
end
end
######## BuildNicks
var BuildNicks( var slurpie, var hosts )
var nicks = []
loop key in hosts
Append( nicks, slurpie.LoadMemory(key) )
end
return nicks
end
#############
### MAIN ###
#############
ClearText()
DisplayGraphics()
DisplayGraphics()
Print( "My Name is..." )
Print( " " + Name() )
Print( "Connecting to slurpieDB..." )
var slurpie = Connect( slurpieDB )
var hosts = slurpie.GetMemories()
bool exists = slurpie.HasMemory(Name())
string oldNick = ""
if exists
oldNick = slurpie.LoadMemory(Name())
Print( "Already in DB as: " )
Print( " " + oldNick )
end
Print( "New nickname for this Machine..." )
if exists
Print( "Or hit return to keep nickname." )
end
string nick = ""
loop
nick = Input( ">" )
if nick == "" and exists == false
# nothing - repeat loop
else
break
end
end
if nick == ""
#nothing - can't find the 'not' operator. grr.
else
Print( "Adding my name to slurpieDB..." )
slurpie.SaveMemory( Name(), nick )
# Re-obtain hosts because the list has just changed:
hosts = slurpie.GetMemories()
end
var hostCount = Count( hosts )
Print( "slurpieDB now has " + hostCount + " hosts." )
# Ensure flushed input:
loop
if IsKeyPressed("space")
# loop until this is false
else
break
end
end
string yes_no = Input( "Do you wish to Slurp Now (y/n)? " )
var nicks = BuildNicks( slurpie, hosts )
DisconnectAll() # ensure only dest will be connected
if yes_no == "y" or yes_no == "Y"
number pick = PickMenu( "Choose destination:", nicks )
if pick >= 0
Print( "Connecting to:" )
Print( " " + hosts[ pick ] )
var dest = Connect( hosts[ pick ] )
Slurp()
end
end
Print( "Program done." )
If you want to manually hack a non-console or non-floppy machine to add
it to the list without using the floppy:
#
string slurpieDB = "whatever machine name you used for the server above"
var c = Connect(slurpieDB)
c.SaveMemory(Name(), "some nickname here") # now it's in the slurpie DB