Linkup! Wireless redstone and command buttons!


Author: beecee
Created: 2013-11-25T02:37:24-0500
Edited: 2014-02-11T16:59:34-0500
Denizen Version: 1440
Views: 52
Downloads: 942
Likes: 1


WGET
Description: A denizen script that lets you link up buttons, pressure plates and levers over an unlimited amount of channels! And also lets you tie commands to buttons, pressure plates and levers that run when a player toggles them!

Youtube demo video 1: http://youtu.be/U5eJLeJLe7o
Youtube demo video 2: http://youtu.be/I7_2HQFsQKk
Clean RAW text: http://mcmonkey4eva.dyndns.org/paste/363

commands and permission nodes:

/linkup addchannel channel
Adds the switch you're looking at to the specified channel.
permissions required: linkup.channel

/linkup removechannel channel/-all
removes the switch you're looking at from the specified channel or all channels.
permissions required: linkup.channel

/linkup addcommand 'command'
Adds the command to the switch you're looking at.
permissions required: linkup.command

/linkup removecommand 'command'/-all
removes the command or all commands form the switch you're looking at.
permissions required: linkup.command

/linkup check
Returns which channels and commands the switch you're looking at is linked to.
permissions required: linkup.check

"linkupevents":
  type: world
  debug: false
  events:
    on player right clicks lever:
    - inject local 'path:linkupeventtoggle' 
    on player right clicks wood_button:
    - inject local 'path:linkupeventtoggle'
    on player right clicks stone_button:
    - inject local 'path:linkupeventtoggle' 
    on player stands on stone_plate:
    - inject local 'path:linkupeventtoggle'
    on player stands on wood_plate:
    - inject local 'path:linkupeventtoggle'
    on linkup command:
    - inject locally 'path:linkupinject'
    on ll command:
    - inject locally 'path:linkupinject'
  linkupinject:
    - run scoreboardhint def:linkup
    - if <context.args.get[1]> == addchannel {
      - if <player.has_permission[linkup.channel]> != true {
        - narrate "<&c>You do not have the permission to do this."
        - determine fulfilled
        - queue clear
        }
      - if <context.args.get[2]> == null {
        - narrate "<&9>You must specify a channel name!"
        - narrate "<&c> /linkup addchannel <<>channel<>>"
        - determine fulfilled
        - queue clear
        }
      - if <player.location.cursor_on.material.bukkit_enum> == wood_button || <player.location.cursor_on.material.bukkit_enum> == stone_button || <player.location.cursor_on.material.bukkit_enum> == wood_plate || <player.location.cursor_on.material.bukkit_enum> == stone_plate || <player.location.cursor_on.material.bukkit_enum> == lever || <player.location.cursor_on.material.bukkit_enum> == wooden_door {
        - flag global 'linkup<context.args.get[2].to[500].replace[li@].replace[|].with[ ]>:->:<player.location.cursor_on>'
        - if <server.flag[linkupchannels].as_list> !contains '<context.args.get[2].to[500].replace[li@].replace[|].with[ ]>' flag global 'linkupchannels:->:<context.args.get[2].to[500].replace[li@].replace[|].with[ ]>'
        - narrate "<&9>Your device has been stored to channel '<context.args.get[2].to[500].replace[li@].replace[|].with[ ]>'"
        - determine fulfilled
        - queue clear
        } else {
        - narrate "<&c>You must be targeting a switch."
        - determine fulfilled
        - queue clear
        }
      }
    - if <context.args.get[1]> == removechannel {
      - if <player.has_permission[linkup.channel]> != true {
        - narrate "<&c>You do not have the permission to do this."
        - determine fulfilled
        - queue clear
        }
      - if <context.args.get[2]> == null {
        - narrate "<&9>You must specify a channel name or '-all' for all channels"
        - narrate "<&c> /linkup removechannel <<>channel/-all<>>"
        - determine fulfilled
        - queue clear
        }
      - if <player.location.cursor_on.material.bukkit_enum> == wood_button || <player.location.cursor_on.material.bukkit_enum> == stone_button || <player.location.cursor_on.material.bukkit_enum> == wood_plate || <player.location.cursor_on.material.bukkit_enum> == stone_plate || <player.location.cursor_on.material.bukkit_enum> == lever || <player.location.cursor_on.material.bukkit_enum> == wooden_door {
        - if <context.args.get[2]> == '-all' {
          - narrate "<&9>This device has been removed from all existing channels."
          - foreach <server.flag[linkupchannels].as_list> {
            - flag global linkup%value%:<-:<player.location.cursor_on>
            }
          - determine fulfilled
          - queue clear
          } else {
          - flag global 'linkup<context.args.get[2].to[500].replace[li@].replace[|].with[ ]>:<-:<player.location.cursor_on>'
          - narrate "<&9>Your device has been removed from channel '<context.args.get[2].to[500].replace[li@].replace[|].with[ ]>'"
          - determine fulfilled
          - queue clear
          }
        } else {
        - narrate "<&c>You must be targeting a switch."
        - determine fulfilled
        - queue clear
        }
      }
    - if <context.args.get[1]> == addcmd || <context.args.get[1]> == addcommand {
      - if <player.has_permission[linkup.command]> != true {
        - narrate "<&c>You do not have the permission to do this."
        - determine fulfilled
        - queue clear
        }
      - if <context.args.get[2]> == null {
        - narrate "<&b>You must specify a command!"
        - narrate "<&c> /linkup addcommand <<>'command'<>>"
        - determine fulfilled
        - queue clear
        }
      - if <player.location.cursor_on.material.bukkit_enum> == wood_button || <player.location.cursor_on.material.bukkit_enum> == stone_button || <player.location.cursor_on.material.bukkit_enum> == wood_plate || <player.location.cursor_on.material.bukkit_enum> == stone_plate || <player.location.cursor_on.material.bukkit_enum> == lever {
        - if <server.flag[linkupcmdbuttons].as_list> !contains <player.location.cursor_on> flag global linkupcmdbuttons:->:<player.location.cursor_on>
        - if <server.flag[linkupcmd<player.location.cursor_on>].as_list> !contains '<context.args.get[2].to[500].replace[li@].replace[|].with[ ]>' {
          - flag global 'linkupcmd<player.location.cursor_on>:->:<context.args.get[2].to[500].replace[li@].replace[|].with[ ]>'
          }
        - narrate "<&9>Your command has been stored to this device."
        - determine fulfilled
        - queue clear
        } else {
        - narrate "<&c>You must be targeting a switch."
        - determine fulfilled
        - queue clear
        }
      }
    - if <context.args.get[1]> == removecmd || <context.args.get[1]> == removecommand {
      - if <player.has_permission[linkup.command]> != true {
        - narrate "<&c>You do not have the permission to do this."
        - determine fulfilled
        - queue clear
        }
      - if <context.args.get[2]> == null {
        - narrate "<&9>You must specify a command or '-all' for all commands!"
        - narrate "<&c> /linkup removecommand <<>command/-all<>>"
        - determine fulfilled
        - queue clear
        }
      - if <player.location.cursor_on.material.bukkit_enum> == wood_button || <player.location.cursor_on.material.bukkit_enum> == stone_button || <player.location.cursor_on.material.bukkit_enum> == wood_plate || <player.location.cursor_on.material.bukkit_enum> == stone_plate || <player.location.cursor_on.material.bukkit_enum> == lever || <player.location.cursor_on.material.bukkit_enum> == wooden_door {
        - if <context.args.get[2]> == '-all' {
          - narrate "<&9>All commands have been removed from this device."
          - flag global linkupcmd<player.location.cursor_on>:!
          - determine fulfilled
          - queue clear
          } else {
          - flag global 'linkupcmd<player.location.cursor_on>:<-:<context.args.get[2].to[500].replace[li@].replace[|].with[ ]>'
          - narrate "<&9>Your command has been removed from this device."
          - determine fulfilled
          - queue clear
          }
        } else {
        - narrate "<&c>You must be targeting a switch."
        - determine fulfilled
        - queue clear
        }
      }
    - if <context.args.get[1]> == check {
      - if <player.has_permission[linkup.check]> != true {
        - narrate "<&c>You do not have the permission to do this."
        - determine fulfilled
        - queue clear
        }
      - narrate "<&9>This device is linked to the following channels:"
      - foreach <server.flag[linkupchannels].as_list> {
        - if <server.flag[linkup%value%].as_list> contains <player.location.cursor_on> narrate "<&c>Channel '%value%'"
        }
      - narrate "<&9>The following commands are linked to this device:"
      - foreach <server.flag[linkupcmd<player.location.cursor_on>].as_list> {
        - narrate "<&c>Command '%value%'"
        }
      - determine fulfilled
      - queue clear
      } else {
      - narrate ""
      - narrate "<&c>usage<&co> /linkup addchannel <<>channel<>>"
      - narrate "<&9>description<&co> Adds the switch you're looking at to the specified channel."
      - narrate "<&c>usage<&co> /linkup removechannel <<>channel/-all<>>"
      - narrate "<&9>description<&co> removes the switch you're looking at from the specified channel or all channels."
      - narrate "<&c>usage<&co> /linkup addcommand <<>command<>>"
      - narrate "<&9>description<&co> Adds a command to the switch you're looking at"
      - narrate "<&c>usage<&co> /linkup removecommand <<>command/-all<>>"
      - narrate "<&9>description<&co> removes a command or all commands from the switch you're looking at."
      - narrate "<&c>usage<&co> /linkup check"
      - narrate "<&9>description<&co> Returns which channels and commands the switch you're looking at is linked to."
      - narrate "<&c>Variables<&co> <&9><<>player.name<>>."
      - determine fulfilled
      - queue clear
      }
  linkupeventtoggle:
    - foreach <server.flag[linkupchannels].as_list> {
      - if <server.flag[linkup%value%].as_list> contains <context.location> run linkuptoggle def:%value%|<context.location>
      }
    - if <server.flag[linkupcmd<context.location>]> != null run linkupcmd def:<context.location>

"linkuptoggle":
    type: task
    debug: false
    script:
        - ^foreach <server.flag[linkup%1%].as_list> {
          - if %2% == %value% queue clear
          - switch %value%
          }
"linkupcmd":
    type: task
    debug: false
    script:
        - ^foreach <server.flag[linkupcmd%1%].as_list> {
          - execute as_op '%value%'
          }




Comments
No one has posted a comment! Post one below: