csbx Posted August 23 Share Posted August 23 Because when I started developing the mod ( Wayfinder ) I was relatively inexperienced, I worked at it piecemeal without ever hashing out whether the structure I was adopting was going to even be feasible. Now I'm in a position where the mod functions perfectly normally--but when I add an additional (formlist) property to its main script, it breaks the functionality. Rather than try to articulate how the mod functions, I was hoping someone could just take a look at its broad strokes to see what might be going on. It's primarily csbmagellanquest04locations quest that is involved here and that I think is the problem. All I have done since the last posted version is add the DLC as masters and attempt to add to that script a formlist property for a formlist containing Solstheim cave map markers. Upon doing this, the skse setname trick to add text entries to the book suddenly stops working. I verify with debugs that all is actually functioning normally, it's just that the text never shows up in the book. Replacing the script with the previous version doesn't return functionality--only replacing the esp, which presumably is storing the property information. I know it's a big ask, but I'm desperate ! Link to comment Share on other sites More sharing options...
PeterMartyr Posted August 24 Share Posted August 24 I don't get it, are you saying your code does not scale, that all part of learning curve, writing code that not hardcoded that scales at smell of oily rag, no self taught coder can write scalable code.. this is an opportunity to become a better coder let me download your mod and give you an example of scalability, but the odds are you will not like it or maybe understand it.. your code that I adapted Spoiler ScriptName Example_OLD Extends Quest ReferenceAlias[] property mapmarkerAlias auto Formlist Property csbmagmarkerstowns auto ;index 0 Formlist Property csbmagmarkersInns auto ; 1 Formlist Property csbmagmarkersNordR auto ; 2 Formlist Property csbmagmarkersDwem auto ; 3 ======= Formlists full of MapMarker ObjectReferences sorted by location type ======== Formlist Property csbmagmarkersForts auto ; 4 Formlist Property csbmagmarkersNordT auto ; 5 Formlist Property csbmagmarkersCaves auto ; 6 Formlist Property csbmagmarkersBCamps auto ; 7 Formlist Property csbmagMarkersGiantC auto ; 8 Formlist Property csbmagMarkersDLairs auto ; 9 Formlist Property csbmagMarkersMines auto ; 10 Formlist Property csbmagMarkersWTowers auto ; 11 Formlist Property csbmagMarkersGroves auto ; 12 ======= Groves include 'clearing' type locations Formlist Property csbmagMarkersStrongholds auto ; 13 Formlist Property csbmagMarkersAdHoc auto ; 20 Int Property FoundLocationType auto Int QuestIndex Int FoundLocationIndex Bool foundalready = false GlobalVariable Property csbMagMapChosen auto ;conditional Function FindTheAliasMarkerMatch(int QI) ;======= QI is the quest index that determines which vanilla quest we're pulling info from and then determining which TEXT we want to add to the book ======== QuestIndex = QI FoundLocationType = 99 Foundalready = False ObjectReference RadQuestMapMarker = mapmarkerAlias[QuestIndex].getreference() As ObjectReference CheckFormlist (csbmagmarkersNordR, RadQuestMapMarker, 2) CheckFormlist (csbmagmarkersDwem, RadQuestMapMarker, 3) CheckFormlist (csbmagmarkersForts, RadQuestMapMarker, 4) CheckFormlist (csbmagmarkersNordT, RadQuestMapMarker, 5) CheckFormlist (csbmagmarkersBCamps, RadQuestMapMarker, 7) CheckFormlist (csbmagMarkersTowns, RadQuestMapMarker, 0) CheckFormlist (csbmagMarkersGiantC, RadQuestMapMarker, 8) CheckFormlist (csbmagMarkersDLairs, RadQuestMapMarker, 9) ;======= Check each of my formlists full of map markers, organized by location type, to find a match with the alias map marker for the vanilla quest CheckFormlist (csbmagMarkersMines, RadQuestMapMarker, 10) ;======= Thanks to nexus/xkkmEl for showing me how to streamline the code related to these checks CheckFormlist (csbmagMarkersWTowers, RadQuestMapMarker, 11) CheckFormlist (csbmagMarkersGroves, RadQuestMapMarker, 12) CheckFormlist (csbmagMarkersStrongholds, RadQuestMapMarker, 13) CheckFormlist (csbmagMarkersAdHoc, RadQuestMapMarker, 20) CheckFormlist (csbmagmarkersCaves, RadQuestMapMarker, 6) Formlist csbmagmarkersERDP = Game.GetFormFromFile(0x800, "Wayfinder - ERDP Patch.esp") as formlist Formlist csbmagmarkersHam = Game.GetFormFromFile(0x800, "Wayfinder - Hammet01 Patch.esp") as formlist If Game.GetFormFromFile(0x800, "Wayfinder - ERDP Patch.esp") != None ;============= Only load these if ERDP is loaded CheckFormlist (csbmagmarkersERDP, RadQuestMapMarker, 30) ;debug.notification("it found that i have the erdp patch and found the formlist") Endif ;debug.notification("we've seen this part of script with no finding that form..") If Game.GetFormFromFile(0x800, "Wayfinder - Hammet01 Patch.esp") != None CheckFormlist (csbmagmarkersHam, RadQuestMapMarker, 35) Endif If !foundalready mapmarkerAlias[QuestIndex].getreference().AddToMap() ;======= If vanilla quest map marker alias not found in my lists, add marker to map as an over-ride so player isn't left without means of finding location ;======= E.g. this will happen if a location mod a player installs adds locations to radiant quests that my mod obviously doesn't know about Endif If (QI >= 0 && QI <= 100) && foundalready ;======= Only pass to next function if we've actually found the map marker csbmagmapchosen.setvalue(FoundLocationIndex as int) ;; Start PeterMartyr comment ;commented out just for convenience I dont want to copy the whole script:) ;FindDirectionsNPC(FoundLocationType, True, 0) ;; End PeterMartyr comment Endif EndFunction ;============================================================ ; Function below does the dirty work = actual checking through the formlists ;============================================================ Function CheckFormlist (Formlist FormlistPick, ObjectReference RadQuestMapMarker, int LocationType) if !foundalready int i = FormlistPick.find(RadQuestMapMarker) If i >= 0 FoundLocationIndex = i FoundLocationType = locationType foundalready = true EndIf Endif endfunction now this the above code made scalable, so it only require changes to properties values done correctly to scale up, the code stays the same, trust me you will not like it :))) Spoiler ScriptName Scalable Extends Quest conditional GlobalVariable Property csbMagMapChosen auto conditional Int Property QUEST_ID_UNDERFLOW_ERROR = 0 AutoReadOnly Int Property QUEST_ID_OVERFLOW_ERROR = 100 AutoReadOnly Int Property NOT_FOUND = -1 AutoReadOnly Int Property GAME_SAVE = 255 AutoReadOnly Int Property ZERO_INDEX = 0 AutoReadOnly Int Property TOWN = 0 AutoReadOnly Int Property INNS = 1 AutoReadOnly Int Property NORDIC_RUINS = 2 AutoReadOnly {if it was me I would not abbreviate NORDIC_RUINS just saying } Int Property DWEMER = 3 AutoReadOnly Int Property FORTS = 4 AutoReadOnly Int Property NORD_TOWERS = 5 AutoReadOnly Int Property CAVES = 6 AutoReadOnly Int Property BANDIT_CAMPS = 7 AutoReadOnly Int Property GAINT_CAMPS = 8 AutoReadOnly Int Property Dragon_LAIRS = 9 AutoReadOnly Int Property MINES = 10 AutoReadOnly Int Property W_TOWERS = 11 AutoReadOnly {not sure what "W" is: Western?} Int Property GROVES = 12 AutoReadOnly Int Property STRONG_HOLDS = 13 AutoReadOnly Int Property RADIANT_QUESTS = 14 AutoReadOnly {I changed 20 to 14 cos it is index value} Int Property ERDP_PATCH = 30 AutoReadOnly Int Property HAMMET01_PATCH = 35 AutoReadOnly ReferenceAlias[] property mapmarkerAlias auto Int Property FoundLocationType auto {value are has stated above} ; csbmagmarkerstowns ; index 0 ; csbmagmarkersInns ; 1 ; csbmagmarkersNordR ; 2 ; csbmagmarkersDwem ; 3 ; csbmagmarkersForts ; 4 ; csbmagmarkersNordT ; 5 ; csbmagmarkersCaves ; 6 ; csbmagmarkersBCamps ; 7 ; csbmagMarkersGiantC ; 8 ; csbmagMarkersDLairs ; 9 ; csbmagMarkersMines ; 10 ; csbmagMarkersWTowers ; 11 ; csbmagMarkersGroves ; 12 ; csbmagMarkersStrongholds ; 13 ; csbmagMarkersAdHoc ; 14 ; Note keep this for reference FormList[] Property myFormlists Auto {an array of above fill in the KIT} int Function SearchLists(ObjectReference MapMarker) Int index = ZERO_INDEX Int result While index < myFormlists.Length result = myFormlists[index].find(MapMarker) If result != NOT_FOUND FoundLocationType = index return result EndIf index+=1 EndWhile return NOT_FOUND EndFunction int Function SearchList(formlist thisList, ObjectReference MapMarker, int LocationType) Int result = thisList.find(MapMarker) If result != NOT_FOUND FoundLocationType = LocationType return result EndIf return NOT_FOUND EndFunction Function FindTheAliasMarkerMatch(int QuestID) If QuestID < QUEST_ID_UNDERFLOW_ERROR || QuestID > QUEST_ID_OVERFLOW_ERROR Return ; either underflow or overflow error let not run this for no reason whatsoever EndIf ObjectReference RadQuestMapMarker = mapmarkerAlias[QuestID].getreference() As ObjectReference int found = SearchLists(RadQuestMapMarker) If (found == NOT_FOUND && Game.GetModByName("ERDP.esp") != GAME_SAVE && Game.GetModByName("Wayfinder - ERDP Patch.esp") != GAME_SAVE) found = SearchList(Game.GetFormFromFile(0x800, "Wayfinder - ERDP Patch.esp") as formlist, RadQuestMapMarker, ERDP_PATCH) EndIf If (found == NOT_FOUND && Game.GetModByName(" Hammet01.esp") != GAME_SAVE && Game.GetModByName("Wayfinder - Hammet01 Patch.esp") != GAME_SAVE) found = SearchList(Game.GetFormFromFile(0x800, "Wayfinder - Hammet01 Patch.esp") as formlist, RadQuestMapMarker, HAMMET01_PATCH) EndIf If found != NOT_FOUND csbmagmapchosen.setvalue(found) FindDirectionsNPC(FoundLocationType, True, 0) Else FoundLocationType = NOT_FOUND csbmagmapchosen.setvalue(NOT_FOUND) mapmarkerAlias[QuestID].getreference().AddToMap() Endif EndFunction BTW adding DG AND DB is insert into the array at the end and patch index values increase accordingly. Link to comment Share on other sites More sharing options...
PeterMartyr Posted August 24 Share Posted August 24 yes the patches should have been a function too, but I got lazy and it just an example Link to comment Share on other sites More sharing options...
HarrisonWalker Posted October 18 Share Posted October 18 I faced the same, but now everything is good. Thank you. Link to comment Share on other sites More sharing options...
Recommended Posts