From af3f5ef954e820de55cfa7e00c778f8dbe4e1518 Mon Sep 17 00:00:00 2001 From: MarioE Date: Tue, 3 Jun 2014 15:44:48 -0400 Subject: [PATCH] Add a /wind command for changing the wind speed --- TShockAPI/Commands.cs | 41 +++++++++++++++++++++++++--------------- TShockAPI/Permissions.cs | 3 +++ 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 1d9af36e..fbc5113b 100755 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -466,6 +466,10 @@ namespace TShockAPI { HelpText = "Sets the world time." }); + add(new Command(Permissions.wind, Wind, "wind") + { + HelpText = "Changes the wind speed." + }); add(new Command(Permissions.worldinfo, WorldInfo, "world") { HelpText = "Shows information about the current world." @@ -656,21 +660,6 @@ namespace TShockAPI return ret; } - private static char GetEscape(char c) - { - switch (c) - { - case '\\': - return '\\'; - case '"': - return '"'; - case 't': - return '\t'; - default: - return c; - } - } - private static bool IsWhiteSpace(char c) { return c == ' ' || c == '\t' || c == '\n'; @@ -3221,6 +3210,28 @@ namespace TShockAPI } } + private static void Wind(CommandArgs args) + { + if (args.Parameters.Count != 1) + { + args.Player.SendErrorMessage("Invalid syntax! Proper syntax: /wind "); + return; + } + + float speed; + if (!float.TryParse(args.Parameters[0], out speed)) + { + args.Player.SendErrorMessage("Invalid wind speed!"); + return; + } + + Main.windSpeed = speed; + Main.windSpeedSet = speed; + Main.windSpeedSpeed = 0f; + TSPlayer.All.SendData(PacketTypes.WorldInfo); + TSPlayer.All.SendInfoMessage("{0} changed the wind speed to {1}.", args.Player.Name, speed); + } + #endregion Time/PvpFun Commands #region Region Commands diff --git a/TShockAPI/Permissions.cs b/TShockAPI/Permissions.cs index ccb7803f..b31c15d3 100644 --- a/TShockAPI/Permissions.cs +++ b/TShockAPI/Permissions.cs @@ -284,6 +284,9 @@ namespace TShockAPI [Description("User can turn on or off the rain.")] public static readonly string rain = "tshock.world.rain"; + [Description("User can modify the wind.")] + public static readonly string wind = "tshock.world.wind"; + // Non-grouped [Description("User can clear items or projectiles.")]