foamyesque Posted April 7, 2017 Share Posted April 7, 2017 (edited) Okay, so, here's my problem: Given an arbitrary ObjectReference known to be a harvestable object (i.e. its base form type is Flora or SKSE's TreeObject), how can I find out what it is supposed to yield up when harvested? SKSE's GetIngredient(), which ought to do it according to the (very sparse) documentation out there, is currently failing me.The cause, according to the logs, appears to be a type mismatch, but I'm not understanding why. Log snips:[04/06/2017 - 07:25:13PM] DetectLoot: Harvestable is tree[04/06/2017 - 07:25:13PM] Error: Mismatched types assigning to variable named "::temp61"stack: [alias ActiveObject183 on quest SM_DetectLootActiveObjectsQuest (7E18C34F)].foamdetectlootalias.AssessFlora() - "foamDetectLootAlias.psc" Line 295 [alias ActiveObject183 on quest SM_DetectLootActiveObjectsQuest (7E18C34F)].foamdetectlootalias.Assess() - "foamDetectLootAlias.psc" Line 111 [alias ActiveObject183 on quest SM_DetectLootActiveObjectsQuest (7E18C34F)].foamdetectlootalias.OnUpdate() - "foamDetectLootAlias.psc" Line ?[04/06/2017 - 07:25:13PM] DetectLoot: No ingredient found [04/06/2017 - 07:25:24PM] DetectLoot: Harvestable is flora[04/06/2017 - 07:25:24PM] Error: Mismatched types assigning to variable named "::temp61"stack: [alias ActiveObject082 on quest SM_DetectLootActiveObjectsQuest (7E18C34F)].foamdetectlootalias.AssessFlora() - "foamDetectLootAlias.psc" Line 286 [alias ActiveObject082 on quest SM_DetectLootActiveObjectsQuest (7E18C34F)].foamdetectlootalias.Assess() - "foamDetectLootAlias.psc" Line 111 [alias ActiveObject082 on quest SM_DetectLootActiveObjectsQuest (7E18C34F)].foamdetectlootalias.OnUpdate() - "foamDetectLootAlias.psc" Line ?[04/06/2017 - 07:25:24PM] DetectLoot: No ingredient found Relevant code: if akRefObj == None Debug.Trace("DetectLoot: Null object passed to harvestable assessment") return -1 endif Form baseForm = akRefObj.GetBaseObject() if baseForm == none Debug.Trace("DetectLoot: No base form found for harvestable") return -1 endif Ingredient refIng = none if (baseForm as Flora) Flora floraForm = baseForm as Flora if floraForm != none Debug.Trace("DetectLoot: Harvestable is flora") refIng = floraForm.GetIngredient() else Debug.Trace("DetectLoot: Flora form is empty") return -1 endif elseif (baseForm as TreeObject) TreeObject treeForm = baseForm as TreeObject if treeForm != none Debug.Trace("DetectLoot: Harvestable is tree") refIng = treeForm.GetIngredient() else Debug.Trace("DetectLoot: Tree form is empty") return -1 endif else Debug.Trace("DetectLoot: Flora & tree casts failed") return -1 endif if refIng != none int wealth = AssessGenericItem(refIng) Debug.Trace("DetectLoot: " + akRefObj.GetDisplayName() + ": ingredient worth " + wealth) return wealth else Debug.Trace("DetectLoot: No ingredient found") return -1 endifThe specific code line that fails looks like the refIng assignment, but as far as I can tell all the types involved are explicitly (and successfully, since they drive the Tree/Flora debug) cast to match the ones for GetIngredient(): For Flora, taken from SKSE's Flora.psc: Ingredient Function GetIngredient() native For TreeObject, ditto: Ingredient Function GetIngredient() native Help? :sad: Edited April 7, 2017 by foamyesque Link to comment Share on other sites More sharing options...
foamyesque Posted April 7, 2017 Author Share Posted April 7, 2017 (edited) Ran a test with a simpler version, explicitly filled with a flora form (HangingRabbit01, specifically) to avoid any casting problems: Flora Property testFlora Auto Event OnBeginState() Ingredient testIngredient = testFlora.GetIngredient() if testIngredient != none Debug.Notification("Test ingredient found") else Debug.Notification("Test ingredient not found") endif EndEvent "Test ingredient not found" shows up, and the log gives me: [04/07/2017 - 11:27:16AM] Error: Mismatched types assigning to variable named "::temp1" stack: [sM_DetectLootActiveObjectsQuest (7E18C34F)].foamdetectlootactiveobjectsquest.onBeginState() - "foamDetectLootActiveObjectsQuest.psc" Line ? [sM_DetectLootActiveObjectsQuest (7E18C34F)].foamdetectlootactiveobjectsquest.GotoState() - "Form.psc" Line ? [sM_DetectLootActiveObjectsQuest (7E18C34F)].foamdetectlootactiveobjectsquest.OnInit() - "foamDetectLootActiveObjectsQuest.psc" Line 18 So either the function is busted or I'm missing something really obvious in how it's supposed to work, and given how reliable SKSE is I'm quite sure it's the latter. Anyone have any ideas? Edited April 7, 2017 by foamyesque Link to comment Share on other sites More sharing options...
PeterMartyr Posted April 7, 2017 Share Posted April 7, 2017 (edited) Hey dude I'm self taught so probable not the best to advise you, but get Flora.GetIngredient() return a Form Value so I just change it to this. Flora Property testFlora Auto Event OnBeginState() Form testIngredient = testFlora.GetIngredient() if(testIngredient as Ingredient) Debug.Notification("Test ingredient found " + testIngredient.getName()) else Debug.Notification("Test ingredient not found") endif EndEvent Edited April 7, 2017 by PeterMartyr Link to comment Share on other sites More sharing options...
foamyesque Posted April 7, 2017 Author Share Posted April 7, 2017 (edited) Hey dude I'm self taught so probable not the best to advise you, but get Flora.GetIngredient() return a Form Value so I just change it to this. Flora Property testFlora Auto Event OnBeginState() Form testIngredient = testFlora.GetIngredient() if(testIngredient as Ingredient) Debug.Notification("Test ingredient found " + testIngredient.getName()) else Debug.Notification("Test ingredient not found") endif EndEvent I've tried that, same result. Moreover, my Flora.psc and PapyrusFlora.h (and the CK wiki, but that's less trustworthy) claim it returns an Ingredient. Edited April 7, 2017 by foamyesque Link to comment Share on other sites More sharing options...
PeterMartyr Posted April 7, 2017 Share Posted April 7, 2017 (edited) Scriptname Flora extends Activator Hidden ; SKSE additions built 2015-05-24 00:46:48.937000 UTC SoundDescriptor Function GetHarvestSound() native Function SetHarvestSound(SoundDescriptor akSoundDescriptor) native Form Function GetIngredient() native Function SetIngredient(Form akIngredient) native mine said Form, it a mystery, anywho I tried, I got nothing else. Sorry Edited April 7, 2017 by PeterMartyr Link to comment Share on other sites More sharing options...
foamyesque Posted April 7, 2017 Author Share Posted April 7, 2017 (edited) Scriptname Flora extends Activator Hidden ; SKSE additions built 2015-05-24 00:46:48.937000 UTC SoundDescriptor Function GetHarvestSound() native Function SetHarvestSound(SoundDescriptor akSoundDescriptor) native Form Function GetIngredient() native Function SetIngredient(Form akIngredient) native mine said Form, it a mystery, anywho I tried, I got nothing else. Sorry That's actually interesting. I did try to update SKSE before I did this. SKSE's version and installer match with the doc, but checking my .pex files they're still dated 2015-05-23. Could be time-zones, though. Does your script actually work on your machine?EDIT: The source files I have are much more out of date though. Need to fix that... Edited April 7, 2017 by foamyesque Link to comment Share on other sites More sharing options...
PeterMartyr Posted April 7, 2017 Share Posted April 7, 2017 It compiles but I haven't test it for function Link to comment Share on other sites More sharing options...
PeterMartyr Posted April 7, 2017 Share Posted April 7, 2017 Starting game to Test it Link to comment Share on other sites More sharing options...
foamyesque Posted April 7, 2017 Author Share Posted April 7, 2017 Well, that's peculiar. SKSE's installer didn't fix things, but when I downloaded the full archive and extracted that, using Forms as the receiving type instead of Ingredient started working. It works now but good grief. :v Link to comment Share on other sites More sharing options...
PeterMartyr Posted April 7, 2017 Share Posted April 7, 2017 [04/08/2017 - 04:43:47AM] (TestStart========================================================================================= [04/08/2017 - 04:43:47AM] Test ingredient found Pheasant Breast [04/08/2017 - 04:43:47AM] (TestEnd========================================================================================= Flora HangingPheasant01 = game.GetForm(0x38B0D) as Flora Form testIngredient = HangingPheasant01.GetIngredient() if(testIngredient as Form) debug.Trace("(TestStart=========================================================================================") Debug.trace("Test ingredient found " + testIngredient.getName()) debug.Trace("(TestEnd=========================================================================================") else Debug.trace("Test ingredient not found") endif It works, I tweak the script Link to comment Share on other sites More sharing options...
Recommended Posts