Jump to content

How to disable some code in player_common.lua OnLoad function


Recommended Posts

Hello, I need some help with something I have no idea how to do :(.

So, basically in player_common.lua in the OnLoad function I want to remove this code or prevent it from working

Spoiler

inst:DoTaskInTime(0, function()
        local my_x, my_y, my_z = inst.Transform:GetWorldPosition()

        if not TheWorld.Map:IsPassableAtPoint(my_x, my_y, my_z) then
        for k,v in pairs(Ents) do            
                if v:IsValid() and v:HasTag("multiplayer_portal") then
                    inst.Transform:SetPosition(v.Transform:GetWorldPosition())
                    inst:SnapCamera()
                end
            end            
        end

    end)

because this code is conflicting with my mod and it's really annoying

Thank you for reading and any help is awesome! Thanks and have a great day/night :D!

Edited by Warbucks
Link to comment
Share on other sites

11 hours ago, Warbucks said:

Hello, I need some help with something I have no idea how to do :(.

So, basically in player_common.lua in the OnLoad function I want to remove this code or prevent it from working

  Hide contents


inst:DoTaskInTime(0, function()
        local my_x, my_y, my_z = inst.Transform:GetWorldPosition()

        if not TheWorld.Map:IsPassableAtPoint(my_x, my_y, my_z) then
        for k,v in pairs(Ents) do            
                if v:IsValid() and v:HasTag("multiplayer_portal") then
                    inst.Transform:SetPosition(v.Transform:GetWorldPosition())
                    inst:SnapCamera()
                end
            end            
        end

    end)

because this code is conflicting with my mod and it's really annoying

Thank you for reading and any help is awesome! Thanks and have a great day/night :D!

:D that is exactly the code I was looking for, to make the goose-load working https://forums.kleientertainment.com/forums/topic/111740-woodie-rework/?do=findComment&comment=1260395
Are you currently trying the same? :D

I will look into it later today or maybe tomorrow, and we will find a solution for that ;)

 

Link to comment
Share on other sites

ok.. I think we have these possibilites:

1) Overwrite the OnLoad function and remove this code. This way we have to update the function everytime the devs do an update.
2) Add the drownable component for a short period of time. But many things depend on the drownable component, so this may have hundreds of unwanted side effects, I do not recommend this.
3) Remove the multiplayer_portal for a short period of time. If it is only in caves, I don't think it has bad sideeffects, since the portal is not used anyway, right?
4) Make the location passable for a short period of time, eg by spawning an invisible boat at the players location and remove it after loading.
5) Ask the devs to make this code more modfriendly, eg. by saving this task within inst, eg "inst.ImpassableTeleport = inst:DoTaskinTiem...", then we could cancel this task before it gets executed.

What do you think? :D
I think the spawning and removing of a boat would cause no trouble, so might be the best workaround... if we are able to spawn it before the OnLoad for the character is called.

Link to comment
Share on other sites

If the devs added something to disable it that would be ideal, but I don't know if they would add something that only modders would use :wilson_resigned:..

10 minutes ago, Serpens said:

4) Make the location passable for a short period of time, eg by spawning an invisible boat at the players location and remove it after loading.

This sounds okay if it's possible to do!

I probably would've picked removing the code if player_common wasn't such a big prefab which is updated frequently :wilson_ecstatic:!

And thanks for your help :D!!

Link to comment
Share on other sites

1 hour ago, Warbucks said:

If the devs added something to disable it that would be ideal, but I don't know if they would add something that only modders would use :wilson_resigned:..

This sounds okay if it's possible to do!

I probably would've picked removing the code if player_common wasn't such a big prefab which is updated frequently :wilson_ecstatic:!

And thanks for your help :D!!

hm... unfortunately 2 problems:
1) All "DoTaskInTime(0,..." are called in random order, so if we add one more to spawn a boat we can not gurantee that it is called before. And there is no lower possible number than 0...
2) Even if we succeed with this,  removing a boat will automatically trigger the "sink" stategraph for everything on the boat, but since we have no drownable, this will crash the server (might find a solution for this or even a bugfix from devs, since the goose should not sink when the boat sinks)

Currently I dont know how to solve 1) which means we also can not remove multiplayer_portal instead.
We could open a bugreport, reporting that the goose is sinking if the boat sinks on which the goose is and ask the devs in the same report to save the task in inst, so we can cnacel it. This will be the cleanest solution. And if they dont do it, I guess its best to overwrite the OnLoad function in this case... https://forums.kleientertainment.com/klei-bug-tracker/dont-starve-together/weregoose-is-sinking-if-boat-is-destroyed-r22078/

 

Link to comment
Share on other sites

Would this work around work?

If in impassable terrain save the coordinates you are at and when it loads, teleport back to the old coordinates a tick after the onload. If you are in passable terrain then no need to save the coordinates and because no data is loaded it doesn't need to run the hack teleport. Its kind of hacky, but its the best I can think that would be the least intrusive.

Edited by IronHunter
  • Like 1
Link to comment
Share on other sites

8 hours ago, IronHunter said:

Would this work around work?

If in impassable terrain save the coordinates you are at and when it loads, teleport back to the old coordinates a tick after the onload. If you are in passable terrain then no need to save the coordinates and because no data is loaded it doesn't need to run the hack teleport. Its kind of hacky, but its the best I can think that would be the least intrusive.

hm yes, this would work. depending on how fast you/warbucks need a solution, we could code this first or wait for the devs for ~one week, if they will add something.

9 hours ago, Warbucks said:

well then I guess it's replace player_common or hope klei does something about this, hopefully the latter :wilson_ecstatic:

no, we wont replace the whole file, only the OnLoad function.
See my code in the woodie rework thread, where I already do some stuff with the OnPreLoad function. We will do it similar with the OnLoad function.

Edited by Serpens
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
 Share

×
  • Create New...