So what are the advantages of an array?
You can...
- store values, where you don't know how many you'll need while writing the script. I.e. storing every weapon the player had equipped for whatever reason.
- use it to return more then one value with a user function
- use it as a way to pass a multi-argument to a User Function
- etc.
I am tracking damage done to the PC. The way I'm doing it is by tracking when base health is == to current health If current health drops, I do something. Is there a more efficient way to do that? Would an array used in this instance cut down on precessing?
Why not use a
OnHealthDamage-http://www.obse.silverlock.org/obse_command_doc.html#Events?
Would this be valid (trying to determine if the PC has a shield equipped -- any shield)?Using a string variable (there may be a better way, but I can't seem to find the function):
set string1 to sv_construct player.getequippedobject 13 if sv_length string1 > 1 do something
??
No. sv_Construct expects a format_string as argument, not a function returning a formID.
If you want to use the string-method it could work in a http://www.obse.silverlock.org/obse_command_doc.html#Compiler_Override-Block using one of these three lines:
let string := GetName ( GetEquippedObject 13 )let string := GetFormIDString ( GetEquippedObject 13 )let string := $GetEquippedObject 13 ;returns the FormID IIRC
Or use a Dummy-Ref, then you could use this without a compiler override.
Oh okay, my noobness got me there. Which version, mine or yours, is less CPU intensive? That's the one I'll use.
Not really sure about CPU intensitivity (if you don't use loops that shouldn't matter, btw.), but since both methods call GetEquippedObject and only one uses another function afterwards I'd guess the one with the ref-var is faster.
If you want to know if the shield is really used (and not only equipped; i.e. using a bow) I'd suggest using http://cs.elderscrolls.com/constwiki/index.php/IsShieldOut instead.
PS:
GetEquippedObject is not a Vanilla-Function.
Edit:
A little bit too slow, I guess.