mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Update bot making documentation in ChatBot.cs
+ Add GetVarAsDouble in Script API (See #200)
This commit is contained in:
parent
2a07fbbae6
commit
f5575d7f8b
3 changed files with 24 additions and 11 deletions
|
|
@ -303,6 +303,21 @@ namespace MinecraftClient
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get a global variable by name, as a double
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="varName">Name of the variable</param>
|
||||||
|
/// <returns>Value of the variable as double, or 0 if no variable or not a number</returns>
|
||||||
|
public double GetVarAsDouble(string varName)
|
||||||
|
{
|
||||||
|
if (GetVar(varName) is double)
|
||||||
|
return (double)GetVar(varName);
|
||||||
|
double result;
|
||||||
|
if (double.TryParse(GetVarAsString(varName), out result))
|
||||||
|
return result;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get a global variable by name, as a boolean
|
/// Get a global variable by name, as a boolean
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -11,19 +11,15 @@ namespace MinecraftClient
|
||||||
///
|
///
|
||||||
/// Welcome to the Bot API file !
|
/// Welcome to the Bot API file !
|
||||||
/// The virtual class "ChatBot" contains anything you need for creating chat bots
|
/// The virtual class "ChatBot" contains anything you need for creating chat bots
|
||||||
/// Inherit from this class while adding your bot class to the folder "ChatBots".
|
/// Inherit from this class while adding your bot class to the "ChatBots" folder.
|
||||||
/// Override the methods you want for handling events: Initialize, Update, GetText.
|
/// Override the methods you want for handling events: Initialize, Update, GetText.
|
||||||
/// Once your bot is created, read the explanations below to start using it in the MinecraftClient app.
|
|
||||||
///
|
///
|
||||||
/// Pieces of code to add in other parts of the program for your bot. Line numbers are approximative.
|
/// For testing your bot you can add it in McTcpClient.cs (see comment at line ~119).
|
||||||
/// Settings.cs:73 | public static bool YourBot_Enabled = false;
|
/// Your bot will be loaded everytime MCC is started so that you can test/debug.
|
||||||
/// Settings.cs:74 | private enum ParseMode { /* [...] */, YourBot };
|
///
|
||||||
/// Settings.cs:106 | case "yourbot": pMode = ParseMode.YourBot; break;
|
/// Once your bot is fully written and tested, you can export it a standalone script.
|
||||||
/// Settings.cs:197 | case ParseMode.YourBot: switch (argName.ToLower()) { case "enabled": YourBot_Enabled = str2bool(argValue); break; } break;
|
/// This way it can be loaded in newer MCC builds, without modifying MCC itself.
|
||||||
/// Settings.cs:267 | + "[YourBot]\r\n" + "enabled=false\r\n"
|
/// See config/sample-script-with-chatbot.cs for a ChatBot script example.
|
||||||
/// McTcpClient:110 | if (Settings.YourBot_Enabled) { handler.BotLoad(new ChatBots.YourBot()); }
|
|
||||||
/// Here your are. Now you will have a setting in MinecraftClient.ini for enabling your brand new bot.
|
|
||||||
/// Delete MinecraftClient.ini to re-generate it or add the lines [YourBot] and enabled=true to the existing one.
|
|
||||||
///
|
///
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,8 @@ namespace MinecraftClient
|
||||||
if (Settings.ScriptScheduler_Enabled) { BotLoad(new ChatBots.ScriptScheduler(Settings.ExpandVars(Settings.ScriptScheduler_TasksFile))); }
|
if (Settings.ScriptScheduler_Enabled) { BotLoad(new ChatBots.ScriptScheduler(Settings.ExpandVars(Settings.ScriptScheduler_TasksFile))); }
|
||||||
if (Settings.RemoteCtrl_Enabled) { BotLoad(new ChatBots.RemoteControl()); }
|
if (Settings.RemoteCtrl_Enabled) { BotLoad(new ChatBots.RemoteControl()); }
|
||||||
if (Settings.AutoRespond_Enabled) { BotLoad(new ChatBots.AutoRespond(Settings.AutoRespond_Matches)); }
|
if (Settings.AutoRespond_Enabled) { BotLoad(new ChatBots.AutoRespond(Settings.AutoRespond_Matches)); }
|
||||||
|
//Add your ChatBot here by uncommenting and adapting
|
||||||
|
//BotLoad(new ChatBots.YourBot());
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue