CubeCoders / AMP

Issue tracking and documentation for AMP
https://cubecoders.com/AMP
MIT License
207 stars 38 forks source link

Feature request: "Cycle" task #1025

Open TheStraying11 opened 7 months ago

TheStraying11 commented 7 months ago

Feature Request

Feature Information:

 Trigger: Simple Time Interval 10 minutes
    Task: Cycle
        Task: Send message to everyone on the server
            MessageOne
         Task: Send message to everyone on the server
             MessageTwo
         Task: Send message to everyone on the server
             MessageThree

would send "MessageOne", then "MessageTwo", then "MessageThree", one after the other, with one message every 10 minutes, repeating after "MessageThree"

I confirm:

IceOfWraith commented 7 months ago

This can already be done with one trigger and three tasks. Unless I'm misunderstanding.

IceOfWraith commented 7 months ago

Ohh I see what you're saying. Instead, you'd just do three triggers of every X minutes. Each with one of the messages. I think that's what you're wanting.

TheStraying11 commented 7 months ago

let me add some "pseudocode" (python xD)

import time

i = 0
taskList = [
    lambda: print("MessageOne"),
    lambda: print("MessageTwo"),
    lambda: print("MessageThree")
    # you have the ability to easily add as many of these as you like
]
while True:
    taskList[i]()
    i += 1
    i %= len(taskList)
    time.sleep(10*60) # 10 minute sleep
TheStraying11 commented 7 months ago

the current way, as far as i can see, say you want this to trigger at 5pm every day, you'd have to manually work out the timings, so that it plays the next message at the correct time, and then cycles back

TheStraying11 commented 7 months ago

i suppose, rather than that while loop if you put the taskList[i](), and the i+=1 and i%=len(taskList) parts in a def trigger():, that's more like what would happen in AMP, like, whatever you set the trigger to, those three lines get called every single time it triggers

IceOfWraith commented 7 months ago

Perhaps the Wait Task would be what you want then?

TheStraying11 commented 7 months ago

https://paste.gg/p/TheStraying11/83783d3e762844e1bb9d051d9af219bf

here is a more robust example that shows its usefulness over the "Wait" task, while the first two are just harder to do with just "Wait", specifically the last trigger I define, cannot be done with a wait, this would not only be a convenience tool, but a much more powerful one aswell

TheStraying11 commented 7 months ago

you could have for example, a trigger where, if a player performs a certain action, a certain number of times, they get banned, but before that they are given warnings, or a warning if a backup fails once, then another if it fails twice, and finally if it fails three times, the server gets shut down