Hopefully, this is the right forum to attempt asking for opinions on source writing! I arrived at the beginning of Chapter II in Nelson’s manual, and entered/understood the first bits of the Ruins game. I decided to add a couple flags that would render a different response to “examine” if the mushroom had already been nibbled, was being taken for the second time, etc. – as well as an attempt to keep the mushroom intact after it’s been tried, since the player’s death occurred if he takes two bites (i.e. after the first warning that it tastes awful). Can anyone comment on the efficiency and “correctness” of my embellishments so far? (It works perfectly, so I suppose this is mostly a stylistic query – although you might see something that I don’t even need. I’m brand-spankin’-new at this, after all.)
Thanks very much for any help!
[code]constant story “RUINS^”;
constant headline “An Interactive Example^Copyright (C)1999 by
Angela M. Horns. Edited 2007 by Chris Federico.^”;
include “Parser”;
include “VerbLib”;
! The “random” outcome will always be the same after saving the text
! (source) file, oddly enough – not after each compilation, which was
! the initial suspicion. Twenty tests were conducted for each case. The
! contents of the text file were not altered; the file was merely re-saved.
!
! The exception: If the PC has been rebooted, there will be a different
! result – once. But this will always be the same post-reboot result for
! that .z5 file. WinFrotz will return to repeating the other result after
! this first try, and will not waver unless the PC is rebooted yet again.
!
! There appears to be no way to scramble the seed to prevent this.
!
! In other words, avoid random numbers in Inform; use some other
! method to give the illusion of randomness if it’s ever necessary
! (i.e. particular combination of items carried, number of turns, etc.).
object forest “~Great Plaza~”
with description
“Or so your notes call this low escarpment of limestone;
but the rainforest has claimed it back. Dark olive trees
crowd in on all sides, the air steams with the mist of a
recent warm rain, and midges hang in the air.^
~Structure 10~ is a shambles of masonry that might
once have been a burial pyramid, and little survives
except stone-cut steps that lead into the darkness below.”,
has light;
! Using “describe” as below, rather than “initial,” prevents a blank
! line from being printed between the room description and the
! “object here” prose.
object->mushroom “speckled mushroom”
with name ‘speckled’ ‘mushroom’ ‘fungus’ ‘toadstool’ ‘growth’ ‘stalk’,
mushroom_picked,mushroom_tried,
describe [;
if(self.mushroom_picked)
“There’s a speckled mushroom here.”;
“A speckled mushroom grows from the sodden earth
on a long stalk.”;],
description
“It’s capped with blotches, and you aren’t at all sure it’s
not a toadstool.”,
before [; eat:if(self.mushroom_tried)
{deadflag=true;“Now you know beyond the shadow of a
doubt that it’s a toadstool.^
The poisonous kind, as it turns out.”;}
else
{print “You nibble at it, but the foul taste repels you.^”;
mushroom.description=“Now you’re almost positive it’s a
toadstool.”;
self.mushroom_tried=true;
move self to player;rtrue;}],
! The object move above is necessary to keep the mushroom from
! being removed from the game after it’s eaten; it’s being taken back
! from “nothing.” The “return true” keeps the library from inserting its
! own “eaten” message after the specially added (“nibble”) one.
after [; take:
if (self.mushroom_picked)
“Taken. I’m afraid you were only able to kill it the one time,
though.”;
self.mushroom_picked=true;
“You pick the mushroom, neatly cleaving its thin stalk.”;
drop:
“The mushroom drops to the ground, detached and not
very happy about it.”;],
has edible;
[initialise;location=forest;
“^^^After days of searching, days of thirsty hacking through the briars of
the forest, your patience is rewarded at last. An actual discovery!^”;];
include “Grammar”;[/code]