Page 1 of 1

Script runs twice

Posted: Wed Jul 22, 2015 6:26 am
by tabitaru
!

Re: Script runs twice

Posted: Wed Jul 22, 2015 6:58 am
by Desufire
Tab out your ifs and elseifs?

Code: Select all

 
function onGameHour()
local monk=GetMobAction(17682442);
local horror=GetMobAction(17682446);
local rough = math.random(1,50);
print("Random Number = "..rough);
print("Is Spawned Monk = "..monk);
print("Is Spawned Horror = "..horror);
         if(monk ==0) and (rough <=3) and (horror ==0) then
            SpawnMob(17682442);
         elseif (monk ==0) and (horror ==0) and (rough >=49) then
            SpawnMob(17682446);
         elseif (monk ~=0) and (horror ==0) and (rough >=49) then
            DespawnMob(17682442);
            SpawnMob(17682446);
         end
end;

Re: Script runs twice

Posted: Wed Jul 22, 2015 8:06 am
by tabitaru
!

Re: Script runs twice

Posted: Wed Jul 22, 2015 11:56 am
by TeoTwawki

Code: Select all

function onGameHour()
    local monk = GetMobAction(17682442);
    local horror = GetMobAction(17682446);
    local rough = math.random(1,50);
    print("Random Number = "..rough);
    print("Is Spawned Monk = "..monk);
    print("Is Spawned Horror = "..horror);
    if (monk == 0 and rough <=3 and horror == 0) then
        SpawnMob(17682442);
    elseif (monk == 0 and horror == 0 and rough >= 49) then
        SpawnMob(17682446);
    elseif (monk ~= 0 and horror == 0 and rough >= 49) then
        DespawnMob(17682442);
        SpawnMob(17682446);
    end
end;
Formatted properly*.
And I see no reason why this code would exec twice on the same game hour trigger.. /shrug

* While lua is not a whitespace sensitive language, its much more difficult on my eyes when ppl mess it up..

Re: Script runs twice

Posted: Thu Jul 23, 2015 3:54 am
by tabitaru
!