FiftyTifty Posted September 11, 2019 Share Posted September 11, 2019 I'm attempting to make an NVSE script that, when the player presses a hotkey, all items present in a cell are put into an array and then iterated through, replacing each item with a static version. But I hit a wee snag with GetRefs(), as it couldn't be called via an NVSE script through CMD_GetRefs_Execute(), as far as I could tell. So I made a stripped down copy-paste, which is tailored to my specific usage: ArrayID GetItemsInCell(COMMAND_ARGS) { // returns an array of references formID in the specified cell(s) ArrayID arrayItemsFound = g_ArrayMap.Create(kDataType_Numeric, true, scriptObj->GetModIndex()); UInt8 formType = 0; UInt8 cellDepth = 0; bool includeTakenRefs = false; double uGrid = 0; double arrIndex = 0.0; cellDepth = 0; CellScanInfo info(cellDepth, formType, bIncludeTakenRefs, cellPlayerIsIn); info.FirstCell(); while (info.curCell) { const TESObjectCELL::RefList& refList = info.curCell->objectList; for (TESObjectCELL::RefList::Iterator iter = refList.Begin(); !iter.End(); ++iter) { TESObjectREFR* pRefr = iter.Get(); if (pRefr) switch (formType) { case 201: if (refrIsItem(pRefr)) { g_ArrayMap.SetElementFormID(arrayItemsInCellFormIDs, arrIndex, pRefr->refID); arrIndex += 1.0; } break; } } info.NextCell(); } return arrayItemsFound; } The problem is that I couldn't really discern what COMMAND_ARGS does. It has something to do with what is passed from a GECK script to the function itself, but the arguments aren't 1:1, so I'm at a loss. Moreover, it's scriptObj->GetModIndex(); that throws an error when I remove COMMAND_ARGS. I can tell that scriptObj is a child of COMMAND_ARGS, but that's about it. Since I'm going to be calling this function inside a plugin, with no functions being called via a GECK script, nothing will be passed to COMMAND_ARGS. How do I rectify this? Link to comment Share on other sites More sharing options...
c6dev Posted September 11, 2019 Share Posted September 11, 2019 (edited) COMMAND_ARGS is used for script function definitions, it's not usable anywhere else. scriptObj is an object of "Script" class that is passed when a script command is called, so obviously you can't get a mod index from a script object when you don't have a script.Moreover, why would you use NVSE array vars when you aren't making a script function? You have the power of C++ to your advantage, no need for them. Edited September 11, 2019 by TrueCourierSix Link to comment Share on other sites More sharing options...
FiftyTifty Posted September 11, 2019 Author Share Posted September 11, 2019 COMMAND_ARGS is used for script function definitions, it's not usable anywhere else. scriptObj is an object of "Script" class that is passed when a script command is called, so obviously you can't get a mod index from a script object when you don't have a script.Moreover, why would you use NVSE array vars when you aren't making a script function? You have the power of C++ to your advantage, no need for them. It's what the original GetRefs function had, so I'm stripping out the unnecessary stuff. There's no documentation, so I'm not sure on what can be removed, what needs to be added, and what is a requirement for interfacing with NVSE. So COMMAND_ARGS is unnecessary. Good, good. I'll continue to poke around then. Link to comment Share on other sites More sharing options...
Recommended Posts