Author Topic: Missing ScriptObject/SimObject inheritance?  (Read 1188 times)

I've come across this multiple times and I have no idea what the cause is.

When I create an unnamed ScriptObject with a defined class, it fails to inherit all of the default functions of ScriptObjects.. ::schedule, ::dump, ::getClassName, etc.

It seems to happen particularly while add-ons are executing, but occasionally afterward too.

Code: [Select]
  %this = new ScriptObject() {
    class = "Structure";
    file = %file;

    rotation = 0;
    position = "0 0 0";
  };

  if(%this.getClassName() !$= "ScriptObject") { // I have no clue why this happens, but it does
    error("Registered a non-scriptobject script object?");
    %this.delete();
    return;
  }

  if(!isObject(StructureGroup))
    new ScriptGroup(StructureGroup);

  StructureGroup.add(%this);

If I load the server first, then execute my add-on, then call the command, it works fine.

It occurs regardless of the namespace I use, I've tried others thinking that Structure may be some default engine class.

This is very odd, I have never heard nor seen anything like this. The only thing I could think of that could possibly cause something like this is a terribly badly made dll injected, or if some weird add-on is somehow breaking something within the OnAdd method. Run a trace, try with default add-ons, remove unnecessary lines, etc.

Structure isn't a default class in the engine, just to clarify. %this.file = %file doesn't work, as %file isn't being defined at all inside the object. I'm assuming you left it in for future reference.

Also i dunno if %this.getClassName returns the parent class or the class specified. Never seen that used before

This is probably an interference with another script/add-on that uses the same or similar class names

%file is one of the function's arguments. Using default add-ons. For a properly registered and created object that doesn't have this issue, ::getClassName() will return ScriptObject.

Again, I've tried using a different namespace, so it's not interference.

Well what does getClassName return? Are you sure the object is actually being created?

Do you have any other example that shows this problem every time?

The Structure::* functions I've defined are all accessible and work fine. ::getClassName tells me that the function doesn't exist, like every other function that should be inherited.

I've worked with ScriptObjects many times before for the past 3-4 years and have never encountered this until recently. I've worked with multi-level inheritance before and never had this issue. I encountered it making Blockland Glass, and remedied it by just waiting for Blockland to finish loading before creating the object and it worked fine.

Yep, this has happened to me plenty of times. Occasionally even consistently, but I never found out why. In most cases, removing the superClass fixed it, but that isn't always an acceptable solution (or even applicable at all).

That's weird, I never had this issue. I used both script objects and script groups.

I've had this happen before, consistently. I believe that I worked around it by creating a temporary object of that class and then deleting it. Everything then worked the second time around.

Actually, here's the workaround itself. Line 86. That code was released to a few thousand users and didn't have problems related to the object issue.
« Last Edit: January 05, 2016, 10:34:58 PM by Greek2me »

Is it just the first instance of the class that has the issue?


That fixed it, thanks.