smp-datapack/src/database/database.jmc
themodernhakr 5d62488695
All checks were successful
Deploy datapack to dev / Build (push) Successful in 7s
Edit test and add print for debug
2025-03-22 21:27:28 -05:00

54 lines
1.2 KiB
Plaintext

@lazy //takes name of table. metadata must already exist.
function createTable(name) {
logger(2, database.createTable, "Creating table: $name");
Array.forEach(
"ferdinland:ferdinland",
"database.tables.$name.fields",
()=>{tellraw @a {"storage":"ferdinland:ferdinland", "nbt":"database.tables.$name.fields[0]"};}
);
}
class database {
@add(__load__)
function __init__() {}
@add(this.__init__)
function schema() {}
@add(this.schema)
function tables.myTable() {
::database.tables.myTable.name = "myTable";
::database.tables.myTable.fields = ["one", "two"];
createTable(myTable);
}
}
class database.benchmark {
function arrayTest1.setup() {
::database.test.arrayTest1.array = [];
for ($i=0;$i<=500;$i++) {
$thisI = $i;
$thisI += 1;
::database.test.arrayTest1.array << {id: $thisI, string: "array item &<$i>"};
}
}
function arrayTest1.print() {
tellraw @a {"nbt":"database.test.arrayTest1.array","storage":"ferdinland:ferdinland"};
}
function arrayTest1.clean() {
::database.test.arrayTest1.array.del();
}
function arrayTest1.run() {
}
function arrayTest2.setup() {
::database.test.arrayTest2.arrays = [];
::database.test.arrayTest2.index = [];
}
function arrayTest2.clean() {
}
function arrayTest2.run() {
}
}