################################################################################ # # # M o b S p a w n L i m i t M a n a g e r # # # # Author: |Anthony| # # Version: 0.1 # # dScript Version: 0.9.4-b1518 # # # # # # A system for controlling how many mobs are able to spawn per chunk in each # # world. Will autogenerate the default config file on first run. Read the help # # file in game with /mslimit # # # # Permission: denizen.mslimit # # # # Features a dynamic command handler. Command arguments can be supplied in any # # order. Syntax checking and error handling included. # # # # Example: Set the ambient mob type limit to 3 in the world named World # # /mslimit -s -w World -t ambient -l 3 # # # ################################################################################ 'MobSpawnManager_Configurations': type: task debug: false # These are the default values. You can edit them... but it's all # configurable from in game so why bother. ambient: 5 animal: 15 monster: 30 water_animal: 2 ################################################################################ # # This is the meat and potatoes of this script. You really shouldn't touch # ANYTHING beyond this point unless you really know wtf you're doing! # 'MobSpawnManagerTasks': type: task debug: false script: - narrate "HEY! Why does monkeybot give me a warning if I don<&sq>t have a script subscript path!?!" config: - define readID 'MobSpawnManager' - define basePath '_Configurations' - define scriptPath '' - yaml 'load:' 'id:' - define keylist '].list_keys[].exclude[type|debug|script]>' - announce to_console "MobSpawnManager<&co> Generating default config file..." - yaml create 'id:%readID%' - foreach { - define world - announce to_console "MobSpawnManager<&co> Found world " - foreach %keylist% { - define key %value% - define entry '' - yaml 'write:%readID%..' 'value:%entry%' 'id:%readID%' - adjust %key%_spawn_limit:%entry% } } - yaml 'savefile:%readID%/config.yml' 'id:%readID%' - yaml unload 'id:%readID%' - announce to_console "MobSpawnManager<&co> Done!" - yaml unload 'id:%basePath%' load: - announce to_console "MobSpawnManager<&co> Loading config file..." - define readID 'MobSpawnManager' - yaml 'load:%readID%/config.yml' 'id:%readID%' - define worlds '' - foreach %worlds% { - define world %value% - define types '' - foreach %types% { - define type %value% - define limit '' - adjust %type%_spawn_limit: } } - announce to_console "MobSpawnManager<&co> Done!" set: - define worlds - if %world% != null { - if !]> { - narrate "<&4><&l>ERROR<&co><&r> <&a> <&b>does not exist" - queue stop } } else { - narrate "<&4><&l>ERROR<&co><&r> <&b>Must specify a world" - narrate format:CmdSynFormat "/mslimit -w \<<\>world\<>\>" - queue stop } - define types 'ambient|animal|monster|water_animal' - if %type% != null { - if !]> { - narrate "<&4><&l>ERROR<&co><&r> <&a> <&b>is not a valid type" - queue stop } } else { - narrate "<&4><&l>ERROR<&co><&r> <&b>Must specify a type" - narrate format:CmdSynFormat "/mslimit -t \<<\>type\<>\>" - queue stop } - if %limit% != null { - if ! { - narrate "<&4><&l>ERROR<&co><&r> <&a> <&b>is not a valid number" - queue stop } - define limit } else { - narrate "<&4><&l>ERROR<&co><&r> <&b>Must specify a limit" - narrate format:CmdSynFormat "/mslimit -l \<<\>limit\<>\>" - queue stop } - define readID 'MobSpawnManager' - yaml 'load:%readID%/config.yml' 'id:%readID%' - yaml 'write:%readID%..' 'value:%limit%' 'id:%readID%' - adjust %type%_spawn_limit: - yaml 'savefile:%readID%/config.yml' 'id:%readID%' - yaml unload 'id:%readID%' - narrate "<&b> <&a>Spawn Limit set to <&b>%limit%<&a> for <&a><&b>." list: - define worlds - if %world% != null { - if !]> { - narrate "<&4><&l>ERROR<&co><&r> <&a> <&b>does not exist" - queue stop } - define worlds } - define types 'ambient|animal|monster|water_animal' - if %type% != null { - if !]> { - narrate "<&4><&l>ERROR<&co><&r> <&a> <&b>is not a valid type" - queue stop } - define types } - foreach { - define world %value% - narrate "" - narrate "<&e><&l><&r><&6> Spawn Limits" - foreach { - narrate "<&sp><&sp><&sp><&b><&co> <&a>_spawn_limit>" } } - narrate "" help: - narrate "" - narrate "<&b>========== <&a>MobSpawnLimit Help <&b>==========" - narrate "" - narrate "A system for controlling how many mobs are able to spawn per chunk in each world." - narrate "" - narrate "" - narrate "<&b>Setting Limits" - narrate "<&sp>Sets the mobspawn limit. Must specify a valid world, type, and number" - narrate "<&sp><&sp><&sp><&e>/mslimit -s" - narrate "<&sp><&sp><&sp><&e>/mslimit --set" - narrate "" - narrate "<&b>Listing Limits" - narrate "<&sp>Shows a list of current limits. Can be filtered by world and/or type" - narrate "<&sp><&sp><&sp><&e>/mslimit -ls" - narrate "<&sp><&sp><&sp><&e>/mslimit --list" - narrate "" - narrate "<&b>Options" - narrate "<&sp><&a>World" - narrate "<&sp><&sp><&sp><&e>-w \" - narrate "<&sp><&a>Type" - narrate "<&sp><&sp><&sp><&e>-t \" - narrate "<&sp><&sp><&sp>Valid types<&co> <&a>ambient animal monster water_animal" - narrate "<&sp><&a>Limit" - narrate "<&sp><&sp><&sp><&e>-l \" - narrate "<&sp><&a>Reset<&f> - Reset all worlds to default limits" - narrate "<&sp><&sp><&sp><&e>--reset" - narrate "<&sp><&a>Reload<&f> - Reloads the config file" - narrate "<&sp><&sp><&sp><&e>--reload" - narrate "" - narrate format:CmdSynFormat "/mslimit <&6>\<<\><&e>--set / -s<&6>\<>\> \<&lb\><&e>-w worldname -t type -l limit<&6>\<&rb\>" - narrate format:CmdSynFormat "/mslimit <&6>\<<\><&e>--list / -ls<&6>\<>\> \<<\><&e>-w worldname -t type -l limit<&6>\<>\>" - narrate "" ################################################################################ # # Handles the commands and server start # 'MobSpawnManagerEvents': type: world debug: true events: on mslimit command: # The command handler. Accepts the command and passes the info to the task scripts - if ! queue stop - determine passively fulfilled - define reset '' - define reload '' - define list ']:true||]:true||false>>' - define set ']:true||]:true||false>>' - define world ']:].escaped> || null>' - define type ']:].escaped> || null>' - define limit ']:].escaped> || null>' - if %list% == true { - inject s@MobSpawnManagerTasks p:list - queue stop } - if %set% == true { - inject s@MobSpawnManagerTasks p:set - queue stop } - if %reset% == true { - inject s@MobSpawnManagerTasks p:config - queue stop } - if %reload% == true { - inject s@MobSpawnManagerTasks p:load - queue stop } - if { - inject s@MobSpawnManagerTasks p:help - queue stop } - inject s@MobSpawnManagerTasks p:help on server start: # Checks if the config file exists on server start and reads or generates it. - define readID 'MobSpawnManager' - if { - run s@MobSpawnManagerTasks p:load delay:2s } else { - run s@MobSpawnManagerTasks p:config delay:2s }