Advertisement
Guest User

Gravestones

a guest
Mar 31st, 2015
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 22.17 KB | None | 0 0
  1. on load:
  2.     set {gs.setting.first.block} to false
  3.     set {gs.setting.second.block} to false
  4.     set {gs.setting.ground} to false
  5.     if {gs.blacklist.every.region} is not set:
  6.         set {gs.blacklist.every.region} to false
  7.     if {gs.creationmethod} is not set:
  8.         set {gs.creationmethod} to "setblock"
  9.  
  10. command /gravestones <text="help"> [<text>]:
  11.     permission: skript.gravestones
  12.     aliases: /gs
  13.     trigger:
  14.         if arg-1 is "help":
  15.             if arg-2 is "methods":
  16.                 message "<cyan>   Setblock using relative coords to set blocks around." to player
  17.                 message "<grey>Grave will look like 2 podzol blocks at ground level, double-" to player
  18.                 message "<grey>chest underneath, and cobble fence with player head above it." to player
  19.                 message "<cyan>Use this, if you like my design, and don't want to set up stuff." to player
  20.                 message "" to player
  21.                 message "<grey>   Clone is using vanilla /clone command." to player
  22.                 message "<cyan>You need to build a tomb, and define it using /gs setgrave." to player
  23.                 message "<grey>This method will detect chests in your tomb and store drops in." to player
  24.                 message "<cyan>Chests can be placed separately, not necessarily as double." to player
  25.                 message "<light red>If you place 2< chests though, unfit drop will be dropped near!" to player
  26.                 message "<cyan>If there is a skull(397:3), it will be replaced with victim's." to player
  27.                 message "<grey>You need to place your structure somewhere at spawn(most-" to player
  28.                 message "<grey>likely underground), because it won't work w/ unloaded chunks." to player
  29.                 message "" to player
  30.                 message "<cyan>   Schematic method should work with PirateSK and WorldEdit." to player
  31.                 message "<grey>But, it seems PirateSK doesn't work with Skript 2.2, so I can't" to player
  32.                 message "<grey>test it, so it's disabled. <light red>Sorry<grey>." to player
  33.                 stop
  34.             if arg-2 is "masks":
  35.                 message "<cyan>   In masked mode, your tomb will be copied ignoring air."  to player
  36.                 message "<grey>In replace mode vice versa." to player
  37.                 message "<cyan>For example: your tomb is a hollow box with chest in the middle." to player
  38.                 message "<grey>Your player suffocated somewhere deep undergound." to player
  39.                 message "<cyan>With masked mode tomb will be filled with stone and other blocks." to player
  40.                 message "<grey>But with replace mode it will be placed as is - hollow." to player
  41.                 stop
  42.             else:
  43.                 message "   <cyan>/gs help <grey>will show this page." to player
  44.                 message "<cyan>/gs method <clone/setblock/<black>schematic<cyan>> <grey>will set gravestone creation method." to player
  45.                 message "<cyan>/gs help methods <grey>will show more info about creation methods." to player
  46.                 message "<cyan>/gs setgrave <grey>will start selection of gravestone structure. Type again to cancel.<light red>*" to player
  47.                 message "<cyan>/gs setmask <masked/replace> <grey>will set mask mode.<light red>*" to player
  48.                 message "<cyan>/gs help masks <grey>will show more info about masks for /clone command.<light red>*" to player
  49.                 message "<cyan>/gs protect <region name> <grey>will add region to blacklist. Type in  '<cyan> <every> <grey>' as region name to enable blacklisting for all regions. Regions, where player can't build are protected by default. Set this only if you want to protect regions from permitted administrators or donators." to player
  50.                 message "<cyan>/gs unprotect <region name> <grey>will remove region from blacklist. Type in '<cyan> <every> <grey>' as region name to disable blacklisting for all regions. (This will not affect regions you added manually)" to player
  51. #                message "<cyan>/gs protectlist <grey>will show every protected region."
  52.                 message "<cyan>/gs info <grey>will show your config information." to player
  53.                 message "   <light red>*Those commands are only for <grey>clone <light red>creation method." to player
  54.         if arg-1 is "method":
  55.             if arg-2 is "clone":
  56.                 set {gs.creationmethod} to "clone"
  57.                 if {gs.clone.maskmode} is not set:
  58.                     set {gs.clone.maskmode} to "masked"
  59.                 message "   <grey>Creation method has been set to <cyan>%{gs.creationmethod}%<grey>." to player
  60.                 message "<grey>This method has additional options, look at <cyan>/gs info<grey>." to player
  61.                 stop
  62.             if arg-2 is "setblock":
  63.                 set {gs.creationmethod} to "setblock"
  64.                 message "   <grey>Creation method has been set to <cyan>%{gs.creationmethod}%<grey>." to player
  65.                 stop
  66.             if arg-2 is "schematic":
  67. #                set {gs.creationmethod} to "schematic"
  68. #                message "   <grey>Creation method has been set to <cyan>%{gs.creationmethod}%<grey>." to player
  69.                 message "   <light red>This method is currenly under construction, sorry." to player
  70.                 stop
  71.             else:
  72.                 message "   <grey>You need to specify method to set it." to player
  73.                 message "<grey>It can be either <cyan>clone<grey>, <cyan>setblock<grey> or <cyan>schematic<grey>." to player
  74.                 message "<grey>Current is: <cyan>%{gs.creationmethod}%<grey>." to player
  75.                 stop
  76.         if arg-1 is "setgrave":
  77.             if {gs.creationmethod} is "clone":
  78.                 if {gs.setting.first.block} and {gs.setting.second.block} and {gs.setting.ground} is false:
  79.                     set {gs.setting.first.block} to true
  80.                     message "<grey>Break a block to select <cyan>first <grey>coordinate." to player
  81.                 else:
  82.                     set {gs.setting.first.block} and {gs.setting.second.block} and {gs.setting.ground} to false
  83.                     message "<light red>You canceled coordinates setting. Coordinates may be invalid, if you canceled in the middle of the process, check /gs info to be sure." to player
  84.             else:
  85.                 message "<light red>This command only works with <grey>clone <light red>creation method selected." to player
  86.         if arg-1 is "setmask":
  87.             if {gs.creationmethod} is "clone":
  88.                 if arg-2 is "masked":
  89.                     set {gs.clone.maskmode} to "masked"
  90.                     message "   <grey>Mask mode has been set to <cyan>%{gs.clone.maskmode}%<grey>." to player
  91.                     stop
  92.                 if arg-2 is "replace":
  93.                     set {gs.clone.maskmode} to "replace"
  94.                     message "   <grey>Mask has been set to <cyan>%{gs.clone.maskmode}%<grey>." to player
  95.                     stop
  96.                 else:
  97.                     message "   <grey>You need to specify mode to set it." to player
  98.                     message "<grey>It can be either <cyan>masked<grey> or <cyan>replace<grey>." to player
  99.                     message "<grey>Current is: <cyan>%{gs.clone.maskmode}%<grey>." to player
  100.             else:
  101.                 message "<light red>This command only works with <grey>clone <light red>creation method selected." to player
  102.         if arg-1 is "protect":
  103.             if arg-2 is "<every>":
  104.                 set {gs.blacklist.every.region} to true
  105.                 message "   <grey>Protection for every region is <cyan>enabled." to player
  106.                 stop
  107.             if arg-2 is not set:
  108.                 message "   <grey>You need to specify a region. Use <cyan>/gs <grey>for help." to player
  109.                 stop
  110.             else:
  111.                 add arg-2 to {gs.blacklist.regions.list::*}
  112.                 message "   <grey>Added <cyan>%arg-2% <grey>to protected regions list." to player
  113.         if arg-1 is "unprotect":
  114.             if arg-2 is "<every>":
  115.                 set {gs.blacklist.every.region} to false
  116.                 message "   <grey>Protection for every region is <cyan>disabled." to player
  117.                 stop  
  118.             if arg-2 is not set:
  119.                 message "   <grey>You need to specify a region. Use <cyan>/gs <grey>for help." to player
  120.                 stop
  121.             else:
  122.                 remove arg-2 from {gs.blacklist.regions.list::*}
  123.                 message "   <grey>Removed <cyan>%arg-2% <grey>from protected regions list." to player
  124. #        if arg-1 is "protectlist":
  125. #            message "   <cyan>Protected regions: <grey>%{gs.blacklist.regions.list::*}%." to player
  126.         if arg-1 is "info":
  127.             if {gs.creationmethod} is "setblock":
  128.                 message "   <grey>Current creation method is <cyan>%{gs.creationmethod}%<grey>." to player
  129.                 if {gs.blacklist.every.region} is true:
  130.                     message "<grey>Every region is currently protected from grave creation." to player
  131.                 else:
  132.                     message "<cyan>Protected regions: <grey>%{gs.blacklist.regions.list::*}%." to player
  133.             else:
  134.                 message "   <grey>Current creation method is <cyan>%{gs.creationmethod}%<grey>." to player
  135.                 message "<grey>Current clone mask mode is <cyan>%{gs.clone.maskmode}%<grey>." to player
  136.                 message "<grey>Current gravestone cloning structure coordinates:" to player
  137.                 message "<cyan>%x-coord of {gs.clone.first.loc}% %y-coord of {gs.clone.first.loc}% %z-coord of {gs.clone.first.loc}% <grey>TO <cyan>%x-coord of {gs.clone.second.loc}% %y-coord of {gs.clone.second.loc}% %z-coord of {gs.clone.second.loc}%<grey>." to player
  138.                 message "<grey>Current ground offset is <cyan>%{gs.clone.structure.groundoffset}%<grey>." to player
  139.                 message "<grey>Current structure dimensions: <cyan>%{gs.absolute.width}%<grey> on X, <cyan>%{gs.absolute.height}%<grey> on Y and <cyan>%{gs.absolute.depth}%<grey> on Z." to player
  140.                 if {gs.blacklist.every.region} is true:
  141.                     message "<grey>Every region is currently protected from grave creation." to player
  142.                 else:
  143.                     message "<cyan>Protected regions: <grey>%{gs.blacklist.regions.list::*}%." to player
  144.  
  145. on block break:
  146.     if {gs.setting.ground} is true:
  147.         cancel event
  148.         message "<grey>Ground set. Calculating things..." to player
  149.  
  150. #Calculating ground offset
  151.         if y-coord of {gs.clone.first.loc} <= y-coord of {gs.clone.second.loc}:
  152.             set {gs.clone.structure.groundoffset} to y-coord of {gs.clone.first.loc} - y-coord of event-block
  153.             set {gs.absolute.height} to y-coord of {gs.clone.second.loc} - y-coord of {gs.clone.first.loc} + 1
  154.         if y-coord of {gs.clone.first.loc} > y-coord of {gs.clone.second.loc}:
  155.             set {gs.clone.structure.groundoffset} to y-coord of {gs.clone.second.loc} - y-coord of event-block
  156.             set {gs.absolute.height} to y-coord of {gs.clone.first.loc} - y-coord of {gs.clone.second.loc} + 1
  157.            
  158. #Making coordinates absolute to calculate structure size
  159.         if x-coord of {gs.clone.first.loc} < 0:
  160.             set {_absolute.x1} to x-coord of {gs.clone.first.loc} * -1
  161.         if z-coord of {gs.clone.first.loc} < 0:
  162.             set {_absolute.z1} to z-coord of {gs.clone.first.loc} * -1
  163.            
  164.         if x-coord of {gs.clone.second.loc} < 0:
  165.             set {_absolute.x2} to x-coord of {gs.clone.second.loc} * -1
  166.         if z-coord of {gs.clone.second.loc} < 0:
  167.             set {_absolute.z2} to z-coord of {gs.clone.second.loc} * -1
  168.            
  169. #Calculating structure size
  170.         set {gs.absolute.width} to {_absolute.x1} - {_absolute.x2}
  171.         set {gs.absolute.depth} to {_absolute.z1} - {_absolute.z2}
  172.        
  173.         if {gs.absolute.width} < 0:
  174.             set {gs.absolute.width} to {gs.absolute.width} * -1
  175.         if {gs.absolute.depth} < 0:
  176.             set {gs.absolute.depth} to {gs.absolute.depth} * -1
  177.  
  178.         set {gs.absolute.width} to {gs.absolute.width} + 1
  179.         set {gs.absolute.depth} to {gs.absolute.depth} + 1
  180. #End of calculations
  181.        
  182.         message "<cyan>Done." to player
  183.         set {gs.setting.ground} to false  
  184.        
  185.     if {gs.setting.second.block} is true:
  186.         cancel event
  187.         message "<grey>Second coordinate set" to player
  188.         message "<grey>Region selected, now break any block where <cyan>ground level <grey>should be when gravestone is placed." to player
  189.         message "<grey>For example, if you want your tomb to be a single chest on the ground, break block under chest." to player
  190.         set {gs.clone.second.loc} to location of event-block
  191.         set {gs.setting.second.block} to false
  192.         set {gs.setting.ground} to true
  193.        
  194.     if {gs.setting.first.block} is true:
  195.         cancel event
  196.         message "<grey>First coordinate set" to player
  197.         message "<grey>Break a block to select <cyan>second <grey>coordinate." to player
  198.         set {gs.clone.first.loc} to location of event-block
  199.         set {gs.setting.first.block} to false
  200.         set {gs.setting.second.block} to true
  201.  
  202. on death of a player:
  203.  
  204. #Delete previous grave if exists, and reset some variables
  205.     set {_canbuild.%player%} to true
  206.     delete {gs.items.%player%::*}
  207.     delete {gs.location.%player%}
  208.    
  209. #Calculate ground coordinate
  210.     set {gs.location.%player%} to location of player
  211.     while block at {gs.location.%player%} is air or stationary water or flowing water:
  212.         set {gs.location.%player%} to location 1 meter below {gs.location.%player%}
  213.     #If there is no ground, don't set Y:
  214.        if y-coord of block at {gs.location.%player%} is 0:
  215.            set y-coord of {gs.location.%player%} to -1
  216.            message "Grave can't be created in void" to player
  217.            stop
  218.  
  219. #Vanilla clone command gravestone creation method
  220.    #Check if player can build at grave location
  221.    if {gs.creationmethod} is "clone":
  222.        add block at location rounded {gs.absolute.depth}/2 meters north and rounded {gs.absolute.width}/2 meters west and rounded {gs.absolute.height}/2 meters above {gs.location.%player%} to {_canbuildat.%player%::*}
  223.        add block at location rounded {gs.absolute.depth}/2 meters north and rounded {gs.absolute.width}/2 meters east and rounded {gs.absolute.height}/2 meters above {gs.location.%player%} to {_canbuildat.%player%::*}
  224.        add block at location rounded {gs.absolute.depth}/2 meters south and rounded {gs.absolute.width}/2 meters west and rounded {gs.absolute.height}/2 meters above {gs.location.%player%} to {_canbuildat.%player%::*}
  225.        add block at location rounded {gs.absolute.depth}/2 meters south and rounded {gs.absolute.width}/2 meters east and rounded {gs.absolute.height}/2 meters above {gs.location.%player%} to {_canbuildat.%player%::*}
  226.        add block at location rounded {gs.absolute.depth}/2 meters north and rounded {gs.absolute.width}/2 meters west and rounded {gs.absolute.height}/2 meters below {gs.location.%player%} to {_canbuildat.%player%::*}
  227.        add block at location rounded {gs.absolute.depth}/2 meters north and rounded {gs.absolute.width}/2 meters east and rounded {gs.absolute.height}/2 meters below {gs.location.%player%} to {_canbuildat.%player%::*}
  228.        add block at location rounded {gs.absolute.depth}/2 meters south and rounded {gs.absolute.width}/2 meters west and rounded {gs.absolute.height}/2 meters below {gs.location.%player%} to {_canbuildat.%player%::*}
  229.        add block at location rounded {gs.absolute.depth}/2 meters south and rounded {gs.absolute.width}/2 meters east and rounded {gs.absolute.height}/2 meters below {gs.location.%player%} to {_canbuildat.%player%::*}
  230.        if player cannot build at {_canbuildat.%player%::*}:
  231.            set {_canbuild.%player%} to false
  232.        if "%region at {_canbuildat.%player%::*}%" is not "<none>":
  233.            if {gs.blacklist.every.region} is true:
  234.                set {_canbuild.%player%} to false
  235.        if "%region at {_canbuildat.%player%::*}%" contains {gs.blacklist.regions.list::*}:
  236.            set {_canbuild.%player%} to false
  237.        if {_canbuild.%player%} is true:
  238.    #Start making grave
  239.            add drops to {gs.items.%player%::*}
  240.            if {gs.clone.first.loc} and {gs.clone.second.loc} and {gs.clone.structure.groundoffset} is set:
  241.                execute console command "/clone %x-coord of {gs.clone.first.loc}% %y-coord of {gs.clone.first.loc}% %z-coord of {gs.clone.first.loc}% %x-coord of {gs.clone.second.loc}% %y-coord of {gs.clone.second.loc}% %z-coord of {gs.clone.second.loc}% %x-coord of {gs.location.%player%} - rounded down {gs.absolute.width}/2% %y-coord of {gs.location.%player%} + {gs.clone.structure.groundoffset}% %z-coord of {gs.location.%player%} - rounded down {gs.absolute.depth}/2% %{gs.clone.maskmode}%"
  242.                loop blocks within {_canbuildat.%player%::1} to {_canbuildat.%player%::8}:
  243.                    if loop-block is a chest:
  244.                        add location of loop-blocks to {_chest.loc.%player%::*}
  245. #                        if {_chest.loc.%player%::2} is set:
  246. #                            exit loop
  247.                    if loop-block is a mob head block:
  248.                        set {_skull.loc.%player%} to location of loop-block
  249.                        execute console command "/blockdata %x-coord of {_skull.loc.%player%}% %y-coord of {_skull.loc.%player%}% %z-coord of {_skull.loc.%player%}% {SkullType:3,ExtraType:%player%}"
  250.                execute console command "/setblock %x coord of {_chest.loc.%player%::1}% %y coord of {_chest.loc.%player%::1}% %z coord of {_chest.loc.%player%::1}% chest 0 replace {CustomName:Loot of %player%}"
  251.                execute console command "/setblock %x coord of {_chest.loc.%player%::2}% %y coord of {_chest.loc.%player%::2}% %z coord of {_chest.loc.%player%::2}% chest 0 replace {CustomName:Loot of %player%}"
  252.    #Adding drops to found chests
  253.                if {_chest.loc.%player%::1} is set:
  254.                    loop 40 times:
  255.                        set {_loop.counter.%player%} to loop-number + 1
  256.                        if block at {_chest.loc.%player%::1} has enough space for {gs.items.%player%::%loop-number%}:
  257.                            add {gs.items.%player%::%loop-number%} to block at {_chest.loc.%player%::1}
  258.                        else:
  259.                            if {_chest.loc.%player%::2} is set:
  260.                                add {gs.items.%player%::%loop-number%} to block at {_chest.loc.%player%::2}
  261.                            else:
  262.                                drop {gs.items.%player%::%loop-number%} at location 5 meters above {_chest.loc.%player%::1}
  263.                    clear drops
  264.                else:
  265.                    stop
  266.                clear {gs.items.%player%::*}
  267.            else:
  268.                message "<light red>Don't know what to clone, coordinates not set." to player
  269.    
  270. #Setblock gravestone creation method
  271.    if {gs.creationmethod} is "setblock":
  272.        add block at location north and 2 meters above {gs.location.%player%} to {_canbuildat.%player%::*}
  273.        add block at location below {gs.location.%player%} to {_canbuildat.%player%::*}
  274.        if player cannot build at {_canbuildat.%player%::*}:
  275.            set {_canbuild.%player%} to false
  276.            broadcast "cant' build here"
  277.        if "%region at {_canbuildat.%player%::*}%" is not "<none>":
  278.            if {gs.blacklist.every.region} is true:
  279.                set {_canbuild.%player%} to false
  280.                broadcast "there is a region near your death location, can't create grave"
  281.        if "%region at {_canbuildat.%player%::*}%" contains {gs.blacklist.regions.list::*}:
  282.            set {_canbuild.%player%} to false
  283.            broadcast "blacklisted region found, can't create grave"
  284.        if {_canbuild.%player%} is true:  
  285.            broadcast "digging grave here"
  286.    #Start making grave
  287.            add drops to {gs.items.%player%::*}
  288.            set block at {gs.location.%player%} to dirt:2
  289.            set block 1 meter north of {gs.location.%player%} to dirt:2
  290.            set block at location 1 meter north and above {gs.location.%player%} to cobblestone wall
  291.            execute console command "/setblock %x-coord of {gs.location.%player%}% %y-coord of {gs.location.%player%} +2% %z-coord of {gs.location.%player%} -1% skull 1 keep {SkullType:3,ExtraType:%player%,Rot:8}"
  292.            execute console command "/fill %x-coord of {gs.location.%player%}% %y-coord of {gs.location.%player%} -1% %z-coord of {gs.location.%player%}% %x-coord of {gs.location.%player%}% %y-coord of {gs.location.%player%} -1% %z-coord of {gs.location.%player%} -1% chest 0 replace {CustomName:Loot of %player%}"
  293.    #Adding drops to created chest
  294.        loop blocks within {_canbuildat.%player%::1} to {_canbuildat.%player%::2}:
  295.            if loop-block is a chest:
  296.                if inventory name of loop-block is "Loot of %player%":
  297.                    add {gs.items.%player%::*} to loop-block
  298.                    clear drops
  299.                    stop loop
  300.            clear {gs.items.%player%::*}
  301.  
  302.    #Schematic gravestone creation method
  303. #        if {gs.creationmethod} is "schematic":
  304. #            paste schematic "gravestone" at event-location
  305. #            do stuff
  306. #            clear {gs.items.%player%::*}
  307.  
  308. #Help player destroy setblock grave
  309. on break of dirt:2:
  310.    if block above event-block is cobblestone wall:
  311.        if block 2 blocks above event-block is head:
  312.            if block below event-block is a chest:
  313.                execute console command "/setblock %x coordinate of event-block% %y coordinate of event-block +1% %z coordinate of event-block% air 0"
  314.                execute console command "/setblock %x coordinate of event-block% %y coordinate of event-block +2% %z coordinate of event-block% air 0 destroy"
  315. on break of a head:
  316.    if block below event-block is cobblestone wall:
  317.        if block 2 blocks below event-block is dirt:2:
  318.            if block 3 blocks below event-block is a chest:
  319.                execute console command "/setblock %x coordinate of event-block% %y coordinate of event-block -1% %z coordinate of event-block% air 0"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement