CODA example: Hide all trees
Revision as of 15:47, 19 August 2013 by imported>QQuix (Adjustments)
This example disables all trees in a 4x4 cell area just south of the Chorrol South Gate.
See comments in the script to revert the trees back to enabled.
Notes
- You may use the Export tool of the CSE to get cell FormIDs into a text editor or a spreadsheet (CS menu >> File >> Export >> Interior and Exterior Cell Data).
Code
CODA(DisableTrees) ;------------------------------------------ ; runcodascript DisableTrees ;------------------------------------------ var arCells ; Array of cell FormIDs var refCell var reff var bas var n begin ; Create an array with the FormIDs of the cells in the target area ;-------------------------------------------------------------------- ;=== Create the array with sufficient number of entries === arCells = ArrayCreate (30) ;=== Populate the array === ArrayInsert (arCells, GetFormByFormID (0x00000847), -1) ArrayInsert (arCells, GetFormByFormID (0x00000849), -1) ArrayInsert (arCells, GetFormByFormID (0x0000084D), -1) ArrayInsert (arCells, GetFormByFormID (0x0000091C), -1) ArrayInsert (arCells, GetFormByFormID (0x00000922), -1) ArrayInsert (arCells, GetFormByFormID (0x0000F328), -1) ArrayInsert (arCells, GetFormByFormID (0x0000F329), -1) ArrayInsert (arCells, GetFormByFormID (0x0000F32A), -1) ArrayInsert (arCells, GetFormByFormID (0x0000F347), -1) ArrayInsert (arCells, GetFormByFormID (0x0000F348), -1) ArrayInsert (arCells, GetFormByFormID (0x0000F349), -1) ArrayInsert (arCells, GetFormByFormID (0x0000F34A), -1) ArrayInsert (arCells, GetFormByFormID (0x0000F367), -1) ArrayInsert (arCells, GetFormByFormID (0x0000F368), -1) ArrayInsert (arCells, GetFormByFormID (0x0000F369), -1) ArrayInsert (arCells, GetFormByFormID (0x0000F36A), -1) ; Walk the cells ;------------------- forEach refCell <- arCells printc("Scanning "//GetEditorID(refCell)) ; Walk the references in the cell ;----------------------------------- forEach reff <- GetCellObjects(refCell) ; Check if the ref is valid (for some reason, sometimes it is zero) ;-------------------------------------------------------------------- if (reff > 0 ) ; Get the Base Object ;----------------------- bas = GetRefBaseForm (reff) ; Select the trees (Type 30 = Tree) ;------------------------------------- if(GetFormType(bas) == 30) ; Reorder the lines below to enable or disable the reference ;------------------------------------------------------------- SetRefDisabled (reff, 0) ;;ENABLE SetRefDisabled (reff, 1) ;;DISABLE n += 1 endif endif loop loop printc (". . Done . . "//FormatNumber("%g",n,0)//" trees toggled") end