Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

run-time object naming

3 views
Skip to first unread message

Poptasticboy UK

unread,
Jun 3, 2001, 4:55:48 PM6/3/01
to
Hi.

I'm thinking about a game which will generate some NPC's at the start of the
game, giving them attributes, behaviours, personalities etc., to help make each
game unique.

Ideally I would like their names to be generated as well, so they will also
have different names each time the game is played (it's not just the same
character with a different personality, but a different person altogether).

This appears, however, to be problematic. I have read through the TADS manual
and haven't come across any way for naming an object at run-time. The problem
is that the player needs to be able to refer to the character by the generated
name, and thus the dictionary needs to be extended at run-time. Is this
possible in TADS? Have I missed something, or is there perhaps an obscure way
around this?

I've read through DM3 and begun DM4, but have not yet spent as much time on
Inform as I have on TADS. My initial impression is that this would also be a
problem in Inform. Is this the case?

My first look at Hugo suggests that this this is something Hugo can achieve
relatively easily. I'd appreciate any thoughts anyone has about whether this
*is* achievable in TADS/Inform, and if not, what "deficiencies" there are in
using Hugo when compared to the other two.

Thanks for any ideas.
Chris Warr.

David Glasser

unread,
Jun 3, 2001, 5:26:02 PM6/3/01
to
Poptasticboy UK <poptast...@aol.com> wrote:

> This appears, however, to be problematic. I have read through the TADS manual
> and haven't come across any way for naming an object at run-time. The problem
> is that the player needs to be able to refer to the character by the generated
> name, and thus the dictionary needs to be extended at run-time. Is this
> possible in TADS? Have I missed something, or is there perhaps an obscure way
> around this?

Take a look at the addWord function and its ilk. (Stephen Granade does
something like this in Losing Your Grip.)

> I've read through DM3 and begun DM4, but have not yet spent as much time on
> Inform as I have on TADS. My initial impression is that this would also be a
> problem in Inform. Is this the case?

I'm pretty sure it's not possible in Inform, at least without a lot of
special casing.

--
David Glasser
ne...@davidglasser.net http://www.davidglasser.net/

T Raymond

unread,
Jun 3, 2001, 5:38:03 PM6/3/01
to
Poptasticboy UK was overheard typing about:

> I'm thinking about a game which will generate some NPC's at the
> start of the game, giving them attributes, behaviours,
> personalities etc., to help make each game unique.
>
> Ideally I would like their names to be generated as well, so they
> will also have different names each time the game is played (it's
> not just the same character with a different personality, but a
> different person altogether).
>
> This appears, however, to be problematic. I have read through
> the TADS manual and haven't come across any way for naming an
> object at run-time. The problem is that the player needs to be
> able to refer to the character by the generated name, and thus
> the dictionary needs to be extended at run-time. Is this
> possible in TADS? Have I missed something, or is there perhaps
> an obscure way around this?

I'm no expert, but here's what I know. No you can't name an 'object'
at runtime. I will presume your npc names will be chosen out of some
sort of list? You can add that name to the actual object. I think you
want to check out the addword function. In code your npc would look
something like this:

npc1: actor
sdesc = "NPC"
ldesc = "An NPC of indeterminate origin. "

noun = 'npc1'
adjective = 'first'

....
;

In your routines that generate the names, you would use addword to
add your generated name to the npc1 object. So say your routine picks
the name Joe. You'd do the following to make npc1 able to be referred
to by the name Joe:

addword (npc1, &noun, 'joe'); //to add Joe as his name
delword (npc1, &noun, 'npc1'); //to remove name placeholder

You can do the same with adjectives so that you can add in words that
tie in with whatever behavious that you generate for the npc.

I can't speak for Inform or Hugo, I don't know much about how they
work. There's probably some similar functionality in both, but I'll
let those who know answer on those languages.

Hope that helps some.

Tom
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Tom Raymond adk AT usaDOTnet
"The original professional ameteur."
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Andrew Merenbach

unread,
Jun 3, 2001, 5:44:16 PM6/3/01
to
Note: Poptasticboy UK's posting asked if it was possible in TADS, and if he
or anybody else wishes to stick with TADS, I'm happy, because we need some
variety in this sometimes-dull universe. TADS, Inform, Hugo, whatever. I
don't know TADS, so I don't know any programming tricks, etc. for it.
However, if anybody finds this helpful, or wishes to help me learn more by
alerting me to any mistakes I make (I've done pretty much everything I've
described below, so there _shouldn't_ be any), I'd be happy to hear from
them.

in article 1eufsdd.alzgur1enczo6N%ne...@davidglasser.net, David Glasser at
ne...@davidglasser.net wrote on 6/3/01 2:26 PM:

>> I've read through DM3 and begun DM4, but have not yet spent as much time on
>> Inform as I have on TADS. My initial impression is that this would also be a
>> problem in Inform. Is this the case?
>
> I'm pretty sure it's not possible in Inform, at least without a lot of
> special casing.

Actually, I think it'd be relatively easy--just give an object a short_name
routine, instead of a simple property, and mix together a bunch of things
for the name. For example:

! stick the line "GenerateNames();" (without the quotes) into your
Initialise routine.

[ GenerateNames n;
person_1.selfname = random ('Herman','Bob','Robert');
person_1.selfjob = random ('teacher','doctor','lawyer');
person_1.&name-->0 = person_1.selfname;
person_1.&name-->1 = person_1.selfjob;
];

Object person_1
with
name ' ' ' ',
short_name [; print_ret (address) self.selfname, " the ", (address)
self.selfjob;],
description [; "Why look! It's ", self.shortname();],
selfname, ! this is a made-up property to store this characters
name, outside of the short_name propery
selfjob, ! this is another made-up property, to store this
character's job title
has proper;

Just make as many people as you need, and add as many people as you want to
the GenerateNames routine.

--
Andrew M.

David Glasser

unread,
Jun 3, 2001, 7:18:41 PM6/3/01
to
Andrew Merenbach <amere...@mac.com> wrote:

> ! stick the line "GenerateNames();" (without the quotes) into your
> Initialise routine.
>
> [ GenerateNames n;
> person_1.selfname = random ('Herman','Bob','Robert');
> person_1.selfjob = random ('teacher','doctor','lawyer');
> person_1.&name-->0 = person_1.selfname;
> person_1.&name-->1 = person_1.selfjob;
> ];

Right, but you still have the specify the names literally in the source
code. You can't base it on player input, say.

OKB -- not okblacke

unread,
Jun 3, 2001, 10:59:58 PM6/3/01
to
poptast...@aol.com (Poptasticboy UK) wrote:
>I'm thinking about a game which will generate some NPC's at the start of the
>game, giving them attributes, behaviours, personalities etc., to help make
>each
>game unique.
<snip>

>I've read through DM3 and begun DM4, but have not yet spent as much time on
>Inform as I have on TADS. My initial impression is that this would also be a
>problem in Inform. Is this the case?

I believe it can be done, although I'm not sure of the exact way.
Platypus provides a "runtime dictionary", certainly. I think this uses the
@encode_text opcode. I haven't done much with this type of thing in Inform,
but I think it's possible.

--OKB (Bren...@aol.com) -- no relation to okblacke

"Do not follow where the path may lead;
go, instead, where there is no path, and leave a trail."
--Author Unknown

Aris Katsaris

unread,
Jun 4, 2001, 2:31:00 AM6/4/01
to

David Glasser <ne...@davidglasser.net> wrote in message
news:1eufxlp.y5foybuo8wieN%ne...@davidglasser.net...

> Andrew Merenbach <amere...@mac.com> wrote:
>
> > ! stick the line "GenerateNames();" (without the quotes) into your
> > Initialise routine.
> >
> > [ GenerateNames n;
> > person_1.selfname = random ('Herman','Bob','Robert');
> > person_1.selfjob = random ('teacher','doctor','lawyer');
> > person_1.&name-->0 = person_1.selfname;
> > person_1.&name-->1 = person_1.selfjob;
> > ];
>
> Right, but you still have the specify the names literally in the source
> code. You can't base it on player input, say.

"Balances" has an example of naming objects at run-time based on
player input. Given some copy&paste it doesn't seem too difficult... :-)

Aris Katsaris


Stephen Granade

unread,
Jun 4, 2001, 5:28:10 PM6/4/01
to
ar...@see.the.sig (T Raymond) writes:

You can also have him described as such. Give each NPC a property
called "name":

class NPC: Actor
name = 'npc'
sdesc = { "<<self.name>>"; }
ldesc = {
"<<self.name>> should really have a more interesting description
here. ";
}
actorDesc = {
"<<self.name>> is here. ";
}
;

Then, when you get ready to create an NPC and give it a name, do the
following:

addword(npc1, &noun, 'joe');
npc1.name := 'Joe';

More baroque variations on this are certainly possible.

Stephen

--
Stephen Granade | Interested in adventure games?
sgra...@phy.duke.edu | Visit About Interactive Fiction
Duke University, Physics Dept | http://interactfiction.about.com

0 new messages