Here's a puzzle that I cannot figure out.
I keep getting an 'TADS RuntimeError : nil object reference' with the
"yellow arrow" pointing to another file I am using (here is the brief
code) :
// Check for a glostick being in used - dark room vs. rooms (version 2)
GSCheck : InitObject
execute() { new PromptDaemon(self, &useGloStick); }
useGloStick() {
if (gPlayerChar.location.ofKind(DarkRoom)) {
......
}
}
;
The arrow is pointing at the 'if' statement -- placing the cursor over
'gPlayerChar.location' shows that the PC's location is nil. How?? The
'gPlayerChar' property is pointing to my pc (me) object.
Now here's the funny part -- I can walk in and out of other locations in
my WIP game *with no problems!!!!!* So why is it having a fit when I
try to enter the inn?
Many thanks in advance ------- James
Here is the transcript followed by the related code.
==========
Front Of Inn
This is the front porch of an old inn which lie north. Paths lead
southeast to
the village well, southwest and south. To the east lie the fields while
to the
west you can see a blackened field. The only window is boarded up so
there is
way to look inside.
>n
(first opening the front door)
You close the door after entering.
[ RUNTIME ERROR OCCURS AT THIS POINT ]
==========
CSFrontInn1 : OutdoorRoom 'Front Of Inn'
"This is the front porch of an old inn which lie north. Paths lead
southeast
to the village well, southwest and south. To the east lie the
fields while
to the west you can see a blackened field. The only window is
boarded up
so there is way to look inside. "
north = CSInnDoor1a
southeast = CSWell1
south = CSDirtRoad1a
southwest = CSDirtRoad1b
;
+ CSInnDoor1a : AutoClosingDoor '(front) door' 'front door'
reportAutoClose() { "<.p>You close the door after entering. "; }
;
+ Enterable ->(CSFrontInn1.north) 'inn' 'inn';
CSInsideInn1 : Room 'Inn' 'inside the inn'
"This single room area is divided in half with the eastern part
consisting
of a counter and a two--door dresser against one wall while the
western side
have several beds. The exit out lie to the south. "
out = CSInnDoor1b
south asExit(out)
;
+ CSInnDoor1b : AutoClosingDoor ->CSInnDoor1a '(front) door' 'front door'
reportAutoClose() { "<.p>You close the door after entering. "; }
;
--
The mad programmer strikes again.......
James M.
[snip]
> Now here's the funny part -- I can walk in and out of other locations in
> my WIP game *with no problems!!!!!* So why is it having a fit when I
> try to enter the inn?
I don't have a very specific answer for you, but I have one general tip
based on my experience...
What you're describing is exactly what happens when you try to pass
through a Door or other Passage whose destination property is set to
nil. (All Passages have a destination property, but they handle that
property in a particular way, making it depend on the location of the
other "side" of the passage.) To try to isolate the problem, I'd use
the debugger to find out the value of CSInnDoor1a.destination and/or
CSInnDoor1b.destination and/or do the same thing with whatever other
problem Doors or Passages you have. If any of these turn up nil, you
have a problem. I would then open up travel.t, look at the Passage
class, and see the way it figures out the destination value. Hopefully
that will get you started towards isolating the problem.
Or I could be wrong. If your Doors' destination properties all have the
proper value, then I don't know what to tell you.
I didn't see any problems in the code you posted, so sorry I couldn't
be more specific. Maybe somebody else will be able to help more.
Greg
> Klywarre (The Avatar) wrote:
>> I keep getting an 'TADS RuntimeError : nil object reference' with the
>> "yellow arrow" pointing to another file I am using (here is the brief
>> code) :
>
> I didn't see any problems in the code you posted, so sorry I couldn't
> be more specific. Maybe somebody else will be able to help more.
I just tried the code Klywarre posted (with the sw, s, and se exits
commented out so that it would compile) and couldn't reproduce the problem.
This makes me think it lies elsewhere.
--Michel.
if (gPlayerChar.location != nil) {
.........
}
James
James
Note that if you're trying to track down exactly where gPlayer.location gets
set to nil, there's a really easy way if you're using Workbench: a global
breakpoint on the condition "gPlayer.location == nil". Press F9 to bring up
the Breakpoints dialog, click "New Global", type "gPlayer.location == nil"
into the condition box, and click the "stop when condition is true" radio
button. Confirm out of the dialogs, press Go, and run through the game as
normal - the debugger will stop at the line of code that makes the condition
come true. Once you know where, it's usually pretty easy to figure out why.
--Mike
mjr underscore at hotmail dot com
Here is what happen -- code wise: (unedited version)
CSInsideInn1 : Room 'Inn' 'inside the inn'
desc() {
"This single room area is divided in half with the eastern part
consisting
of a counter and a two--door dresser against one wall while the
western
side have several beds. The exit out lie to the south. ";
if (comment && QuestObjects.test(7, 0)) {
comment = nil; // display comment once if not on quest
already
"<b>The inn keeper isn\'t behind the counter as he should be.</b>\b
<.speech>Celestra:\n<q>Perhaps we\'ll find answers at this
<i>Commons</i> Mike mentioned,</q><./speech> she says looking
around
the empty room.\b
<.speech>Korrwin:\n<q>Looks like it,</q><./speech> wondering
just what
is going on around here with a hand near your weapon, just in
case.<.p> ";
}
}
out = CSInnDoor1b
south asExit(out)
comment = true
;
CSTrogLeaf1 : Thing '(trog) leaf' 'trog leaf'
"It\'s a common leaf from trees grown down in deep caverns below. "
;
+ CSInnCounter1 : NominalPlatform
name = 'counter'
actorInPrep = 'behind'
;
+ CSInnDoor1b : AutoClosingDoor ->CSInnDoor1a '(front) door' 'front door'
reportAutoClose() { "<.p>You close the door after entering. "; }
;
+ Surface, Fixture 'counter' 'counter'
"It divides the northern section of the eastern side of the inn. "
;
+ Bed, Heavy 'bed*beds' 'beds';
+ CSInnDresser1 : ComplexContainer, Heavy 'two-door dresser' 'dresser'
"The dresser stands at least six feet tall with two doors mounted to the
front"
subContainer : ComplexComponent, OpenableContainer {
bulkCapacity = 10
openStatus { if (isOpen) ". It\'s open"; }
}
;
++ Openable, Container '(small) bag/sack' 'small sack' "It\'s a small sack"
subLocation = &subContainer
;
+++ BasicApples;
+++ BasicApples;
+++ BasicApples;
+++ BasicApples;
++ ContainerDoor 'dresser door*doors' 'dresser doors'
"The doors are made out of plain wood. "
isPlural = true
subContainer = CSInnDresser1
;
Did you spot it?
If you said: the CSTrogLeaf1 object, your correct!!
I had to 'glue' myself to the screen while moving down each line when I
found it. Sorry to all for this stupid mistake.
--Ken
//generate's colored speech -- style tag usaged: <.speech> <./speech>
speech : StyleTag 'speech' '<font color=green>' '</font>';
Make working with different text colors easy and other things as well.
<./tag_name/> starts all tags and </./tag_name/> ends it. The items
in the single quotes replace both the start- and end-tags,