Jump to content

[request] skilled modders to look into mod compatibility issues.


Recommended Posts

Hi All,

 

I'm trying to use these two mods together:

 

SimpleHUD: http://steamcommunity.com/sharedfiles/filedetails/?id=286844464

Backpack and Amulet: http://steamcommunity.com/sharedfiles/filedetails/?id=277517714

 

I'm getting some very strange feedback between the two mods, documented in the conversation between myself and the SimpleHUD author (quoted at the end of this post, and available in the comments for the SimpleHUD mod on steam community).

 

I don't have very much Lua experience nor modding for DS, but I've combed through both mods and I've determined through systematic commenting of code, that the failure happens when we call:

 

require "screens/playerhud"

through the AddClassPostConstruct call in Backpack and Amulet. I've refactored the code a bit to not use AddClassPostConstruct, and instead override the PlayerHUD:SetMainCharacter function directly, but that also requires us to do the require statement above, which is how I learned that that is what breaks things. The even stranger thing is this problem seems to be only happening for me.

 

My request is for some more experienced modder to take a look at the comments below, through the screenshots that document my issue, and look at the code for these mods, to see what the heck is going on. I realize this is a big request, but it might be a fun thing to look into for someone who is bored and has a bunch of free time and energy. It might turn out that the problem has nothing to do with either of these mods, and if that's the case, maybe someone has seen something like this before and knows how to fix it in my settings or something.

 

Plaidman:

Very strange mouse. For me the hunger digits don't stay on at all, and the health digits stay on but turn off if I hover over them with my mouse. I'm pretty sure it's these two mods. I disabled all mods except them and I saw it happening. Then when I enabled this one and several others except the backpack/amulet one, it worked perfectly fine. I'll play around with it tonight a bit.

So the mod isn't actually crashing, just behaving strangely, so I don't know if this is helpful but here's the log.txt: http://pastebin.com/98zMZTdY It shows me starting a new game, hovering over the widgets a bit, then quitting.

 

I'm normally running on the mac steam version but I downloaded the standalone version and copied the Backpack/Amulet and SimpleHUD mods to the standalone version: http://imgur.com/u00BvY3

 

Here's some screenshots of what it's doing.

The first one is when the game first loads: http://imgur.com/MOHWuIw

The second one is after I move the mouse over the widgets a few times: http://imgur.com/kHdG5hX

 

Strangely, when I hover over the health widget and it disappears, if I then take damage or heal damage, the digits come back and stay until I hover over the widget again.

Mouse:

I'm really at a loss here. I swear it's working on my end. I even made this short video. https://copy.com/DQVX1MGI14Nr I forgot to setup the sound and there's some frame stuttering but you get the idea.

 

Everything looks pretty normal in your log. The only thing that comes to mind is maybe try disabling small textures, if they're enabled. His backpack-amulet mod doesn't use textures with dimensions at a power of 2. Normally, this would make your game crash if small textures are enabled but it's worth trying anyways. Also, could you screenshot your graphics settings? I'm sorry I'm having you do so much but you're the only person who's reported this problem.

Plaidman: 

I'm with you mouse. I've looked at the code and with my limited Lua knowledge I can say that these two mods shouldn't be interacting. I appreciate the effort but you certainly don't need to stress yourself over my weird corner case if nobody else is seeing it.

 

For your morbid curiosity though, here's my video settings: http://imgur.com/i7mPp4K

Link to comment
Share on other sites

this mod changes widgets directly or in API way?

 

anyway his goal - is only show number without howering by mouse, its can be done in API way

that how its done in "Status Plus" :

local function TweakNum(inst)    --inst.OldHide = inst.Hide or function() end -- not really required in your case    --inst.OldDeactivate = inst.Deactivate or function() end -- not really required in your case    function inst:Hide() end    function inst:Deactivate() end    --function inst:DoHide() if self.OldHide then self:OldHide() end end -- not really required in your case    --function inst:DoDeactivate() if self.OldDeactivate then self:OldDeactivate() end end -- not really required in your case    function inst:OnLoseFocus() end    function inst:OnGainFocus() endendlocal function TweakBadge(inst)--        if self.num and self.num.Kill then self.num:Kill() end  -- you dont need it--        self.num = self:AddChild(Text(NUMBERFONT, 28))  -- you dont need it        inst.num:SetClickable(false)        TweakNum(inst.num)end AddClassPostConstruct("widgets/sanitybadge", TweakBadge)AddClassPostConstruct("widgets/healthbadge", TweakBadge)AddClassPostConstruct("widgets/hungerbadge", TweakBadge)

done, its your "SimpleHud"

Link to comment
Share on other sites

Here is the code for SimpleHUD: http://pastebin.com/z5WFBEfQ
Here is the code for Backpack and Amulet: http://pastebin.com/NMH3j3Jc

It looks like SimpleHUD is done by overriding the functions directly and B&A is done through the API. Your suggestion seems to be working mostly, but it doesn't match SimpleHUD's functionality exactly. It can be a "good enough for now" thing, but I would still like to figure out what's wrong with my setup that this is only happening on my computer.

 

Edit: Let's say I want to get into coding mods. Is one way (API) preferred over the other (overriding functions directly)? From a "Klei intends us to work this way" perspective? From a "this works faster/better" perspective?

Link to comment
Share on other sites

API is always better. usually code is much smaller and easier to update, while non-API way - you have to look into changes in every update/fix. Also its make alot of troubles like you get. That the reason why i dodn't use AlwaysOnStatus, DisplayFoodValues and RPGHUD.

They make direct changes and some of them have outdated base file(s) (file of earlier version of game which used in mod).

 

Link to comment
Share on other sites

well looks like SimpleHUD and BackPack is using API way, check if its haven't standard components in mod_name/script/widget/*.lua

if not - i dont see any criminal in SimpleHud here, nothing wrong in overridng in this way imho.

 

i am not good in english and i don't get where you commented

"require "screens/playerhud"

both mods doesn't have this string at least at your pastebin

 

anyway, i make this kind of mods 2 month ago, first time i was about to make amulet slot too, but i saw that its required much more time and i forget about it, anyway i don't use amulets in game :-)

 

don't remember what exactly was a problem, but probably its was function that you mentioned, sadly i bit tired from DS and need a break, same with mods

 

so maybe someone really experienced like squeek and simplex look into it

Link to comment
Share on other sites

API is always better. usually code is much smaller and easier to update, while non-API way - you have to look into changes in every update/fix. Also its make alot of troubles like you get. That the reason why i dodn't use AlwaysOnStatus, DisplayFoodValues and RPGHUD.

They make direct changes and some of them have outdated base file(s) (file of earlier version of game which used in mod).

 

This makes sense. I'll check out their code to see what NOT to do. =)

 

well looks like SimpleHUD and BackPack is using API way, check if its haven't standard components in mod_name/script/widget/*.lua

if not - i dont see any criminal in SimpleHud here, nothing wrong in overridng in this way imho.

 

i am not good in english and i don't get where you commented

"require "screens/playerhud"

both mods doesn't have this string at least at your pastebin

 

anyway, i make this kind of mods 2 month ago, first time i was about to make amulet slot too, but i saw that its required much more time and i forget about it, anyway i don't use amulets in game :-)

 

don't remember what exactly was a problem, but probably its was function that you mentioned, sadly i bit tired from DS and need a break, same with mods

 

so maybe someone really experienced like squeek and simplex look into it

 

I had refactored the code in B&A a bit to do things a bit more closely to how it's done in SimpleHUD: http://pastebin.com/3br9sHv1

 

If I comment the function override at the bottom and I comment line 2 (require "screens/playerhud") then the mods work fine together. On the other hand, if I comment the function override at the bottom and leave line 2 uncommented, then the mods don't work together. Of course, commenting out the big function at the bottom of the code makes the B&A mod not work at all, but it needs to be commented to demonstrate the issue effectively.

 

For further evidence, the original unmodified B&A mod calls AddClassPostConstruct, which in turn calls (require "screens/playerhud") as part of its code.

Link to comment
Share on other sites

oh this

not sure that its good idea

local PlayerHUD = require "screens/playerhud"

imho, you have to tweak it in way like it was done in backpack mode

