I'm sorry, I scoured the forums for the last twenty minutes (searching the word 'condition' gives quite a lot of solutions, believe it or not. =P), and was unable to find the answer to this. I may have overlooked it, or searched incorrectly, but... :/
Well, I've always been curious. I always thought skipping any extra function call would be good, so I would just have actions do the checks, however, doesn't that also make the code run more often, since the events are mostly generic? Would it be better to use conditions so it didn't bother reading the action all the time something happens?
I guess in easier terms, is it better to use Conditions, or skip them and just use an if() in the Actions?
EX:
Would it be better for me to put that first If as a condition?
Also, I can't exactly find the trigger I was playing with before, but I was-- if I wanted to have two separate conditions to be filled?
Or would it be better to nest the two parts of the condition like so?
Sorry for the terrible writing of this question, but I'm not very good at explaining things. If anyone off-hand would know the answer to this, would you mind sharing? =)
Thanks in advance!
Travis.
Well, I've always been curious. I always thought skipping any extra function call would be good, so I would just have actions do the checks, however, doesn't that also make the code run more often, since the events are mostly generic? Would it be better to use conditions so it didn't bother reading the action all the time something happens?
I guess in easier terms, is it better to use Conditions, or skip them and just use an if() in the Actions?
EX:
JASS:
function Trig_Selling_Actions takes nothing returns nothing
local item checkItem = GetManipulatedItem()
local integer x = 0
local unit character = GetTriggerUnit()
if (GetItemName(checkItem) == "Tournament Registration Forms") then
loop
exitwhen x == 5
if( GetItemName(UnitItemInSlot(character, x)) == "Tournament Registration Forms") then
call UnitDropItemTarget(character, checkItem, gg_unit_n00L_0150)
endif
set x = x+1
endloop
endif
endfunction
Would it be better for me to put that first If as a condition?
Also, I can't exactly find the trigger I was playing with before, but I was-- if I wanted to have two separate conditions to be filled?
JASS:
function cond1 takes nothing returns boolean
if a == b then
return true
else
return false
endif
endfunction
function cond2 takes nothing returns boolean
if a != c then
return true
else
return false
endif
endfunction
function condcheck takes nothing returns boolean
if And(cond1,cond2) == true then
return true
else
return false
endif
endfunction
function InitTrig takes nothing returns nothing
call TriggerAddCondition(Trig, condcheck true)
endfunction
Or would it be better to nest the two parts of the condition like so?
JASS:
function cond1 takes nothing returns boolean
if a == b then
if a != c then
return true
endif
else
return false
endif
endfunction
function InitTrig takes nothing returns nothing
call TriggerAddCondition(Trig, condcheck true)
endfunction
Sorry for the terrible writing of this question, but I'm not very good at explaining things. If anyone off-hand would know the answer to this, would you mind sharing? =)
Thanks in advance!
Travis.