> - Except for @parent, it doesn't seem to be a way to *create* an
> object of a particular type (i.e. as a child of a particular script
> parent). The @parent command is no good, it kicks in after an object
> is already created and thus it does not call at_object_creation()
> which is the main function for customizing object parents I reckon. I
> have an implementation here which adds this ability to the @create
> command; the syntax is @create object=parentpath.
This is definitely needed. Feel free to commit your implementation and
we'll poke at it. To be honest, I'm not sure what will happen when you
add the event as you have. I'm thinking we may see some issues, but
it's worth a shot. To get the affect you're looking for, the current
way to do it would be to have your events in a separate module that
searches for the relevant objects and runs stuff through their script
parent. Coming from a MUX/MUSH background, I grew into the habit of
trying to keep to the looping interval events to an absolute minimum,
so I hadn't spent much time trying to figure out how to make such
things easier.
>
> - There was no error checking at all for setting the script parent
> using set_script_parent(). Setting this with a non-valid script path
> causes *havoc* -- you cannot do anything with the object. You can't
> even destroy it since it throws an exception trying to call
> obj.scriptlink.at_object_destruction(); Database reboot seems the only
> way to get rid of such messed up items. So to prevent the system to
> add a nonsense script path to the object, I added a direct error check
> in set_script_parent(). The check (using the relevant scripthandler
> method to see if the module is loadable) causes the script to be
> cached immediately upon addition. I think that's a reasonable price to
> pay.
Yeah, @parent is still extremely rough around the edges. I don't see
any problem with loading on demand. As you mentioned, after the first
cache, you're good to go.
>
> - A less severe, but annoying thing is also the confusion in
> nomenclature. why is it called "script parent" in some places, whereas
> it's called "script link" in others? Should not either of
> set_script_parent() and get_script_link() really be renamed to match,
> for example?
The idea is that the script link is what you use to get to an Object's
script parent. The link handles all of the transparent caching or
returning the default script parent if none is specified. The actual
script parent is the Python module that determines the object's
behavior. I probably have interchanged the two terms a few times where
I shouldn't be. Feel free to point out or fix these crosses.
> Two final things I wonder about are related to the parented objects
> themselves and the so-called event system. I thought I understood how
> this worked, but creating an extension of example/red_button.py to
> make the button flash regularly met with no success. I supply my code
> below.
I'm not too sure it'll work as you've got it outlined. You will
probably need to break the IntervalEvent and the add_event() call out
into another module. To test this theory, create a bogus module that
searches for anything with the script parent you're wanting to beep or
blink, and have it do its stuff with those objects rather than putting
the event code in the script parent. Import it from either your script
parent (which means the event will be added once you interact with a
button), or toss it in another arbitrary module for the sake of
testing. See src/imc2/events.py for a relatively simple example. Once
that module gets imported, it inserts that event.
> Same goes with having "local commands" on an object, is the object's
> command_table variable really executed somewhere? At any rate,
> commands defined in the ways I tried didn't do anything (I assume just
> writing 'press' or maybe 'press button' should work if the button is
> in the same room?)
The local command table stuff is pretty high priority, I've just been
putting it off (which is bad). This is theoretically 95% ready to go,
it just needs to start looking stuff up. I'll get this handled very
soon and this portion of things will be ready to rock.
If you'd like, commit your @create and @parent changes and we'll test
and adapt from there. I'll kick myself into getting local command
table searching ready to go very soon.
Greg