chandelier Posted June 7 Posted June 7 (edited) the goal is to make gg toast like this, by using loop and condition. and toast with value at that specific phase phase 1 Symbol : =----- 10 phase 2 Symbol : ==--- 20 phase 3 Symbol : ===-- 30 phase 4 Symbol : ====- 40 phase 5 Symbol : ===== 50 if more than max phase length then os.exit() local initialPhase = {10, 20, 30, 40, 50} local initialSymbol1 = '=' local initialSymbol2 = '-' while true do --length = initialPhase.Max.Length; if phase = length then phase = initialPhase + 1 symbol1 = symbol1 + initialSymbol1 symbol2max = initialSymbol2 * length symbol2 = symbol2max - initialSymbol2 gg.toast('Symbol :'..symbol..symbol2..' !!', true) gg.toast('\n'..initialPhase, true) else os.exit() end end Edited June 7 by chandelier
1 CmP Posted June 7 Posted June 7 local function createPhaseDisplayer(phaseValues, progressSymbol, backgroundSymbol) local phasesCount = #phaseValues local currentPhase = 0 return function () currentPhase = currentPhase + 1 if currentPhase > phasesCount then os.exit() end local indicatorFirstPart = string.rep(progressSymbol, currentPhase) local indicatorSecondPart = string.rep(backgroundSymbol, phasesCount - currentPhase) local indicator = indicatorFirstPart .. indicatorSecondPart local phaseValue = phaseValues[currentPhase] local displayMessage = string.format("phase %d\nSymbol : %s\n%d", currentPhase, indicator, phaseValue) gg.toast(displayMessage, true) end end local phaseValues = {10, 20, 30, 40, 50} local symbol1 = "=" local symbol2 = "-" local displayPhase = createPhaseDisplayer(phaseValues, symbol1, symbol2) -- Testing all phases with one extra for i = 1, #phaseValues + 1 do displayPhase() end
1 MonkeySAN Posted June 10 Posted June 10 (edited) for i = 1, #phaseValues do SET_POSITION(table.unpack(phaseValues[i])) displayPhase() end Edited June 10 by MonkeySAN 1
0 chandelier Posted June 8 Author Posted June 8 awesome work, at first idk what it does, im fine as long as the goal is reached, well i tried it and already experiment on it. and will put the code here on my full script, thankyou so much my good man
0 chandelier Posted June 8 Author Posted June 8 oof after i implemented on some part of my script, theres some error about bad argument for key 'value' : string expected, got table (field'setValue') function SET_BUFF(BUFF) gg.sleep(6000) local saved_buff = gg.getListItems() local edited_buff = {} for i, v in ipairs(saved_buff) do if v.name == "BUFF" then v.value = BUFF v.freeze = true table.insert(edited_buff, v) end end if #edited_buff > 0 then gg.setValues(edited_buff) gg.addListItems(edited_buff) else gg.toast("NO MATCHING BUFF FOUND.") end end local function createPhaseDisplayer(phaseValues, buffInfo, progressSymbol, backgroundSymbol) local phasesCount = #phaseValues local currentPhase = 0 return function () currentPhase = currentPhase + 1 if currentPhase > phasesCount then os.exit() end local indicatorFirstPart = string.rep(progressSymbol, currentPhase) local indicatorSecondPart = string.rep(backgroundSymbol, phasesCount - currentPhase) local indicator = indicatorFirstPart .. indicatorSecondPart local phaseValue = phaseValues[currentPhase] local buffInfo = buffInfo local displayMessage = string.format("\n%s : %s", buffInfo, indicator) gg.toast(displayMessage, true) end end local phaseValues = {171, 172, 200} local buffInfo = "MISSION" local symbol1 = "=" local symbol2 = "-" local displayPhase = createPhaseDisplayer(phaseValues, buffInfo, symbol1, symbol2) for i = 1, #phaseValues + 1 do SET_BUFF(phaseValues) displayPhase() end the toast in displayPhase() works fine
0 MonkeySAN Posted June 8 Posted June 8 try this for i = 1, #phaseValues do SET_BUFF(phaseValues[i]) displayPhase() end 1
0 chandelier Posted June 9 Author Posted June 9 ahhh i dont know why it works just by deleting +1 on #phaseValues , and adding [i] on SET_BUFF(phaseValues()) well as long as it works im good and i found another problem when im trying to put them on function and call them back inside a function function BUFF_TRIGGER() local symbol1 = "=" local symbol2 = "-" local displayPhase = createPhaseDisplayer(phaseValues, buffInfo, symbol1, symbol2) for i = 1, #phaseValues do SET_BUFF(phaseValues[i]) displayPhase() end end function SET_BUFF(BUFF) gg.sleep(6000) local saved_buff = gg.getListItems() local edited_buff = {} for i, v in ipairs(saved_buff) do if v.name == "BUFF" then v.value = BUFF v.freeze = true table.insert(edited_buff, v) end end if #edited_buff > 0 then gg.setValues(edited_buff) gg.addListItems(edited_buff) else gg.toast("NO MATCHING BUFF FOUND.") end end local function createPhaseDisplayer(phaseValues, buffInfo, progressSymbol, backgroundSymbol) local phasesCount = #phaseValues local currentPhase = 0 return function () currentPhase = currentPhase + 1 if currentPhase > phasesCount then os.exit() end local indicatorFirstPart = string.rep(progressSymbol, currentPhase) local indicatorSecondPart = string.rep(backgroundSymbol, phasesCount - currentPhase) local indicator = indicatorFirstPart .. indicatorSecondPart local phaseValue = phaseValues[currentPhase] local buffInfo = buffInfo local displayMessage = string.format("\n%s : %s", buffInfo, indicator) gg.toast(displayMessage, true) end end function Main() local phaseValues = {171, 172, 200} local buffInfo = "MISSION" BUFF_TRIGGER() end Main()
0 MonkeySAN Posted June 9 Posted June 9 (edited) local phaseValues = {171, 172, 200} local buffInfo = "MISSION move this outside Main() and put it at very top of the script local function createPhaseDisplayer(phaseValues, buffInfo, progressSymbol, backgroundSymbol) ... then move this function below it before function BUFF_TRIGGER() Edited June 9 by MonkeySAN
0 chandelier Posted June 10 Author Posted June 10 (edited) hm maybe for now i will keep them outside function also in a case where i want to put another phase grouping like this : local phaseValues = {{171, 172, 200},{181, 182, 300},{191, 192, 400}} is it allowed to be written like that? after added that, so the full code will be this : function SET_POSITION(P1, P2, P3) local saved = gg.getListItems() local edited = {} for i, v in ipairs(saved) do if v.name == "P1" then v.value = P1 table.insert(edited, v) elseif v.name == "P2" then v.value = P2 table.insert(edited, v) elseif v.name == "P3" then v.value = P3 table.insert(edited, v) end end if #edited > 0 then gg.setValues(edited) gg.addListItems(edited) else gg.toast("NO MATCHING P1/P2/P3 FOUND.") end end local function createPhaseDisplayer(phaseValues, buffInfo, progressSymbol, backgroundSymbol) local phasesCount = #phaseValues local currentPhase = 0 return function () currentPhase = currentPhase + 1 if currentPhase > phasesCount then os.exit() end local indicatorFirstPart = string.rep(progressSymbol, currentPhase) local indicatorSecondPart = string.rep(backgroundSymbol, phasesCount - currentPhase) local indicator = indicatorFirstPart .. indicatorSecondPart local phaseValue = phaseValues[currentPhase] local buffInfo = buffInfo local displayMessage = string.format("\n%s : %s", buffInfo, indicator) gg.toast(displayMessage, true) end end local phaseValues = {{171, 172, 200},{181, 182, 300},{191, 192, 400}} local buffInfo = "MISSION" local symbol1 = "=" local symbol2 = "-" local displayPhase = createPhaseDisplayer(phaseValues, buffInfo, symbol1, symbol2) for i = 1, #phaseValues do SET_POSITION(phaseValues[i]) displayPhase() end Edited June 10 by chandelier
0 MonkeySAN Posted June 10 Posted June 10 for i = 1, #phaseValues do SET_POSITION(phaseValues[i][1], phaseValues[i][2], phaseValues[i][3]) displayPhase() end
0 chandelier Posted June 10 Author Posted June 10 ahh i see, it does work if i do that, thankyou.. a question from me, what if i have so many phase grouping that more than 3? do i need increment for it? so i dont have to write SET_POSITION(phaseValues[i][1], phaseValues[i][2], phaseValues[i][3].............................., phaseValues[i][1000])
0 chandelier Posted June 11 Author Posted June 11 ahh it does work, thankyou so much, i apreciate it, hope to see you again in my next question xD
Question
chandelier
the goal is to make gg toast like this, by using loop and condition. and toast with value at that specific phase
phase 1
Symbol : =-----
10
phase 2
Symbol : ==---
20
phase 3
Symbol : ===--
30
phase 4
Symbol : ====-
40
phase 5
Symbol : =====
50
if more than max phase length then os.exit()
11 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now