Jump to content

scripting assistance


bioshards

Recommended Posts

Try this:

ref	rCont
ref	rItem

begin OnAdd

	set rCont to GetContainer
	set rItem to GetBaseObject

end

begin GameMode

	if rCont == 0
	elseif rCont.GetEquipped rItem == 0
	elseif rCont.GetHealthPercentage < 0.7
		set rCont to 0
		DropMe
	endif

end
GetSelf will not return a valid value when called by an inventory reference; GetEquipped expects a base object, and will otherwise break the script.
Only use NVSE notation (let X :=, instead of set X to) with expressions referencing array/string variables - it needlessly adds another level of processing, and is therefore slower.
Link to comment
Share on other sites

It's up to opinion, but personally I would suggest always using let rather than set except in obscure contexts when set works better. The difference in performance is negligible, and let allows much more powerful expressions with the added bonus that if it fails, it prints an error to the console naming the guilty script, rather than just silently boning it.

Link to comment
Share on other sites

  • 3 months later...
  • Recently Browsing   0 members

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