I'm having some trouble getting the DLL to actually work. I might have to put the project on hold, as I have other things I need to do at the moment. Here's what I have so far, if anyone want to pick up where I left off
if (forceRequiredAddOn("Server_EnvironmentZones") == $Error::AddOn_NotFound) {
error("Server_EnvironmentZones not found! Height Environments will not be loaded");
return;
}
function HEN::loadEnv(%fn) {
// TODO
}
function GameConnection::HEN_updateEnv(%this) {
%z = getWord(%client.position, 2);
if (%z < $HEN::dist)
%newEnv = $HEN::caveEnv;
else if (%z >= $HEN::dist && %z < 2 * $HEN::dist)
%newEnv = $HEN::groundEnv;
else if (%z >= 2 * $HEN::dist)
%newEnv = $HEN::spaceEnv;
if (%client.HEN_curEnv != %newEnv) {
%client.popEnvironment(%client.HEN_curEnv);
%client.pushEnvironment(%newEnv);
%client.HEN_curEnv = %newEnv;
}
}
function HEN_updateLoop() {
%clientCnt = ClientGroup.getCount()
for(%i = 0; %i < %clientCnt; %i++) {
%client = ClientGroup.getObject(%i);
%client.HEN_updateEnv();
}
schedule($HEN::elapse * 1000, 0, HEN_updateLoop);
}
package HeightEnvironmentPackage
{
GameConnection::onClientEnterGame(%this) {
Parent::onClientEnterGame(%this);
%this.HEN_curEnv = $caveEnv;
}
GameConnection::spawnPlayer(%this) {
Parent::spawnPlayer(%this);
%this.HEN_updateEnv();
}
};
activatePackage(HeightEnvironmentPackage);
$caveEnv = HEN::loadEnv($HEN::envPath @ "cave.env");
$groundEnv = HEN::loadEnv($HEN::envPath @ "ground.env");
$spaceEnv = HEN::loadEnv($HEN::envPath @ "space.env");
// Set preferences
if(forceRequiredAddOn("System_BlocklandGlass") != $Error::AddOn_NotFound) {
// Blockland Glass support
registerPref("Height Environments", "General", "Distance Between Environments", "num", "$HEN::dist", "Server_HeightEnvironments", 32, "0 1000 1", "", 0, 0, 0);
registerPref("Height Environments", "General", "Time Between Updates (in seconds)", "num", "$HEN::elapse", "Server_HeightEnvironments", 2, "0 10 1", "", 0, 0, 0);
}
if ($HEN::dist $= "")
$HEN::dist = 32;
if ($HEN::elapse $= "")
$HEN::elapse = 2;
// Start loop
HEN_updateLoop();
I haven't tested anything yet, as I haven't gotten the DLL to work. Also, as you can see in the code, I'm still not sure how to properly handle loading in environments. For one thing, I'm not sure whether to use the files generate by saveEnvironment() or the .ez file generated by exportEnvironmentZones(). The latter seems like the best option, but I haven't messed with it much yet.