Jump to content

Script Simplification


Spysteven

Recommended Posts

Hi all, now I've got a simple lockdown script for a custom vault mod I'm working and in the security area there is a terminal that activates and disables a lockdown. The script is as follows

 

Deactivate Lockdown

DoorAtrium.lock(false)

DoorEntrance.lock(false)

DoorReactor.lock(false)

DoorSecurity.lock(false)

 

 

Activate Lockdown

DoorAtrium.lock(true)

DoorEntrance.lock(true)

DoorReactor.lock(true)

DoorSecurity.lock(true)

 

DoorAtrium.setopen(false)

DoorEntrance.setopen(false)

DoorReactor.setopen(false)

DoorSecurity.setopen(false)

 

DoorAtrium.setlocklevel(253)

DoorEntrance.setlocklevel(253)

DoorReactor.setlocklevel(253)

DoorSecurity.setlocklevel(253)

 

Now whilst this script works I want to simplify it and make it easier to add more doors into a group and simply refer to a group. Now I've already tried xmarkers without success because I don't think they except lock values. I'm only a moderate scripter so if someone more experienced could assist it would be much appreciated.

 

Link to comment
Share on other sites

Likely the easiest way would be to use an array or a formlist, iterate through that, and call your functions on each item. Something like:

Function AreaLockdown(bool lockdown, Array DoorArray)

	int i = 0
	
	if (lockdown == none || DoorArray == none)
		return
	endif
	
	while (i < DoorArray.Length)
		Door thedoor = DoorArray[i]
		thedoor.Lock(lockdown)	
		if (lockdown == true)
			thedoor.SetOpen(false)
			thedoor.SetLockLevel(253)
		endif
		i += 1
	endWhile

endFunction
Link to comment
Share on other sites

Like the orange fox but use a FormList to hold your references rather than a property array.

 

Create a formlist and drag your objectreferences into it from the CellView window list then iterate:

FormList Property pMyDoorList Auto Const Mandatory

Function AreaLockdown(bool lockdown)

int iIndex = 0

while (iIndex < pMyDoorList.getSize())
  ObjectReference thedoor = pMyDoorList.GetAt(iIndex) as ObjectReference
  thedoor.Lock(lockdown)    
  if (lockdown == true)
    thedoor.SetOpen(false)
    thedoor.SetLockLevel(253)
  endif
  iIndex += 1
endWhile

EndFunction

ps Reason for suggesting formlists - far easier to maintain when there are things to add or remove through update scripts or just xEDIT. With properties your constantly having to unpack the ESP script object.

Edited by SKK50
Link to comment
Share on other sites

I've created the script as per your guidance and the terminal has accepted it I'm currently working on the papyrus fragments to call up the new function using: lockdowndoors.arealockdown(true) but its not reconising the created function. do I have to refer to the script first then the function?

Edited by Spysteven
Link to comment
Share on other sites

I've created the script as per your guidance and the terminal has accepted it I'm currently working on the papyrus fragments to call up the new function using: lockdowndoors.arealockdown(true) but its not reconising the created function. do I have to refer to the script first then the function?

It will be helpful if you post the entire script(s).

 

 

Orange?! I am red, thank you very much. :tongue:

Hmmm you may have identified a monitor calibration issue ...

 

If it helps the color I see is #C72026.
Link to comment
Share on other sites

 

If it helps the color I see is #C72026.

 

 

I'm an RGB guy and 199/32/38 in paint.net still looks orange on a 144Hz AOC gaming monitor ... but red on a 60Hz BenQ work monitor. Proving that cheap 144Hz panels are cheap for a reason. Wonder what color that green signal grenade smoke I made actually is ...

 

ps apologies OP we do these tangents on all the best threads.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...