mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
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
This commit is contained in:
parent
e29b4ee545
commit
f076e1f512
3 changed files with 61 additions and 10 deletions
|
|
@ -1,12 +1,17 @@
|
|||
//MCCScript 1.0
|
||||
|
||||
/* This script demonstrates how to add fields and methods */
|
||||
/* 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);
|
||||
SendHelloWorld(count, text);
|
||||
SleepBetweenSends();
|
||||
}
|
||||
|
||||
|
|
@ -14,13 +19,13 @@ for (int i = 0; i < 5; i++)
|
|||
|
||||
/* Here you can define methods for use into your script */
|
||||
|
||||
void SendHelloWorld(int count)
|
||||
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);
|
||||
SendText("Hello World no. " + count + ": " + text);
|
||||
}
|
||||
|
||||
void SleepBetweenSends()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue