Commit before removing "un-input-able" terminals
This commit is contained in:
+39
-5
@@ -27,7 +27,16 @@ quitCommand = TerminalCommand
|
||||
disconnectTerminal :: Terminal -> World -> World
|
||||
disconnectTerminal tm w = w
|
||||
& terminals . ix (_tmID tm) . tmStatus .~ Disconnected
|
||||
& terminals . ix (_tmID tm) . tmFutureLines ++.~ [makeTermLine "DISCONNECTION COMPLETE"]
|
||||
& terminals . ix (_tmID tm) . tmInput .~ Nothing
|
||||
& exitTerminalSubInv
|
||||
& terminals . ix (_tmID tm) . tmFutureLines .~
|
||||
[ TerminalLineTerminalEffect 0 (tmDisplayedLines .~ [])
|
||||
]
|
||||
|
||||
exitTerminalSubInv :: World -> World
|
||||
exitTerminalSubInv w = case w ^? hud . hudElement . subInventory . termID of
|
||||
Just _ -> w & hud . hudElement . subInventory .~ NoSubInventory
|
||||
_ -> w
|
||||
|
||||
damageCodeCommand :: TerminalCommand
|
||||
damageCodeCommand = TerminalCommand
|
||||
@@ -44,6 +53,29 @@ damageCodeCommand = TerminalCommand
|
||||
dinfo <- _sensorCoding (_genParams w) M.!? dtype
|
||||
return $ Right $ w & infoClearInput tm [makeTermLine $ show (fst dinfo) ++ " " ++ show (snd dinfo)]
|
||||
|
||||
sensorCommand :: TerminalCommand
|
||||
sensorCommand = TerminalCommand
|
||||
{ _tcString = "SENSOR"
|
||||
, _tcAlias = ["SEN"]
|
||||
, _tcHelp = "ACCESS THE CONNECTED SENSOR"
|
||||
, _tcArgumentType = Just "A SENSOR PARAMETER"
|
||||
, _tcArguments = \tm w -> ["BOOL","VALUE"]
|
||||
, _tcEffect = effectArgMessage sensf
|
||||
}
|
||||
effectArgMessage :: (String -> Terminal -> World -> Maybe [String])
|
||||
-> [String] -> Terminal -> World -> Either String World
|
||||
effectArgMessage f args tm w = maybe (Left "") Right $ do
|
||||
arg <- safeHead args
|
||||
strs <- f arg tm w
|
||||
return $ w & terminals . ix (_tmID tm) . tmFutureLines ++.~ map makeTermLine strs
|
||||
|
||||
sensf :: String -> Terminal -> World -> Maybe [String]
|
||||
sensf arg tm w = case arg of
|
||||
"BOOL" -> Just [show $ w ^? machines . ix (_tmMachineID tm) . mcSensor . sensToggle]
|
||||
_ -> Nothing
|
||||
|
||||
|
||||
|
||||
helpCommand :: TerminalCommand
|
||||
helpCommand = TerminalCommand
|
||||
{ _tcString = "HELP"
|
||||
@@ -123,14 +155,16 @@ commandsCommand = TerminalCommand
|
||||
)
|
||||
}
|
||||
|
||||
singleCommand :: String -> [String] -> String -> (World -> World) -> TerminalCommand
|
||||
singleCommand command aliases htext eff = TerminalCommand
|
||||
singleCommand :: [String] -> String -> [String] -> String -> (World -> World) -> TerminalCommand
|
||||
singleCommand followingLines command aliases htext eff = TerminalCommand
|
||||
{_tcString = command
|
||||
,_tcAlias = aliases
|
||||
,_tcHelp = htext
|
||||
,_tcArgumentType = Nothing
|
||||
, _tcArguments = const $ const []
|
||||
,_tcEffect = \_ tm w -> Right $ eff $ w & terminals . ix (_tmID tm) . tmInput .~ Nothing
|
||||
,_tcEffect = \_ tm w -> Right $ eff $ w
|
||||
& terminals . ix (_tmID tm) . tmInput . _Just . tiText .~ T.pack ""
|
||||
& terminals . ix (_tmID tm) . tmFutureLines ++.~ map makeTermLine followingLines
|
||||
-- & hud . hudElement . subInventory . onInputLine %~ const False
|
||||
}
|
||||
|
||||
@@ -189,7 +223,7 @@ defaultTermParams = defaultTerminal
|
||||
,_tmTitle = "TERMINAL"
|
||||
,_tmInput = Nothing
|
||||
,_tmScrollCommands = []
|
||||
,_tmWriteCommands = []
|
||||
,_tmWriteCommands = [helpCommand,commandsCommand]
|
||||
,_tmProgram = \_ _ -> termSoundLine computerBeepingS
|
||||
: TerminalLineTerminalEffect 0 (tmStatus .~ Connected)
|
||||
: map makeTermLine connectionBlurb
|
||||
|
||||
Reference in New Issue
Block a user