bucketmouse Posted May 5, 2015 Share Posted May 5, 2015 Hey all. Taking my first steps into making an Actual Mod that's not a simple tweak and I think I'm missing something super obvious, and it's infuriating. I'm trying to modify pigman behavior if they're wearing a miner's helmet: (this is in brains\pigbrain.lua) local function HasLightHat(inst) local thehat = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HEAD) return thehat and thehat.prefab == "minerhat" end So far so good. We return true if the pig is wearing a miner's helmet.Now when I'm trying to check whether it's on or not: local function GetLightHatState(inst) local thehat = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HEAD) return HasLightHat(inst)-- and thehat.components.machine:IsOn()end(obviously suboptimal) For some reason thehat doesn't seem to contain any components, even though the prefab script says that it should have 'fueled' and 'machine' at least. The game's stock scripts seem to reference components in this fashion. Am I missing a level of indirection here or is there something weird going on? Also, is there a simple way to dump a table's contents to the console? dumptable() seems to cause a crash. Link to comment https://forums.kleientertainment.com/forums/topic/53534-getting-information-about-an-equipped-item/ Share on other sites More sharing options...
DarkXero Posted May 5, 2015 Share Posted May 5, 2015 The minerhat does not have a machine component. It turns off when unequipped or after running out of fuel.Maybe you are thinking of the mininglantern? Check forthehat.components.fueled.consumingas it will be true when on, and false when off. Also, dumptable works like this,local t = { hello = {"world", "yes"}, "oat", kablam = 9}print(GLOBAL.dumptable(t))-- print(dumptable(t)) outside modmain.lua Link to comment https://forums.kleientertainment.com/forums/topic/53534-getting-information-about-an-equipped-item/#findComment-634650 Share on other sites More sharing options...
bucketmouse Posted May 6, 2015 Author Share Posted May 6, 2015 Yup, it was the mining lantern. I didn't realize all the hats were lumped together in one file. I knew it was something simple like that. Everything's working now, thanks! I had tried calling dumptable like that (on thehat.components) but it just hung DST. No idea what happened there. Link to comment https://forums.kleientertainment.com/forums/topic/53534-getting-information-about-an-equipped-item/#findComment-634901 Share on other sites More sharing options...
DarkXero Posted May 6, 2015 Share Posted May 6, 2015 If you checked the log, you would see.You are accessing ALL the info from inst.components and all its parameters. That thing is huuuuuuuuuge. You are better off with for k, v in pairs(inst.components) do print("Comp: ", k) end Link to comment https://forums.kleientertainment.com/forums/topic/53534-getting-information-about-an-equipped-item/#findComment-634960 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