• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Scripting] When to put "( )"

dabaflow

New Member
Joined
May 22, 2008
Messages
277
Reaction score
1
PHP:
function skinMonster(cid,item,skin)
	local random = math.random(1,8)
	if(random == 1) then
		doPlayerAddItem(cid,skin,1)
		doSendMagicEffect(getThingPos(item.uid), CONST_ME_MAGIC_RED)
	else
		doSendMagicEffect(getThingPos(item.uid), CONST_ME_POFF)
	end
	doTransformItem(item.uid,item.itemid+1)
end

I want to know how to know when to put the ( and ) 's.

Like in the code above "if(random == 1) then.

Why do you have to write "(random == 1)?

I think a "gramma" tutorial for LUA would be nice xD

EDIT; And please try to not answer in a very advanced English(CIP language).
 
Parantheses are basically just added to help you organise your code.

Formula Example:
( ( $level * 3 ) / 10 ) - 40

IF Example:
if isPlayer(cid) == TRUE and ( getPlayerLevel(cid) == 100 or getPlayerLevel(cid) == 200 ) then
 
In most cases? No not really. Although it is required when using certain functions (to enter parameters etc).
 
Back
Top