I've spent hours trying to figure this out only to come to the conclusion it's not possible. I've tried the obvious stateTimeoutValue[x] edits in-game, etc.
Right now, what I'm doing, is dynamically creating shapeBaseImageData datablocks when the server starts to use at a later point when they're needed, and modifying HammerItem to use the image I want.
They create themselves fine, but it's tedious and the hammer just hits my face when using the modified images.
I can resort to having a click/activate-only method but I'd rather have an item because it's apparently confusing to Blockland players. It looks less lazy too.
function convertTempoToMS(%tempo) {
return 60000/%tempo;
}
function initPickaxes() {
%file = new FileObject();
if(!isFile("config/server/MinerTeams/loops.db")) {
%file.openForRead("config/server/MinerTeams/loops/loops.db");
} else {
warn("NO LOOP DATABASE FOUND.");
%file.delete();
return;
}
%tempScript = new FileObject();
while(!%file.isEOF()) {
%data = %file.readLine();
%tempo = getField(%data, 1);
%tempoMS = convertTempoToMS(%tempo);
%datablock = "PickaxeImage_" @ strReplace(%tempo, ".", "_");
if(!isObject(%datablock)) {
echo("Creating dynamic datablock for tempo of" SPC %tempo @ "BPM...");
%tempScript.openForWrite("config/server/MinerTeams/temp.cs");
// this is just too much to eval fml
// dynamic item images when
%tempScript.writeLine("datablock shapeBaseImageData(" @ %datablock @ " : hammerImage) {");
%tempScript.writeLine("stateTimeoutValue[1] = 0;");
%tempScript.writeLine("stateTimeoutValue[2] = 0.01;");
%tempScript.writeLine("stateTimeoutValue[3] = " @ ((%tempoMS/2)/1000)-0.01 @ ";");
%tempScript.writeLine("stateTimeoutValue[4] = 0;");
%tempScript.writeLine("stateTimeoutValue[5] = " @ ((%tempoMS/2)/1000)-0.01 @ ";");
%tempScript.writeLine("stateTimeoutValue[6] = 0;");
%tempScript.writeLine("rotation = eulerToMatrix(\"0 0 0\");");
%tempScript.writeLine("mountPoint = 0;");
%tempScript.writeLine("offset = \"0 0 0\";");
%tempScript.writeLine("emap = true;");
%tempScript.writeLine("eyeOffset = \"0 0 0\";");
%tempScript.writeLine("};");
%tempScript.writeLine("function " @ %datablock @ "::onHitObject(%this, %obj, %slot, %col, %d, %e, %f) {");
%tempScript.writeLine("hitObject(%this, %obj, %slot, %col, %d, %e, %f);");
%tempScript.writeLine("}");
%tempScript.close();
exec("config/server/MinerTeams/temp.cs");
}
}
%tempScript.delete();
%file.close();
%file.delete();
}
You still have to go out of the way to remove the old hammer from everyone's inventory, then add it back.
Is there a better way to do this or does TGE suck this bad?