Blockland Forums > Modification Help
Creating a datablock using a variable name
DYLANzzz:
Neither of these work. They both cause syntax errors when the game is starting up.
--- Code: ---eval("datablock ShapeBaseImageData("@%hatNameNoSpace@")
{
shapeFile = $CobS::HatsFP@%fileName;
emap = true;
mountPoint = $HeadSlot;
offset = \"0 0 0\";
eyeOffset = \"0 0 0.4\";
rotation = eulerToMatrix(\"0 0 0\");
scale = \"1 1 1\";
doColorShift = false;
colorShiftColor = \"1.000 1.000 1.000 1.000\";
};");
--- End code ---
--- Code: ---datablock ShapeBaseImageData(%hatNameNoSpace)
{
shapeFile = $CobS::HatsFP@%fileName;
emap = true;
mountPoint = $HeadSlot;
offset = "0 0 0";
eyeOffset = "0 0 0.4";
rotation = eulerToMatrix("0 0 0");
scale = "1 1 1";
doColorShift = false;
colorShiftColor = "1.000 1.000 1.000 1.000";
};
--- End code ---
This on is unreadable but works :/
--- Code: ---eval("datablock ShapeBaseImageData("@%hatNameNoSpace@"){ shapeFile = $CobS::HatsFP@%fileName; emap = true; mountPoint = $HeadSlot; offset = \"0 0 0\"; eyeOffset = \"0 0 0.4\"; rotation = eulerToMatrix(\"0 0 0\"); scale = \"1 1 1\"; doColorShift = false; colorShiftColor = \"1.000 1.000 1.000 1.000\"; };");
--- End code ---
Is there one that's readable AND works? :D
FFSO:
if you don't use eval and actually write it in a .cs file and save it in a folder in Add-Ons it will work as the readable version.
Brian Smithers:
Dont use eval
--- Code: ---datablock ShapeBaseImage(DummyHatName)
{
shapeName = $CobS::HatsFP@%filename;
emap = true;
mountPoint = $HeadSlot;
offset = "0 0 0";
eyeOffset = "0 0 0.4";
rotation = eulerToMatrix("0 0 0");
scale = "1 1 1";
doColorshift = false;
colorShiftColor = "1 1 1 1";
};
DummyHatName.setName(%hatNameNoSpace);
--- End code ---
:)
DYLANzzz:
The second code snippet doesnt use eval and gave me a syntax error
FFSO:
Is %filename ever defined in the script?