AddClassPostConstruct("screens/playerhud", function(self)

and then play with mod priority, make it lower than this 2 mods have.

that grants that your mod will load last.

 

but imho its not issue.

 

what error in log shows after using both mods?

Link to comment
Share on other sites

Here's the error log: http://pastebin.com/98zMZTdY

 

My next thought was a priority issue. I was going to play around with that after work when I get home, but I won't hold out hope if you think it's not that. I will also try to tweak SimpleHUD to use AddClassPostConstruct using your example above as a base. It seemed to work fine in that case, I would just need to add the missing hover and temperature functionality, which should be easy.

Link to comment
Share on other sites

oh btw i am watched my version of backpack mod, and i see that i am using almost similar way

that you tried, but with some difference, and i dont remember why i maid it, just because i love to check input variables or maybe its was issue:

 

modmain

Assets = {Asset("ATLAS", "images/backpack.xml")}function TweakBackpack(inst)    inst.components.equippable.equipslot = GLOBAL.EQUIPSLOTS.BACKendfunction TweakInventory(component,inst)    inst.components.inventory.numequipslots = 4    inst.components.inventory.maxslots = inst.components.inventory.maxslots - 1endfunction TweakInvBar(inst)    inst:AddEquipSlot(GLOBAL.EQUIPSLOTS.BACK, "images/backpack.xml", "backpack.tex")    inst:Rebuild()endtable.insert(GLOBAL.EQUIPSLOTS, "BACK")GLOBAL.EQUIPSLOTS.BACK = "back"AddComponentPostInit("inventory", TweakInventory)AddPrefabPostInit("backpack", TweakBackpack)AddPrefabPostInit("krampus_sack", TweakBackpack)AddPrefabPostInit("piggyback", TweakBackpack)AddPrefabPostInit("icepack", TweakBackpack)AddClassPostConstruct("widgets/inventorybar", TweakInvBar)local PlayerHud = GLOBAL.require "phfix"

script/phfix.lua:

local PlayerHud = require "screens/playerhud"local OldSMC = PlayerHud.SetMainCharacterfunction PlayerHud:SetMainCharacter(maincharacter)    OldSMC(self,maincharacter)             if maincharacter then        local bp = maincharacter.components.inventory:GetEquippedItem(EQUIPSLOTS.BACK)        if bp and bp.components.container then            bp.components.container:Close()            bp.components.container:Open(maincharacter)        end    endendreturn PlayerHud

so you can try to adapt this overrided SetMainCharacter for your needs.

but still a question, any of this mod have something inside scripts/widgets scripts/screens ?

 

dont remember why i checking this maincharacter variable, but probably its was issue with custom character.

 

"return" in this script is probably not required, as a local variable in modmain.

 

since assigning table(class) to variable is causing assigning table's address, not value

so this file is changing function SetMainCharacter in global object

just too lazy to test it and remove this useless parts of code

 

rule of programmers : don't touch code which works :)

Link to comment
Share on other sites

Yea that looks very similar to my refactored version of the B&A mod. Your line 1 in phfix.lua (local PlayerHud = require "screens/playerhud") is what is crashing SimpleHUD for me.

 

 

but still a question, any of this mod have something inside scripts/widgets scripts/screens ?

 

Both of the mods modify classes defined in Lua scripts in those folders (widgets/badge.lua for SimpleHUD, and screens/playerhud.lua for B&A). I'm not sure if that answers your question.

 

 

rule of programmers : don't touch code which works

 

That's what git is for!

Link to comment
Share on other sites

i understand that they modifying, i mean mods structure itself

inside mod dirctory you usually see

modmain.luamodinfo.lua
 

 

more complex mods have new/changed files similar to vanilla game structure

modmain.luamodinfo.luascripts/prefabs/scripts/widgets/scripts/screens/scripts/random_name/
 

so if there files inside "scripts/widgets" "scripts/screens" they can have same name as vanilla game files, thats bad (nonAPI way) sign.

but dont think that they are exists

 

weird that you have crash, i don't see anything in log about it

anyway i guess using

AddClassPostConstruct("screens/playerhud", function(self)
still better and proper, imho.

all this "Post" functions adding their arguments to array where they will be called at proper game stage, one by one for each class

Link to comment
Share on other sites

For the record, none of my code should overwrite any of the original functions. It's merely tacked on to the end of them so when those functions are called, both the original and the modded functions still run but the tacked on code has the final say. In this case, it's mostly about having the final say on when to show and hide the hover text.

Link to comment
Share on other sites

well to make them work both you need to add

priority = 2
to SimpleHud modinfo.lua

its must be any priority > 0

somehow changes in badges not works, my guess here only one:

BackPack loading playherhud class, which loading badges. Vanilla badges! And this vanilla badges is base for sanity,hunger and such.

changes in simplehud mod is applying AFTER this badge class used.

but its my guess, nothing more. simplex and squeek know proper answer

Link to comment
Share on other sites

I just double checked by putting prints(print("function x called)) in the default widgets/badge functions(ongainfocus, onlosefocus and setpercent) and all the prints are working as expected. So I'm certain the original functions are still running and being called and all that.

Link to comment
Share on other sites

I just double checked by putting prints(print("function x called)) in the default widgets/badge functions(ongainfocus, onlosefocus and setpercent) and all the prints are working as expected. So I'm certain the original functions are still running and being called and all that.

you did nothing wrong, there probably only one problem that Badge Class isn't used directly, its inherited by SanityBadge and rest.

PlayerHUD building with vanilla badget if its called before your mod.

So SanityBadge gets vanilla methods in his class table, while Badge itself is proper.

thats my guess.

Link to comment
Share on other sites

I can't reproduce the bug on my own system. So can someone tell me if it's still happening if you change the function in the backpack amulet mod to read:

AddClassPostConstruct("screens/playerhud", function(self)     local oldfn = self.SetMainCharacter    function self:SetMainCharacter(maincharacter)    	local asdf=oldfn(self, maincharacter)    	self.controls.inv:AddEquipSlot(GLOBAL.EQUIPSLOTS.BACK, "images/newslots.xml", "back.tex")    	self.controls.inv:AddEquipSlot(GLOBAL.EQUIPSLOTS.NECK, "images/newslots.xml", "neck.tex")    	self.controls.inv.bg:SetScale(1.25,1,1.25)	    local bp = maincharacter.components.inventory:GetEquippedItem(GLOBAL.EQUIPSLOTS.BACK)    	if bp and bp.components.container then    		bp.components.container:Close()    		bp.components.container:Open(maincharacter)        end	return asdf    endend)
All I did was change the line that read "oldfn(self, maincharacter)" to "local asdf=oldfn(self, maincharacter)" then had it return that variable. I tested it on my system and it still works just fine but like I said, I can't reproduce the bug so I have no point of reference.
Link to comment
Share on other sites

well i got exactly same issue with OP, and changing loading order helps here.

however i didn't turn off all other mods due to laziness :-), maybe some of them is causing something like this.

but OP said he tested game with this mods only.

i am not professional Lua programmer or DS expert, if my guessing about root of problem is right and my suggestion is helps - good.

Link to comment
Share on other sites

and my guess why you didn't see problem - on your PC mod probably have different name then workshop-286844464, so its loading before BackPack mod and you doesn't see problem

but for Workshop users, your mod comes after BackPack (ie workshop-277517714)

since they have same priority they loading on sorted order and string "workshop-277517714" is "less" then "workshop-286844464" in comparison function of sorting procedure

thats my guess too :-)

rename your mod to zzzzzzzzzzzzzzz (any letter after w) and probably you get same issue.

Link to comment
Share on other sites

I've been watching this but wasn't exactly sure what to add, and I still am not. But my theory of what happens is similar to what Rince said, basically, since backpack mod is getting called before simpleHUD, when it does

 

local PlayerHud = require "screens/playerhud"
 
it effectively forces all badge class files to get loaded. Apparently lua 'inheritance' mechanics is making it not reflect the changes made on base class AFTER the inheriting class is loaded at all, so despite you changing Badge properly, it can no longer propagate to the other 3. That's... scary, to say at the very least, leading to bugs crazy hard to catch. And, sure, if you move priority to 2+ it doesn't happen because overriding is happening before the 'real' badges get loaded.
 
I don't know why it doesn't happen to Mouse tho, are the rest of us on Windows and him only one on linux by any chance? Nevermind, the original log is showing OSX so should be same as linux for all purposes.
Link to comment
Share on other sites

btw instead of changing basic badge you can change real badges

like

 

function asdfg(i){ -- since you like to name temporary variables as asdf           	local asdf1=i.OnLoseFocus        function i:OnLoseFocus(...)                local asdf = asdf1(self,...)		self.isfocused=false   		if self.num then			self.num:Show()		end		if self.num2 then			self.num2:Hide()		end 	        return asdf        end-------------- same for other methods-------end
and now override methods in actual classes, not in parent

AddClassPostConstruct("widgets/sanitybadge", asdfg)AddClassPostConstruct("widgets/healthbadge", asdfg)AddClassPostConstruct("widgets/hungerbadge", asdfg)
so you dont need to care about priority, if there no other mods which want to change same
Link to comment
Share on other sites

and last thing to post before sleep:

OnLoseFocus doesn't return anything, look at parent class "Widget" in widgets/widget.lua

same for other methods.

so you dont need this

local asdf = asdf1(self,...)
just call

asdf1(self,...)
and don't return anything

but check every function before, i didn't check them all

well returning nil doesn't harm any kitten, so you can keep this.

Link to comment
Share on other sites

Yeah, I was about to say, that means that if you want to make sure your mod works at any priority level, you would have to override both the parent class and all classes inheriting it, which is exactly defeating the purpose of inheritance in the first place...

 

Ah well, good to know it acts that way after all.

 

And btw, his way of returning the original functions value is still better even if at the moment said functions have no return values, for the sake of future compatibility.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...