Author Topic: Parent-Child relations  (Read 575 times)

So I created a scriptObject using the code below:
Code: [Select]
%this.Mini = new scriptObject()
{
class = SlyrMinigameSO;
superClass = MinigameSO;
};

What I want to happen is that when someone packages a function like MinigameSO::Reset() that packaged function is also called when SlyrMinigameSO::Reset() is called. Is that possible?

Make SlyrMinigameSO::Reset() call MinigameSO::Reset()

If you do not actually want MinigameSO::Reset() to be called, you can call the function with an argument, then of course edit MinigameSO::Reset() to do nothing when that variable is true.  I do not think simply packaging and returning will work, since that will still break alot of functions triggered by MinigameSO::Reset(), but I am honestly not sure if that is the case.

I legit expected a topic about how your parents beat you or something

I legit expected a topic about how your parents beat you or something
hahaha I was waiting for that

---
Do you know if there's a less hacky way to do it?

hahaha I was waiting for that
Do you know if there's a less hacky way to do it?

If you want all the things that package minigameso::reset() to be called, then it is inevitable that you also call minigameso::reset()

Beyond that, there are a number of ways you can make it so minigameso::reset itself doesn't actually do anything when called, and I gave you a few examples.

You do not really have that many options with the method you use to accomplish this.

I guess I could just get rid of SlyrMinigameSO entirely and just use MinigameSO, checking that it's a slayer minigame, but are there any other methods you can think of?

I legit expected a topic about how your parents beat you or something
Lol'd.

Do you know if there's a less hacky way to do it?
parent::reset(%mini, %winner);

parent::reset(%mini, %winner);

That still won't call the packages of minigameso::reset()

just the slyrminigameso::reset()

That still won't call the packages of minigameso::reset()

just the slyrminigameso::reset()
I tested this out because I wasn't sure.
Executing the following code:
Code: [Select]
$FooBar = new ScriptObject()
{
superClass = "Foo";
class = "Bar";
};

function Foo::DoStuff(%n)
{
echo("Foo!" SPC %n);
}

function Bar::DoStuff(%n)
{
parent::DoStuff(%n);
echo("Bar!" SPC %n);
}

package FooBarPackage
{
function Foo::DoStuff(%n)
{
echo("Packaged Foo!" SPC %n);
parent::DoStuff(%n);
}
};
activatePackage(FooBarPackage);

$FooBar.doStuff();
Results in this console output:
Code: [Select]
Packaged Foo! 7324
Foo! 7324
Bar! 7324
So it should work.