• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

random function lua, possible?

gubbo123

New Member
Joined
Aug 15, 2017
Messages
151
Solutions
1
Reaction score
3
is possible do a random function in lua script?

LUA:
make a script read this part

if not creature:isPlayer() then
doTargetCombatHealth(0, creature, COMBAT_PHYSICALDAMAGE, 0, 0)
position:sendMagicEffect(CONST_ME_BLOCKHIT)

or this part  50/50 % chance

if not creature:isPlayer() then
doTargetCombatHealth(0, creature, COMBAT_PHYSICALDAMAGE, -1, -15)
position:sendMagicEffect(CONST_ME_POFF)

or exist other way to do it? i need that script check if damage 0 do position:sendMagicEffect(CONST_ME_BLOCKHIT) if not is damage 0, execute this

if not creature:isPlayer() then
doTargetCombatHealth(0, creature, COMBAT_PHYSICALDAMAGE, -1, -15)
position:sendMagicEffect(CONST_ME_POFF)
 
Solution
You don't need to be using doTargetCombatHealth for 0 damage, it's going to do nothing.
This is an example of a way to mimic 50/50 chance between executing 2 sets of statements:
LUA:
if math.random(2) == 1 then
    -- some code
else
    -- other code
end
You don't need to be using doTargetCombatHealth for 0 damage, it's going to do nothing.
This is an example of a way to mimic 50/50 chance between executing 2 sets of statements:
LUA:
if math.random(2) == 1 then
    -- some code
else
    -- other code
end
 
Solution
Back
Top