Im making a round system that will spawn a boss on rounds that are 1 less than 5, such as 4,9,14,19, etc.
this is what I have:
while true do
wait(0.5)
local round = 4
local g = round + 5 * math.floor(round / 5)
print("0 :",round,"[]",g)
if round == g then
print("1: ",round)
elseif round ~= g then
print("2: ",round)
end
end
as you can see this attempt didn’t go so well, perhaps someone could point me in the right direction?
You can try adding another variable called “bossRound” to keep track of it.
So then you just need to do like this
--Before starting the loop
local bossRound = 0
-- Inside the loop.
if bossRound == 0 and round == 4 then
bossRound = bossRound + 1
-- First boss round
elseif bossRound >= 1 and round == (4 + (5 * bossRound)) then
bossRound = bossRound + 1
-- Other boss rounds.
end
--Continue the loop.
and I wont need to keep adding to it for more rounds right?
also: as a side note, the rounds are expected to be endless, so it would have to keep adding up without adding more code for more rounds.
local Round = 1
while true do
wait(0.5)
local LastestBossRound = 0
local CurrentBossRound = math.floor((Round+1)/5) --// math.floor would convert numbers with decimals like 0.8 into 0, since every 5 rounds is the boss fight, then we would divide by 5, and because it's not 5, 10, 15, and it's 4, 9, 14, then we would increment one number. If the round is 4, then the number would be 1, if the round is 3 then the number would be 0
if LastestBossRound ~= CurrentBossRound then --// If the lastest boss round (0) is not the same as the current boss round.
LastestBossRound = CurrentBossRound --// Convert the lastest boss round into the current one.
print("Boss Time")
else
print("Pizza Time")
end
Round = Round + 1
end
local round = 0
while true do
wait(0.5)
round += 1
local isBossRound = ((round+1)%5 == 0)
if (isBossRound) then
local bossRound = math.floor((round+1)/5)
print("Boss round:", bossRound)
else
print("Normal round:", round)
end
end