Minecraft-Console-Client/MinecraftClient/config/sample-script-extended.cs
ORelio f076e1f512 Add argument passing for C# scripts
script files with spaces in filename will need double quotes when
calling them eg /script "my script.txt" instead of /script my script.txt
2015-06-25 12:12:59 +02:00

35 lines
No EOL
815 B
C#

//MCCScript 1.0
/* This script demonstrates how to use methods and arguments */
string text = "hello";
if (args.Length > 0)
text = args[0];
for (int i = 0; i < 5; i++)
{
int count = GetVarAsInt("test") + 1;
SetVar("test", count);
SendHelloWorld(count, text);
SleepBetweenSends();
}
//MCCScript Extensions
/* Here you can define methods for use into your script */
void SendHelloWorld(int count, string text)
{
/* Warning: Do not make more than one server-related call into a method
* defined as a script extension eg SendText or switching servers,
* as execution flow is not managed in the Extensions section */
SendText("Hello World no. " + count + ": " + text);
}
void SleepBetweenSends()
{
LogToConsole("Sleeping for 5 seconds...");
Thread.Sleep(5000);
}