Hello!
I would like to ask is there any way to set up or modify textual name of object without using of short_name property. I need to set up a name for dynamycally created objects of certain class, but in Russian Inform 6 library for Glulx (RInform) that I use short_name property has not word declension rules (as I know) so I need to find a way to set up a textual name. Any variants? Maybe some kind of opcode/glk magic?
1 Like
The Glulx Inform Technical Reference says:
The object structure:
This structure is generated by the compiler, and used by the veneer and library.
byte: 70 (type identifier for objects)
byte[7]: attributes
long: next object in the overall linked list
long: hardware name string
long: property table address
long: parent object
long: sibling object
long: child object
So, if I’m reading that correctly, storing the string address word (4 bytes) at memory position object+12
(which is obj-->3
under Glulx) should modify the equivalent value.
Constant Story "Glulx textual name modification";
Constant Headline "^(textual name = hardware string)^";
Include "Parser";
Include "VerbLib";
Include "Grammar";
Class Room
has light;
Room Start "Starting Point"
with description
"An uninteresting room.";
Object test_obj "original name" Start;
Global new_name = "modified name";
[ Initialise ;
location = Start;
print "The original name is: ", (name) test_obj, ".^";
test_obj-->3 = new_name;
print "The modified name is: ", (name) test_obj, ".^";
"... and it looks like that works!";
];
If that’s not what you meant, perhaps you can use a routine-based short_name
property to implement your own declension rules?
[ DetermineDeclension obj;
! This routine determines the declension case for an object
...
];
Object x
with case1_name "case 1",
case2_name "case 2",
short_name [;
switch (DetermineDeclension(self)) {
1: print (string) self.case1_name;
2: print (string) self.case2_name;
default: print "[declension error]";
}
],
...
2 Likes
The first variant has completely fitted. Thank you very much, otistdog! It was very helpful.
1 Like