is it possible to find out if the object has header-provided name? That’s distinct from the short_name property; I know how to check for that. I want to find out if it has the name provided like “This” in my example.
An object always has a built-in name like this, at least in Inform 6. (We generally say “hardware name”.) If you don’t provide one, the compiler generates a string like "(MyObj)".
Thanks, @zarf . Are you saying that it’s not possible find out whether or not we provided a hardware name or if the compiler created one? (I think so, just checking).
I’m looking through the veneer code, but it’s a bit hairy.
(For my case, it’d be fine if the check was “doesn’t-start-with-parentheses”, so if I know where that string can be accessed, I could print-to-array and see if it starts with a “(”)
The cost doesn’t matter (this will get run infrequently, at most 1x/turn). It’s when I’m creating a bunch of conversations options, it’d be very nice to be able to say:
Convo -> "This is the answer" with rel_obj Foo;
rather than having to say:
Convo -> with rel_obj Foo, short_name "This is the answer";
Some research suggests that obj-->0 might that address, but, if so, it doesn’t appear to be a string.
Thanks, @fredrik . It turned out that was what I hit on one second before. I appreciate you jumping in with that tip.
I don’t need the details right now (I am using Z-code), but with Glulx, I assume there’s something similar (print to this stream so you can investigate it), just spelled differently?
There is! Either works in my case, since there won’t be a short_name. But I should definitely use (object) (or, it looks like there’s an opcode for @print_object, which I imagine is pretty much the same thing)
I believe you can do it the same way, with print (object) whatever;. Glulx was designed specifically so as much of Inform as possible could work the same, so it has memory streams as an equivalent to Z-machine output stream 3, and a slot in the object record for an immutable name string. You’ll just be using glk_stream_open_memory() instead of @output_stream 3 and so on.
I’m still not seeing the situation. Why test the hardware name at all?
The Inform library provides the print (name) obj shortcut, which will print short_name (if present) or the hardware name otherwise. That covers both of your examples with no additional work.
If you provide no short_nameor hardware name, what do you want it to print?
I definitely didn’t give a helpful example; sorry, @zarf .
It’s basically just me trying to contort Inform6 a bit to make it easier to make lots of these “conversation topic objects” with a slightly shorter syntax. I wouldn’t really use “short_name” as the property (then, it would be easy—I could just print the object). It’s more that if no name is provided, I would check from a few other choices of properties (depending on whether you’re ASKing or TELLing or such), and being able to go up to the class if nothing is provided.
It’s also, perhaps, the ever-present itch of “but now I want to learn how to do this, even if it’s not 100% important here”, which ever-bedevils me at times when learning new systems.
If you want to do this, I would check all the objects’ hardware names once at the start of play, then give them an appropriate attribute. It’ll be distinctly slow to do every turn on retro hardware.