dizietemblesssma Posted November 26, 2023 Share Posted November 26, 2023 In a function I have: Form[] outfits_array followed by lots of if statements like: ElseIf outfit_type == "default" outfits_array = myRefScript.default_outfit default_outfit_toggle[actor_index] = True at the end of the function I have dz_get_kit(NPC_ref_slot[actor_index],outfits_array,outfit_type) however this does not result in myRefScript.default_outfit (if outfit_type = "default") being edited by the dz_get_kit function, which I guess is because I only made the contents of outfits_array the same as myRefScript.default_outfit, but not making 'outfits_array' a way to pass myRefScript.default_outfit to dz_get_kit. Full function here: Spoiler Function dz_store_outfit_NPC(Int actor_index, String outfit_type) ReferenceAlias myRefAlias = refalias_array[actor_index] as ReferenceAlias dz_outfits_NPCrefalias_script myRefScript = myRefAlias As dz_outfits_NPCrefalias_script DEBUG_TRACE(NPC_ref_slot[actor_index]," dz_store_outfit called with actor index = "+actor_index+" and outfit_type "+outfit_type) DEBUG_TRACE(NPC_ref_slot[actor_index],"myRefScript is "+myRefScript) Form[] outfits_array If outfit_type == "combat" outfits_array = myRefScript.combat_outfit combat_outfit_toggle[actor_index] = True ElseIf outfit_type == "default" outfits_array = myRefScript.default_outfit default_outfit_toggle[actor_index] = True ElseIf outfit_type == "swim" outfits_array = myRefScript.swim_outfit swim_outfit_toggle[actor_index] = True ElseIf outfit_type == "sleep" outfits_array = myRefScript.sleep_outfit sleep_outfit_toggle[actor_index] = True ElseIf outfit_type == "sneak" outfits_array = myRefScript.sneak_outfit sneak_outfit_toggle[actor_index] = True ElseIf outfit_type == "city" outfits_array = myRefScript.city_outfit city_outfit_toggle[actor_index] = True ElseIf outfit_type == "playerhome" outfits_array = myRefScript.playerh_outfit player_house_outfit_toggle[actor_index] = True ElseIf outfit_type == "indoors" outfits_array = myRefScript.dwelling_outfit dwelling_outfit_toggle[actor_index] = True ElseIf outfit_type == "pleasant" outfits_array = myRefScript.pleasant_outfit pleasant_outfit_toggle[actor_index] = True ElseIf outfit_type == "rainy" outfits_array = myRefScript.rainy_outfit rainy_outfit_toggle[actor_index] = True ElseIf outfit_type == "cloudy" outfits_array = myRefScript.cloudy_outfit cloudy_outfit_toggle[actor_index] = True ElseIf outfit_type == "snowy" outfits_array = myRefScript.snowy_outfit snowy_outfit_toggle[actor_index] = True ElseIf outfit_type == "alchemy" outfits_array = myRefScript.alchemy_outfit alchemy_outfit_toggle[actor_index] = True ElseIf outfit_type == "smithing" outfits_array = myRefScript.smithing_outfit smithing_outfit_toggle[actor_index] = True ElseIf outfit_type == "enchanting" outfits_array = myRefScript.enchanting_outfit enchanting_outfit_toggle[actor_index] = True EndIf DEBUG_TRACE(NPC_ref_slot[actor_index]," calling dz_get_kit with outfit type "+outfit_type+" and outfits array "+outfits_array) DEBUG_TRACE(NPC_ref_slot[actor_index],"outfits_array is"+outfits_array) dz_get_kit(NPC_ref_slot[actor_index],outfits_array,outfit_type) Return EndFunction So what is the correct way to select the array I want using the If statements and then pass that array to another function? diziet Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 26, 2023 Share Posted November 26, 2023 Does everything else work? The only issue is that the array is not being set with the default outfit when the outfit type is not specified? If that is the case, add something like the following (adjust as needed): Else outfits_array = myRefScript.default default_outfit_toggle[actor_index] = True With the above, if the outfit_type is not a specified one it will be treated as default and assign the default outfit to the array. At least that is the theory, testing will be needed. Link to comment Share on other sites More sharing options...
dizietemblesssma Posted November 27, 2023 Author Share Posted November 27, 2023 I think I have misdirected my question:) The complete function exists to detemine which array to operate on, All the arrays are specified in the script attached to reference aliases, you will recognise that because you helped me with referencing them i.e ReferenceAlias myRefAlias = refalias_array[actor_index] as ReferenceAlias dz_outfits_NPCrefalias_script myRefScript = myRefAlias As dz_outfits_NPCrefalias_script I attempted to assign 'outfits_array' to whichever array in 'myRefScript' was selected. However operations on 'outfits_array' did not affect the array attached to myRefScript. Instead it appeared that I had created a new array 'outfits_array' with the same contents as the one attached to myRefScript. In the end I changed the function to read: Spoiler Function dz_store_outfit_NPC(Int actor_index, String outfit_type) ReferenceAlias myRefAlias = refalias_array[actor_index] as ReferenceAlias dz_outfits_NPCrefalias_script myRefScript = myRefAlias As dz_outfits_NPCrefalias_script DEBUG_TRACE(NPC_ref_slot[actor_index]," dz_store_outfit called with actor index = "+actor_index+" and outfit_type "+outfit_type) DEBUG_TRACE(NPC_ref_slot[actor_index]," dz_store_outfit_NPC: myRefScript is "+myRefScript) ;Form[] outfits_array If outfit_type == "combat" ;outfits_array = myRefScript.combat_outfit dz_get_kit(NPC_ref_slot[actor_index],myRefScript.combat_outfit,outfit_type) combat_outfit_toggle[actor_index] = True ElseIf outfit_type == "default" ;outfits_array = myRefScript.default_outfit dz_get_kit(NPC_ref_slot[actor_index],myRefScript.default_outfit,outfit_type) use_default_toggle[actor_index] = True ElseIf outfit_type == "swim" ;outfits_array = myRefScript.swim_outfit dz_get_kit(NPC_ref_slot[actor_index],myRefScript.swim_outfit,outfit_type) swim_outfit_toggle[actor_index] = True ElseIf outfit_type == "sleep" ;outfits_array = myRefScript.sleep_outfit dz_get_kit(NPC_ref_slot[actor_index],myRefScript.sleep_outfit,outfit_type) sleep_outfit_toggle[actor_index] = True ElseIf outfit_type == "sneak" ;outfits_array = myRefScript.sneak_outfit dz_get_kit(NPC_ref_slot[actor_index],myRefScript.sneak_outfit,outfit_type) sneak_outfit_toggle[actor_index] = True ElseIf outfit_type == "city" ;outfits_array = myRefScript.city_outfit dz_get_kit(NPC_ref_slot[actor_index],myRefScript.city_outfit,outfit_type) city_outfit_toggle[actor_index] = True ElseIf outfit_type == "playerhome" ;outfits_array = myRefScript.playerh_outfit dz_get_kit(NPC_ref_slot[actor_index],myRefScript.playerh_outfit,outfit_type) player_house_outfit_toggle[actor_index] = True ElseIf outfit_type == "indoors" ;outfits_array = myRefScript.dwelling_outfit dz_get_kit(NPC_ref_slot[actor_index],myRefScript.dwelling_outfit,outfit_type) dwelling_outfit_toggle[actor_index] = True ElseIf outfit_type == "pleasant" ;outfits_array = myRefScript.pleasant_outfit dz_get_kit(NPC_ref_slot[actor_index],myRefScript.pleasant_outfit,outfit_type) pleasant_outfit_toggle[actor_index] = True ElseIf outfit_type == "rainy" ;outfits_array = myRefScript.rainy_outfit dz_get_kit(NPC_ref_slot[actor_index],myRefScript.rainy_outfit,outfit_type) rainy_outfit_toggle[actor_index] = True ElseIf outfit_type == "cloudy" ;outfits_array = myRefScript.cloudy_outfit dz_get_kit(NPC_ref_slot[actor_index],myRefScript.cloudy_outfit,outfit_type) cloudy_outfit_toggle[actor_index] = True ElseIf outfit_type == "snowy" ;outfits_array = myRefScript.snowy_outfit dz_get_kit(NPC_ref_slot[actor_index],myRefScript.snowy_outfit,outfit_type) snowy_outfit_toggle[actor_index] = True ElseIf outfit_type == "alchemy" ;outfits_array = myRefScript.alchemy_outfit dz_get_kit(NPC_ref_slot[actor_index],myRefScript.alchemy_outfit,outfit_type) alchemy_outfit_toggle[actor_index] = True ElseIf outfit_type == "smithing" ;outfits_array = myRefScript.smithing_outfit dz_get_kit(NPC_ref_slot[actor_index],myRefScript.smithing_outfit,outfit_type) smithing_outfit_toggle[actor_index] = True ElseIf outfit_type == "enchanting" ;outfits_array = myRefScript.enchanting_outfit dz_get_kit(NPC_ref_slot[actor_index],myRefScript.enchanting_outfit,outfit_type) enchanting_outfit_toggle[actor_index] = True EndIf ;DEBUG_TRACE(NPC_ref_slot[actor_index]," calling dz_get_kit with outfit type "+outfit_type+" and outfits array "+outfits_array) ;DEBUG_TRACE(NPC_ref_slot[actor_index],"outfits_array is"+outfits_array) ;dz_get_kit(NPC_ref_slot[actor_index],outfits_array,outfit_type) Return EndFunction moving the operation on the array to the if statement, this of course, works:) diziet Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 27, 2023 Share Posted November 27, 2023 Glad you figured it out. Sorry I wasn't much help this time around. Link to comment Share on other sites More sharing options...
Recommended Posts