Jump to content

override function: IsoDoor:ToggleDoor or IsoThumpable:ToggleDoor


TheZ

Recommended Posts

Hey folks,

 

I would like to ask is there are a way to override vanilla functions of IsoDoor and IsoThumpables?

What I'm trying to achive is just to a piece of my funcionality on every ToggleDoor function call for every signle door.

 

Its says that both functions are public and I can't feel any preventing clues of doing me so, but none of my infinite attempts were even close to success.

i tried to inject my stuff iside the function by doing so:

 

local originalToggleDoor = IsoDoor.ToggleDoor;
local originalToggleDoorThump = IsoThumpable.ToggleDoor;

---@param chr IsoGameCharacter
function IsoDoor:ToggleDoor(chr)
  print("My toxical injection comes here");
  originalToggleDoor(self, chr);
end

---@param chr IsoGameCharacter
function IsoThumpable:ToggleDoor(chr)
  print("My toxical thump injection comes here");
  originalToggleDoorThump(self, chr);
end

 

then I tried something that:

 

local originalToggleDoor;

---@param chr IsoGameCharacter
local function toxicToggleDoor(self, chr)
	print("My toxic stuff comes here");
	originalToggleDoor(self, chr);
end

Events.OnGameBoot.Add(function()
	originalToggleDoor = IsoDoor.ToggleDoor;
	IsoDoor.ToggleDoor = toxicToggleDoor;
end);

 

and there were a lot more of some odd attempted to at least break somehow this ToggleDoor but all were just ignored like I'm totally tryng to access something else.

no erros in logs, no any clue of the attempt just initial message which confirms that the script is loaded.

 

I want to find out where am I mistaken and is it doable at all. 

Please, save my zombified soul :)  thank you.

 

The answer for now is:

 

You can override lua functions.

You cannot override java methods (this way).

IsoDoor & IsoThumpable are Java classes.

 

We can subscribe for an event triggered during ToggleDoorActual and named "OnContainerUpdate".

But the event doesn't pass any parameter related to the Door itsef or another place from which this event could be triggered.

 

Edited by TheZ
Link to comment
Share on other sites

You can override lua functions.

You cannot override java methods (this way).

IsoDoor & IsoThumpable are Java classes.

 

I do not know how to override java methods from lua.

I do not know anyone who knows how to do that. (but if someone can, please explain me how).

 

 

That said, ToggleDoor* leads** to the call of LuaEventManager.triggerEvent("OnContainerUpdate");***

*In a subcall to ToggleDoorActual

**event is called only in some cases (not garage door, not double door, not locked door, ..)

***event is called with no parameter so you do not know if the OnContainerUpdate is called for a door opening or something else (like a zombie dead or item generation or whatever)

 

So, if you can maintain a list of doors, and identify that the door changed its state, you could inject your toxic stuff at that time.

It is tricky, verbose and will require a lot of work for a possibly meh result.

 

Edited by Tchernobill
ToggleDoorActual calls an event
Link to comment
Share on other sites

6 hours ago, Tchernobill said:

You can override lua functions.

You cannot override java methods (this way).

IsoDoor & IsoThumpable are Java classes.

Thank you for your self-sufficient answer.

I had feeling that this is somehow like that, but didn't find any evidence that is so before asking.

 

Now its clear. Okay, the only thing that we got is this "OnContainerUpdate" event  triggered during ToggleDoorActual call which is no how connected to the door itself which makes it a tricky thing to maintain this somehow.. Okay.. I see. Thanks again for clearing things here.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...