Advertisement
vintproykt

NxServ Advertiser (Expression 2)

Nov 29th, 2017
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. @name NxServ Advertiser
  2. @inputs Text:string Automate Delay Advertise
  3. @outputs Locked
  4. @persist AText:string ADelay
  5. @persist LockDelay LockTime
  6. @trigger Automate Advertise
  7.  
  8. #[
  9. Connect:
  10. + `Text` with Wire Text Entry (full charset);
  11. + `Automate` with toggleable button (advertise timer starts when active, otherwise it's stopped);
  12. + `Delay` set to constant number of minutes (delay between advertisements);
  13. + `Advertise` with hidden button (optional, makes instant advertisement when active).
  14.  
  15. Minimum delay between advertisements is 10 sec (i.e. `LockDelay / 1000` sec).
  16. You'd also automatically change text when `Locked == 1`, so your advertisement won't be annoying.
  17. ]#
  18.  
  19. function void renewAdvertiseTimer() {
  20. stoptimer("Advertise")
  21. if (Automate) { timer("Advertise", ADelay * 60000) }
  22. }
  23.  
  24. if (first()) {
  25. AText = "E2 code to help you make automatically delayed advertisements: https://pastebin.com/dT6XXdWK"
  26. ADelay = 5 # min
  27. LockDelay = 10000 # msec
  28. }
  29. if (->Text) { AText = Text }
  30. if (->Delay) { ADelay = Delay }
  31. if (~Automate) { renewAdvertiseTimer() }
  32. if (clk("Unlock")) { Locked = 0 }
  33. if (~Advertise & Advertise | clk("Advertise")) {
  34. if (Locked) {
  35. RemainingTime = ceil(LockTime + LockDelay / 1000 - realtime())
  36. if (RemainingTime > 0) { hint("Wait " + RemainingTime + " sec before next advertisement", 1) }
  37. }
  38. else {
  39. nxSayAdvert(AText)
  40. renewAdvertiseTimer()
  41. Locked = 1
  42. LockTime = realtime()
  43. timer("Unlock", LockDelay)
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement