intfiction.org

The Interactive Fiction Community Forum
It is currently Tue Dec 11, 2018 3:07 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Wed Feb 14, 2018 5:59 pm 
Offline

Joined: Sat Feb 10, 2018 7:42 pm
Posts: 9
Sorry if that has been asked before, searching is a bit difficult when some things get ignored.

How to pull off changing the name of an Object?
Is that a job for parse_name? It seems to be the only real solution, but maybe "name" can be edited somehow, too.
I really just need to add one or two more terms to it after identifying the object.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Feb 14, 2018 6:20 pm 
Offline
User avatar

Joined: Sun May 21, 2017 4:59 pm
Posts: 301
Location: Michigan
Hmmm... Checking out the bubble class examples might help:

Code:


  Class   Bubble(10)
    with  short_name [;
              print (address) self.&name-->0, " ", (address) self.&name-->1, " bubble";
              rtrue;
          ],
          name '.size' '.colour' 'bubble' 'bubbles//p',
          description [; print_ret (The) self, " floats gently in the air."; ],
          create [;
              self.&name-->0 = random('tiny','small','regular','large','enormous');
              self.&name-->1 = random('red','green','blue');
              PronounNotice(self);
              move self to location;
              StartTimer(self, random(5));
              "You carefully blow ", (a) self, ".";
          ],
          before [ player_gone s c;
            Attack,Burst,Cut,Push,PushDir,Rub,Squeeze,Take,Taste,Tie,Touch,Turn,Wave:
              StopTimer(self);
              player_gone = (self notin location);
              s = self.&name-->0; c = self.&name-->1;
              Bubble.destroy(self);
              self.&name-->0 = s; self.&name-->1 = c;
              if (player_gone) rtrue;
              "With a gentle 'pop', ", (the) self, " bursts.";
          ],
          time_left 0,
          time_out [; <<Burst self>>; ];


http://www.firthworks.com/roger/informfaq/oo.html

_________________
~~~
My ebooks on Amazon
My ebooks on Smashwords


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Feb 14, 2018 6:28 pm 
Offline
User avatar

Joined: Sun May 21, 2017 4:59 pm
Posts: 301
Location: Michigan
In fact a little test seems to show that

Code:
self.&name-->0 = 'Sally'; 


Can replace the first entry in the list of names for an object when I call it in an "Initial" block, so it'll probably work elsewhere as well.

_________________
~~~
My ebooks on Amazon
My ebooks on Smashwords


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Feb 14, 2018 6:43 pm 
Offline

Joined: Sat Feb 10, 2018 7:42 pm
Posts: 9
howtophil wrote:
In fact a little test seems to show that

Code:
self.&name-->0 = 'Sally'; 


Can replace the first entry in the list of names for an object when I call it in an "Initial" block, so it'll probably work elsewhere as well.

Yes, thank you, that worked just right.
Just got to take care to use single quotes/apostrophe for the new value, right.
The compiler/source accepting double quotes is trappy.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Feb 14, 2018 6:50 pm 
Offline
User avatar

Joined: Sun May 21, 2017 4:59 pm
Posts: 301
Location: Michigan
Yeah, if you need an apostrophe, you should do something like

Code:
self.&name-->0 = 'brunette^s'

which will be "brunette's" in game.

You can also add the name to the list of names by counting up your exisiting lists of names and popping it in after the last one:

Code:
name 'Sally','Girl','Woman',
...
...
self.&name-->3 = 'NewSally'

self.&name-->0 is 'Sally'
self.&name-->1 is 'Girl'
self.&name-->2 is 'Woman'

then, when you've added another
self.&name-->3 is 'NewSally'

_________________
~~~
My ebooks on Amazon
My ebooks on Smashwords


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Feb 14, 2018 7:12 pm 
Offline

Joined: Sat Feb 10, 2018 7:42 pm
Posts: 9
Cool, thank you very much!

I wasn't too sure if I could just add things at the end like that.
Initially I only skimmed the manual on that section, reading something about going beyond the boundaries of the array, and since I didn't want to deal with that at the time, yeah :P
Skipped it.
Going to study it more in depth next.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Feb 14, 2018 7:35 pm 
Offline
User avatar

Joined: Sun May 21, 2017 4:59 pm
Posts: 301
Location: Michigan
Maybe you can add some blanks to the name array... Not completely sure. Let me know how it works out :)

_________________
~~~
My ebooks on Amazon
My ebooks on Smashwords


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Feb 14, 2018 8:15 pm 
Offline

Joined: Fri Oct 18, 2013 10:13 am
Posts: 2669
Location: The Midwest
You can indeed add some blanks! I'm trying to remember the example number now, but one of the DM4 examples uses this.

(Though parse_name is usually better once you start needing two or more blank name entries.)

_________________
Daniel Stelzer


Top
 Profile Send private message  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 18 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group