Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name NxServ Advertiser
- @inputs Text:string Automate Delay Advertise
- @outputs Locked
- @persist AText:string ADelay
- @persist LockDelay LockTime
- @trigger Automate Advertise
- #[
- Connect:
- + `Text` with Wire Text Entry (full charset);
- + `Automate` with toggleable button (advertise timer starts when active, otherwise it's stopped);
- + `Delay` set to constant number of minutes (delay between advertisements);
- + `Advertise` with hidden button (optional, makes instant advertisement when active).
- Minimum delay between advertisements is 10 sec (i.e. `LockDelay / 1000` sec).
- You'd also automatically change text when `Locked == 1`, so your advertisement won't be annoying.
- ]#
- function void renewAdvertiseTimer() {
- stoptimer("Advertise")
- if (Automate) { timer("Advertise", ADelay * 60000) }
- }
- if (first()) {
- AText = "E2 code to help you make automatically delayed advertisements: https://pastebin.com/dT6XXdWK"
- ADelay = 5 # min
- LockDelay = 10000 # msec
- }
- if (->Text) { AText = Text }
- if (->Delay) { ADelay = Delay }
- if (~Automate) { renewAdvertiseTimer() }
- if (clk("Unlock")) { Locked = 0 }
- if (~Advertise & Advertise | clk("Advertise")) {
- if (Locked) {
- RemainingTime = ceil(LockTime + LockDelay / 1000 - realtime())
- if (RemainingTime > 0) { hint("Wait " + RemainingTime + " sec before next advertisement", 1) }
- }
- else {
- nxSayAdvert(AText)
- renewAdvertiseTimer()
- Locked = 1
- LockTime = realtime()
- timer("Unlock", LockDelay)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement