Hornete Posted April 27, 2019 Share Posted April 27, 2019 Hello! I would like to find out how to set custom colour cubes when wearing certain hats, I've got the colour cubes but I don't know how to apply it when the hat is worn. Any help is appreiciated! Thanks for reading! Link to comment https://forums.kleientertainment.com/forums/topic/105476-colour-cubes-for-hats/ Share on other sites More sharing options...
CarlZalph Posted April 27, 2019 Share Posted April 27, 2019 Listen for the onequip/onunequip events from the hat and then apply the colour cube to the owner if it's a player. You can find pretty much all of this code with the moggles hat alone. Link to comment https://forums.kleientertainment.com/forums/topic/105476-colour-cubes-for-hats/#findComment-1186534 Share on other sites More sharing options...
Hornete Posted April 27, 2019 Author Share Posted April 27, 2019 24 minutes ago, CarlZalph said: Listen for the onequip/onunequip events from the hat and then apply the colour cube to the owner if it's a player. You can find pretty much all of this code with the moggles hat alone. Quote local SHOOTVISION_COLOURCUBES = { day = "images/colour_cubes/shooting_goggles_cc.tex", dusk = "images/colour_cubes/shooting_goggles_cc.tex", night = "images/colour_cubes/shooting_goggles_cc.tex", full_moon = "images/colour_cubes/purple_moon_cc", } local function SetShootVision(inst, enable) if enable then --inst.components.playervision:ForceNightVision(true) inst.components.playervision:SetCustomCCTable(SHOOTVISION_COLOURCUBES) else --inst.components.playervision:ForceNightVision(false) inst.components.playervision:SetCustomCCTable(nil) end end local function onequip(inst, owner) SetShootVision(owner, true) goggletalk(inst) owner.AnimState:OverrideSymbol("swap_hat", "hat_gogglesshoot", "swap_hat") owner.AnimState:Show("HAT") --if TheWorld and TheWorld.components.colourcube then --TheWorld.components.colourcube:SetOverrideColourCube("images/colour_cubes/shooting_goggles_cc.tex", .25) --end if owner:HasTag("wagstaff_inventor") then inst.components.weapon:CanRangedAttack(function() return true end) --inst.components.weapon:SetProjectile("fryfocals_charge") else --inst.components.weapon:SetProjectile() inst.components.weapon:CanRangedAttack(function() return false end) end end local function onunequip(inst, owner) SetShootVision(owner, false) owner.AnimState:ClearOverrideSymbol("swap_hat") owner.AnimState:Hide("HAT") --if TheWorld and TheWorld.components.colourcube then --TheWorld.components.colourcubemanager:SetOverrideColourCube(nil, .5) --end end I have this code but whenever I equip said item I freeze and crash instantly. Quote [00:01:42]: Assert failure 'dest != INVALID_RESOURCE_HANDLE' at ..\source\game\components\PostProcessorComponent.cpp(31): Trace follows... This is what I find in the client_log.txt, what does it mean? Link to comment https://forums.kleientertainment.com/forums/topic/105476-colour-cubes-for-hats/#findComment-1186553 Share on other sites More sharing options...
Ultroman Posted April 27, 2019 Share Posted April 27, 2019 It would be nice with the whole stacktrace. Link to comment https://forums.kleientertainment.com/forums/topic/105476-colour-cubes-for-hats/#findComment-1186560 Share on other sites More sharing options...
Hornete Posted April 27, 2019 Author Share Posted April 27, 2019 10 minutes ago, Ultroman said: It would be nice with the whole stacktrace. Sorry But I feel like that's what the issue was rooted in, here you go. client_log.txt Link to comment https://forums.kleientertainment.com/forums/topic/105476-colour-cubes-for-hats/#findComment-1186571 Share on other sites More sharing options...
Ultroman Posted April 27, 2019 Share Posted April 27, 2019 I meant that "Trace follows..." it said, but apparently the trace didn't follow xD That's where it broke. What I wanted to know was the stacktrace. Which function was fired tracing all the way to the call that caused the crash. But apparently, we can't have nice things. I don't know enough about the engine to solve that one. Link to comment https://forums.kleientertainment.com/forums/topic/105476-colour-cubes-for-hats/#findComment-1186581 Share on other sites More sharing options...
CarlZalph Posted April 28, 2019 Share Posted April 28, 2019 2 hours ago, Ultroman said: That's where it broke. What I wanted to know was the stacktrace. Which function was fired tracing all the way to the call that caused the crash. But apparently, we can't have nice things. I don't know enough about the engine to solve that one. I think this is caused from the mod not having the image loaded into its assets and the game trying to use said asset as if it were loaded already. @Omaremad74 I see you have "images/colour_cubes/purple_moon_cc" in there without the ".tex" at the end. Perhaps this is the culprit, as every other colourcube in the playervision component also has the ".tex" suffix for all of its images. Link to comment https://forums.kleientertainment.com/forums/topic/105476-colour-cubes-for-hats/#findComment-1186610 Share on other sites More sharing options...
Hornete Posted April 28, 2019 Author Share Posted April 28, 2019 Just now, CarlZalph said: I think this is caused from the mod not having the image loaded into its assets and the game trying to use said asset as if it were loaded already. @Omaremad74 I see you have "images/colour_cubes/purple_moon_cc" in there without the ".tex" at the end. Perhaps this is the culprit, as every other colourcube in the playervision component also has the ".tex" suffix for all of its images. I tried it but it's still the same error. Link to comment https://forums.kleientertainment.com/forums/topic/105476-colour-cubes-for-hats/#findComment-1186612 Share on other sites More sharing options...
CarlZalph Posted April 28, 2019 Share Posted April 28, 2019 2 minutes ago, Omaremad74 said: I tried it but it's still the same error. Well, to limit to see whether or not it's the custom colourcube images not being loaded properly, could you try re-using some base game colourcube paths? local SHOOTVISION_COLOURCUBES = { day = "images/colour_cubes/mole_vision_off_cc.tex", dusk = "images/colour_cubes/mole_vision_on_cc.tex", night = "images/colour_cubes/mole_vision_on_cc.tex", full_moon = "images/colour_cubes/mole_vision_off_cc.tex", } Link to comment https://forums.kleientertainment.com/forums/topic/105476-colour-cubes-for-hats/#findComment-1186613 Share on other sites More sharing options...
Hornete Posted April 28, 2019 Author Share Posted April 28, 2019 (edited) Just now, CarlZalph said: Well, to limit to see whether or not it's the custom colourcube images not being loaded properly, could you try re-using some base game colourcube paths? local SHOOTVISION_COLOURCUBES = { day = "images/colour_cubes/mole_vision_off_cc.tex", dusk = "images/colour_cubes/mole_vision_on_cc.tex", night = "images/colour_cubes/mole_vision_on_cc.tex", full_moon = "images/colour_cubes/mole_vision_off_cc.tex", } Hmm so it's something with the custom colour cubes... I will see what I can do to fix the colour cubes. 1 minute ago, CarlZalph said: [snip[ This is the code used in DS for it Quote local function shoot_onequip(inst, owner) onequip(inst, owner) if GetWorld() and GetWorld().components.colourcubemanager then GetWorld().components.colourcubemanager:SetOverrideColourCube("images/colour_cubes/shooting_goggles_cc.tex", .25) end if owner:HasTag("wagstaff_inventor") then inst.components.weapon:SetCanAttack(function() return true end) --inst.components.weapon:SetProjectile("fryfocals_charge") else --inst.components.weapon:SetProjectile() inst.components.weapon:SetCanAttack(function() return false end) end end But ofc colourcubemanager doesn't exist and theres no function called SetOverrideColourCube in the colourcube component. Although Now im wondering is there a function that does almost this Or Do I have to do something completely different? Edited April 28, 2019 by Omaremad74 Link to comment https://forums.kleientertainment.com/forums/topic/105476-colour-cubes-for-hats/#findComment-1186615 Share on other sites More sharing options...
CarlZalph Posted April 28, 2019 Share Posted April 28, 2019 (edited) 16 minutes ago, Omaremad74 said: But ofc colourcubemanager doesn't exist and theres no function called SetOverrideColourCube in the colourcube component. Although Now im wondering is there a function that does almost this Or Do I have to do something completely different? Ultimately the functions go to using: PostProcessor:SetColourCubeData After doing a small test I'm thinking the colourcube images are only loaded from the game's core directory rather than from mods to have the PostProcessor able to use them. The SetOverrideColourCube is just a workaround Klei used to force a specific colourcube that doesn't change by normal game behaviour like the time of day and such. You can simulate it by hooking this PostProcessor function and then having it return your static if the goggles are on or to use the default if they are not. For an example on how to do something like this, see (hook getmetatable(PostProcessor).__index.SetColourCubeData): Good luck to you with your port here, I'm going to get some rest. Edited April 28, 2019 by CarlZalph Link to comment https://forums.kleientertainment.com/forums/topic/105476-colour-cubes-for-hats/#findComment-1186620 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now