-
Notifications
You must be signed in to change notification settings - Fork 0
How to
Classes references:
SteveSharp.Project
At your Program class, use the using SteveSharp
to create a SteveSharp reference, then create a Project
reference with a name, for example:
using SteveSharp;
namespace Example {
public class Program {
public static void Main() {
Project p = new Project();
}
}
}
Then, provide this arguments:
name
: The output folder name for the project, this can be used as a relative directory.
description
: This description is the pack description for the pack.mcmeta
metadata file.
id
: This is the namespace that will be created for the datapack.
pack_format
: The pack format for the pack.mcmeta
metadata file.
load
: The function name for the Minecraft's load.json
tag file. This is the load function for the project.
main
: The function name for the Minecraft's tick.json
tag file. This is the main function for the project.
functions
: All your functions for your datapack!
matrix
: A matrix of functions, if you want to create sequences of functions, be creative!
using SteveSharp;
namespace Example {
public class Program {
public static void Main() {
Project p = new Project(
name: "SteveSharp Project",
description: "This is a SteveSharp Project",
id: "stevesharp",
pack_format: 15,
load: new Function(
name: "stevesharp:load",
body: new List<string> {}
)
main: new Function(
name: "stevesharp:load",
body: new List<string> {}
),
functions: new List<Function> {},
matrix: new List<List<Function>> {}
);
}
}
}
Now you have your project ready for code!
Classes references:
SteveSharp.Function
Now that you have your project code ready, let's create a function.
To create a new function, the project supports function nesting. For example, the parameter "load" of the project is a function.
First, provide the name
field for the function, for example: "stevesharp:load"
Project p = new Project(
name: "SteveSharp Project",
description: "This is a SteveSharp Project",
id: "stevesharp",
pack_format: 15,
load: new Function(
name: "stevesharp:load",
...
And then, in the body
parameter of the function, provide a list of strings, because inside of the function, we are writing lines of code, which are strings.
Project p = new Project(
name: "SteveSharp Project",
description: "This is a SteveSharp Project",
id: "stevesharp",
pack_format: 15,
load: new Function(
name: "stevesharp:load",
body: List<string> {}
)
);
Pro Tip: You can create more functions in the functions
field of your project!
Project p = new Project(
...
functions: new List<Function> {
new Function(
name: "stevesharp:my_function",
body: new List<string> {
Chat.Say("Hello World!")
}
)
}
);
Pro Tip: You can create a matrix of functions, or a sequence of functions!
Project p = new Project(
...
matrix: new List<List<Function>> {
For.Functions(
from: 1,
to: 15,
block: (i) => new Function(
name: "stevesharp:my_function_"+i,
body: new List<string> {
Chat.Say("Command for function "+i)
}
)
)
}
);
Classes references:
SteveSharp.Function
SteveSharp.Core.Execute
SteveSharp.Core.Entity
SteveSharp.Core.Chat
You have created a function, now you will write your commands in a function.
How? In the body you can provide all the commands you want!
...
new Function(
name: "stevesharp:my_new_function",
body: new List<string> {
Chat.Say("My first function!")
}
)
);
There are so much methods to write your commands, but you will need to import the SteveSharp.Core
using
For example:
execute as @a at @s run say Hello World!
execute as @a at @s run kill @s
You will write something like this:
...
new Function(
name: "stevesharp:my_commands",
body: new List<string> {
Execute.Write(
Execute.Asat(Entity.Everyone()),
new string[] {
Entity.Kill(Entity.Self())
}
)
}
)
Finally, the entire code will look something like this:
using SteveSharp;
using SteveSharp.Core;
class Program {
static void Main() {
new Project(
name: "SteveSharp Project",
description: "This is a SteveSharp Project",
id: "stevesharp",
pack_format: 15,
load: new Function(
name: "stevesharp:load",
body: new List<string>{}
),
main: new Function(
name: "stevesharp:main",
body: new List<string>{}
),
functions: new List<Function> {
new Function(
name: "stevesharp:my_function",
body: new List<string> {
Chat.Say("Hello World!")
}
),
new Function(
name: "stevesharp:my_commands",
body: new List<string> {
Execute.Write(
Execute.Asat(Entity.Everyone()),
new string[] {
Entity.Kill(Entity.Self())
}
)
}
)
},
matrix: new List<List<Function>> {
For.Functions(
from: 1,
to: 15,
block: (i) => new Function(
name: "stevesharp:my_function_"+i,
body: new List<string> {
Chat.Say("Command for function "+i)
}
)
)
}
);
}
}
Now you have learned SteveSharp!