Difference between revisions of "Talk:If"

319 bytes added ,  19:54, 20 November 2008
Request for else/elseif
imported>Haama
(→‎Nested IF's: Logically, yes)
imported>Relax and Play
(Request for else/elseif)
Line 113: Line 113:
:#Speed - It's faster to run two checks on the same line (''If... && If...'') than to run two '''if''' checks, but only when you expect both conditions to be true most of the time. If either one is rare, it'd be faster to use two '''if''' checks. Scripts that check for input are a great example of this - the Keychain mod waits for you to press Activate, makes sure you have the Keychain, and then moves the keys over. I could combine the checks into ''if (GetControlPress 5) && if (player.GetItemCount Keychain)'', but because Activate is pressed maybe once every 1000 script runs, it'd take less processing to run ''if (GetControlPress 5)'', have it return false, and skip the second, ''if (player.GetItemCount Keychain)'' check.
:#Speed - It's faster to run two checks on the same line (''If... && If...'') than to run two '''if''' checks, but only when you expect both conditions to be true most of the time. If either one is rare, it'd be faster to use two '''if''' checks. Scripts that check for input are a great example of this - the Keychain mod waits for you to press Activate, makes sure you have the Keychain, and then moves the keys over. I could combine the checks into ''if (GetControlPress 5) && if (player.GetItemCount Keychain)'', but because Activate is pressed maybe once every 1000 script runs, it'd take less processing to run ''if (GetControlPress 5)'', have it return false, and skip the second, ''if (player.GetItemCount Keychain)'' check.
:--[[User:Haama|Haama]] 00:20, 26 August 2008 (EDT)
:--[[User:Haama|Haama]] 00:20, 26 August 2008 (EDT)
==Else/elseif?==
These two commands are not covered here. While I would add a section for the two commands myself, scripting is my current weak point in Oblivion modding. If anyone would, add an entry explaining the functions of else and elseif. --[[User:Relax and Play|Relax and Play]] 19:54, 20 November 2008 (EST)