Description: My second script posting, now I'm getting adventurous!
This script is for OP players on servers where there are NPC villages that are experiencing population troubles.
The /village command is basically the help.
First step for any OP should be to /listvillage - this gives a list of the village locations added by any OP.
You use /addvillage and the players location is stored in the vLocList variable (Village Location List), this location should be the 'center' of the village.
When the /checkvillage command is run, each location stored in the list is checked, and if there are less than 2 villagers within 30 blocks, two new ones will be spawned in.
OP's can go to the villages to check on them using /gotovillage <number>
If a village location is no longer needed, simply /delvillage <number> to remove it from the list.
The villages in the list are checked each minecraft morning at 8am, just as though an OP has run the /checkvillage command.
# Village Population# by Krowerom, 8th May 2014# ---------------# This script is for OP players on servers where there are NPC villages # that are experiencing population troubles.# The /village command is basically the help.# First step for any OP should be to /listvillage - this gives a list# of the village locations added by any OP.# You use /addvillage and the players location is stored in the vLocList# variable (Village Location List)# This location should be the 'center' of the village.# When the /checkvillage command is run, each location stored in the list# is checked, and if there are less than 2 villagers within 30 blocks, # two new ones will be spawned in.# OP's can go to the villages to check on them using /gotovillage <number># If a village location is no longer needed, simply /delvillage <number> to# remove it from the list.# The villages in the list are checked each minecraft morning at 8am, just# as though an OP has run the /checkvillage command.
'VillagePopulation':
type: world
events:
on village command:
- if <player.is_op> {
- narrate "<gray>There are a number of commands<&co>"
- narrate "<aqua>/addvillage<white> - adds the player location to the village list"
- narrate "<aqua>/listvillage<white> - lists village locations"
- narrate "<aqua>/gotovillage <gold>number<white> - goes to village in position <gold>number"
- narrate "<white> from the listvillage command"
- narrate "<aqua>/delvillage <gold>number<white> - removes the village in position <gold>number"
- narrate "<white> from the listvillage command"
- narrate "<aqua>/checkvillage<white> - checks that village locations have at least"
- narrate "<white> two villagers"
- narrate "<gray>The village check runs automatically at 8am every minecraft day."
- determine fulfilled
}
on addvillage command:
- if <player.is_op> {
- flag global vLocList:->:<player.location.simple>
- announce to_ops "<green><player.name> added <player.location.simple> to vLocList"
- determine fulfilled
}
on delvillage command:
- if <player.is_op> {
- flag player vDel:<[email protected][<context.raw_args>]>
- flag global vLocList:<-:<player.flag[vDel]>
- announce to_ops "<red><player.name> removed <player.flag[vDel]> from vLocList"
- flag player vDel:!
- determine fulfilled
}
on listvillage command:
- if <player.is_op> {
- foreach <[email protected]_list> {
- flag player vCounter:++
- narrate "<aqua><player.flag[vCounter].asint><&co> %value%"}
- flag player vCounter:!
- determine fulfilled
}
on gotovillage command:
- if <player.is_op> {
- teleport <player.name> <[email protected][<context.raw_args>]>
- narrate "<gold>You were taken to village <context.raw_args> at <[email protected][<context.raw_args>]>"
- determine fulfilled
}
on checkvillage command:
- if <player.is_op> {
- run CheckingVillages
- determine fulfilled
}
on 8:00 in world:
- run CheckingVillages
- determine fulfilled
'CheckingVillages':
type: task
script:
- foreach <[email protected]_list> {
- flag global vCounter:++
- chunkload add <l@%value%.add[16,0,16]>
- chunkload add <l@%value%.add[16,0,0]>
- chunkload add <l@%value%.add[16,0,-16]>
- chunkload add <l@%value%.add[0,0,16]>
- chunkload add %value%
- chunkload add <l@%value%.add[0,0,-16]>
- chunkload add <l@%value%.add[-16,0,16]>
- chunkload add <l@%value%.add[-16,0,0]>
- chunkload add <l@%value%.add[-16,0,-16]>
- announce to_ops "<gray><l@%value%.find.entities[VILLAGER].within[30].size> Villagers found at <global.flag[vCounter].asint><&co> %value%"
- if <l@%value%.find.entities[VILLAGER].within[30].size> < 2 {
- spawn villager l@%value%
- spawn villager l@%value%
- announce to_console "<global.flag[vCounter].asint><&co> %value% Repopulated!"
- announce to_ops "<red><global.flag[vCounter].asint><&co> %value% Repopulated!"
- chunkload remove <l@%value%.add[16,0,16]>
- chunkload remove <l@%value%.add[16,0,0]>
- chunkload remove <l@%value%.add[16,0,-16]>
- chunkload remove <l@%value%.add[0,0,16]>
- chunkload remove %value%
- chunkload remove <l@%value%.add[0,0,-16]>
- chunkload remove <l@%value%.add[-16,0,16]>
- chunkload remove <l@%value%.add[-16,0,0]>
- chunkload remove <l@%value%.add[-16,0,-16]>} else {
- announce to_console "<global.flag[vCounter].asint><&co> %value% Population is OK (<l@%value%.find.entities[VILLAGER].within[30].size>)"
- announce to_ops "<green><global.flag[vCounter].asint><&co> %value% Population is OK"
- chunkload remove <l@%value%.add[16,0,16]>
- chunkload remove <l@%value%.add[16,0,0]>
- chunkload remove <l@%value%.add[16,0,-16]>
- chunkload remove <l@%value%.add[0,0,16]>
- chunkload remove %value%
- chunkload remove <l@%value%.add[0,0,-16]>
- chunkload remove <l@%value%.add[-16,0,16]>
- chunkload remove <l@%value%.add[-16,0,0]>
- chunkload remove <l@%value%.add[-16,0,-16]>}}
- flag global vCounter:!
I found the issue.. I set my village locations near to the edge of a chunk, so some villagers are not loaded when the check takes place. Still working to fix!
now I posted it.. I found an issue.. the chunk loading isn't working as it should, I am working to fix
I found the issue.. I set my village locations near to the edge of a chunk, so some villagers are not loaded when the check takes place. Still working to fix!
I'm sure there is a neater way, but this seems to work...