Jump to content

Would like some help with a script


KingFeraligatr

Recommended Posts

I have written a script to constantly reset an actor's Essential status to "true" no matter what. I wrote it because I know people are crafty and I'm a bit paranoid about people setting the Essential status of someone I've deemed permanently Essential to "false". Now the script works well as intended, but I did it sort of sloppy. The "reset essential" part of the script is stuck in an unbreakable while loop (intentional for now) and it makes the script processed constantly. This in turn cause quite a bit of script lag. Here's the source:

Scriptname z_reset_essential extends Actor
{constantly makes an actor essential}

;can't say I like how this script works right now. It hogs other scripts' processing and slows down script proccesing in general. I'd like some help with making
;this script better. Tell me if you know a better way to make this idea work.
;actor SelfRef
int looping = 1

Event OnInit() ;continuous checking start
RegisterForSingleUpdate (1.0)
EndEvent

Event OnUpdate()
ActorBase myself = GetActorBase () as ActorBase
looping = 1
while( looping != 0 || looping == 0 );this creates the endless loop. this unbreakable while loop is intentional until I can find a better way to do this
looping = 1
if( myself.IsEssential () == false );here's the the essential check
myself.SetEssential (true)
endif
endwhile
RegisterForSingleUpdate (1.0)
EndEvent

----------------
I'd like some help optimizing the script so it doesn't hog up script processing while still achieving the effect of making an actor constantly Essential not matter what the circumstance with the script being unable to be broken. Anything you can contribute would be nice. Thank you.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...