I have a moon lander docked to a mother ship orbiting Titan. There is a single entry/exit hatch into the lander.
The player character enters the lander by going up through the hatch. Once inside the lander, the down direction returns the PC to the launch dock.
The PC goes up, the lander is launched, lands on Titan, and the PC goes down. Now I want the destination of the hatch to be the surface of Titan.
+ hatchOutOfMoonLander: Door 'hatch'
"Hatch out of moon lander. <.p>"
otherSide = getDest
travelDesc = getLanderExitText
getDest()
{
local ret = hatchIntoMoonLander;
if(saturnMoonLander.onTitan)
{
ret = hatchFromMoonIntoMoonLander;
}
return ret;
}
...
;
This does not work. While I can manipulate the travelDesc text based on the state of the onTitan property of the saturnMoonLander…
…the actual destination remains the launch dock inside the mother ship.
I’ve isolated the code from the larger game into a test bed environment and added a magic button that toggles the value of the onTitan property of the moon lander.
Here’s the transcript…
And here’s the code…
#charset "us-ascii"
#include <tads.h>
#include "advlite.h"
versionInfo: GameID
IFID = '445C38A3-AD1B-4729-957A-F584600DE5C1'
name = 'test'
byline = 'by Jerry Ford'
htmlByline = 'by <a href="mailto:jerry.o.ford@gmail.com">
Jerry Ford</a>'
version = '1'
authorEmail = 'Jerry Ford <jerry.o.ford@gmail.com>'
desc = 'Testing dynamic door destination.'
htmlDesc = 'Testing dynamic door destination.'
;
gameMain: GameMainDef
initialPlayerChar = me
paraBrksBtwnSubcontents = nil
;
me: Actor 'me;him' @saturnMoonLander
""
firstName = 'John'
lastName = 'Doe'
person = 2
;
saturnMoonLander: Room 'Moon Landing Module' 'landing module;Enceladus Titan
Saturn moon;lander'
"The moon lander is a small space with two recliner chairs in front of a
control panel on which there is a big red button labelled <i>Magic
Button</i>. \b
The current location of the lander is <<if(!onTitan)>>docked to the mother
ship<<else>>on Titan<<end>>. <.p>"
onTitan = nil
down = hatchOutOfMoonLander
;
+ magicButton: Button 'magic button'
"The magic button toggles the lander's position between <i>on Titan</i> and
<i>off Titan</i> <.p>"
dobjFor(Push)
{
action()
{
saturnMoonLander.onTitan = saturnMoonLander.onTitan == nil ? true :
nil;
"At the touch of the magic button you are ";
if(!saturnMoonLander.onTitan)
"docked to the mother ship";
else
"on Titan";
". <.p>";
}
}
;
+ hatchOutOfMoonLander: Door 'hatch'
"Hatch out of moon lander. <.p>"
otherSide = getDest
travelDesc = getLanderExitText
getDest()
{
local ret = hatchIntoMoonLander;
if(saturnMoonLander.onTitan)
{
ret = hatchFromMoonIntoMoonLander;
}
return ret;
}
getLanderExitText()
{
if(saturnMoonLander.onTitan)
{
"The hatch pops open. You drop down to the frozen
surface of Titan. <.p>";
}
else
{
"You descend from the lander entry hatch into the launching dock.
<.p>";
}
}
;
titanLandingSite: Room 'Titan Landing Site' 'landing site;Titan'
"The lander sits on a low rise of icy ground. In the near distance to the
south, the ice gives way to the dark liquid methane of Kraken Mare.
<.p>"
up = hatchFromMoonIntoMoonLander
;
+ hatchFromMoonIntoMoonLander: Door 'hatch into lander'
"Hatch into lander. <.p>"
otherSide = hatchOutOfMoonLander
travelDesc = "After knocking your boots against the lander strut in an effort to
dislodge whatever remains of Kraken Mare sludge clinging to them, you climb the
ladder and cycle through the air lock.<.p>"
;
landingModuleLaunchDock: Room 'Landing Module Launch Dock' 'landing module
launch dock'
"The landing-module launch dock is located at the forward tip of the
Saturn mother ship core corridor---the spear that is the ship's axis.
<.p>"
up: TravelConnector
{
destination = hatchIntoMoonLander
}
;
+ hatchIntoMoonLander: Door 'hatch;moon lander'
"Hatch into moon lander. <.p>"
isOpen = nil
otherSide = hatchOutOfMoonLander
;
Any suggestions on how I can make the otherSide property of the hatchOutOfMoonLander object (type Door) dynamic?
When onTitan is true, I want the other side to be hatchFromMoonIntoMoonLander on the titanLandingSite.
When onTitan is nil, I want the hatch’s other side to be hatchIntoMoonLander on the landingModuleLaunchDock.
Doable? (A break point in the getDest() method of hatchOutOfMoonLander object stops exactly once when I run the program—early on, I believe during pre-init, then never again no matter how often the PC goes through the hatch.)
If not doable, suggestions for alternatives?
Thanks.
Jerry