function RR_import_level(%name){
%file = new FileObject();
%file.openForRead("Add-ons/RockRaiders/Levels/" @ %name @ ".txt");
if(isobject($RR_LEVEL)){
$RR_LEVEL.delete();
RR_echo("level data deleted");
}
$RR_LEVEL = new ScriptObject("RR LEVEL")
{
class = "RR_LEVELso";
};
%curz=1;
%curx=0;
%cury=0;
echo("begginning" SPC %file.isEOF());
while(!%file.isEOF()){
%line=%file.readline();
echo(%line);
%firstword=firstword(%line);
if(%firstword$="Z"){
%curz=restwords(%line);
%curx=0;
%cury=0;
}
if(%firstword$="L"){
%seq=restwords(%line);
RR_parseleveldata(%curx,%cury,%curz,%seq);
%curx=0;
%cury++;
}
echo(%curx SPC %cury SPC %curz);
}
%file.close();
%file.delete();
}
function RR_parseleveldata(%curx,%cury,%curz,%seq){
%data="";
%c=0;
%I=0;
while(%I==0){
%data=getsubstr(%seq,%c,1);
%c++;
echo(%data);
if(%data$="&"){
%I=1;
}
%what=$RR_level_object[%data];
echo(%what);
if(%what!$="NONE"&&%what!$=""){
$RR_LEVEL.data[%curx,%cury,%curz]=%what;
RR_create_object(%what,%curx,%cury,%curz,0);
}
%curx++;
}
}
// grid = 6 by 6 by 12
function RR_create_object(%objectname,%x,%y,%z,%nofloor)
{
%real="static" @ %objectname;
%realloc= %x*6 SPC %y*6 SPC %z*12;
%obj = new StaticShape()
{
position = %realloc;
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = %real;
};
if(strlwr(%objectname) !$= "rrfloorobject"&&!%nofloor){
%floor = new StaticShape()
{
position = %realloc;
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "staticRRfloorobject";
};
}
%obj.objecttype=%objectname;
%obj.POS=%x SPC %y SPC %z;
$RR_LEVEL.objects[%x,%y,%z]=%obj;
schedule(1000,0,"RR_rotate_sched",%obj,%x,%y,%z);
return %obj;
}
function RR_rotate_sched(%obj,%x,%y,%z){
if(isobject(%obj)){
if($RR_level_object_directional[%obj.objecttype]){
RR_object_directional_rotate(%obj);
}
%on=$RR_LEVEL.data[%x+1,%y,%z];
if($RR_level_object_directional[%on]){
RR_object_directional_rotate($RR_LEVEL.objects[%x+1,%y,%z]);
}
%on=$RR_LEVEL.data[%x-1,%y,%z];
if($RR_level_object_directional[%on]){
RR_object_directional_rotate($RR_LEVEL.objects[%x-1,%y,%z]);
}
%on=$RR_LEVEL.data[%x,%y+1,%z];
if($RR_level_object_directional[%on]){
RR_object_directional_rotate($RR_LEVEL.objects[%x,%y+1,%z]);
}
%on=$RR_LEVEL.data[%x,%y-1,%z];
if($RR_level_object_directional[%on]){
RR_object_directional_rotate($RR_LEVEL.objects[%x,%y-1,%z]);
}}
}
function servercmdcreateRRobject(%client,%objectname,%x,%y,%z){
%objectname = "RR" @ %objectname @ "object";
RR_create_object(%objectname,%x,%y,%z,0);
messageclient(%client,'',"You created a" SPC %objectname SPC "at" SPC %x SPC %y SPC %z @ ".");
}
function RR_object_directional_rotate(%object){
//lets find out whats on what sides
%firstrotate=%object.firstrotate;
%x=getword(%object.POS,0);
%y=getword(%object.POS,1);
%z=getword(%object.POS,2);
%flooramount=0;
%on=$RR_LEVEL.data[%x+1,%y,%z];
if($RR_level_object_floor[%on]){
%xplus=1;//floor on x+
%flooramount++;
}
%on=$RR_LEVEL.data[%x-1,%y,%z];
if($RR_level_object_floor[%on]){
%xminus=1;//floor on x-
%flooramount++;
}
%on=$RR_LEVEL.data[%x,%y+1,%z];
if($RR_level_object_floor[%on]){
%yplus=1;//floor on y+
%flooramount++;
}
%on=$RR_LEVEL.data[%x,%y-1,%z];
if($RR_level_object_floor[%on]){
%yminus=1;//floor on y-
%flooramount++;
}
echo("X+" SPC %xplus @ "." SPC "X-" SPC %xminus @ "." SPC "Y+" SPC %Yplus @ "." SPC "Y-" SPC %yminus @ "." SPC "floor amount:" @ %flooramount);
if(%flooramount==1){
if(%yplus){
%object.rotation="1 0 0 0";
}
if(%yminus){
%object.rotation="0 0 1 180";
}
if(%xminus){
%object.rotation="0 0 -1 90";
}
if(%xplus){
%object.rotation="0 0 1 90";
}
}
if(%flooramount==2){
if(%xminus&&%yplus){
%objecttype = %object.objecttype;
%object.delete();
%object = RR_create_object($RR_level_object_corner_out[%objecttype],%x,%y,%z,1);
%object.rotation="0 0 1 90";
%hasoutcornered=1;
}
if(%yminus&&%xplus&&!%hasoutcornered){
%objecttype = %object.objecttype;
%object.delete();
%object = RR_create_object($RR_level_object_corner_out[%objecttype],%x,%y,%z,1);
%object.rotation="0 0 -1 90";
%hasoutcornered=1;
}
if(%xminus&&%yminus&&!%hasoutcornered){
%objecttype = %object.objecttype;
%object.delete();
%object = RR_create_object($RR_level_object_corner_out[%objecttype],%x,%y,%z,1);
%object.rotation="0 0 1 180";
%hasoutcornered=1;
}
if(%xplus&&%yplus&&!%hasoutcornered){
%objecttype = %object.objecttype;
%object.delete();
%object = RR_create_object($RR_level_object_corner_out[%objecttype],%x,%y,%z,1);
%object.rotation="1 0 0 0";
%hasoutcornered=1;
}
}
if(%flooramount==0){
%on=$RR_LEVEL.data[%x+1,%y+1,%z];
if($RR_level_object_floor[%on]){
%xplusyplus=1;//floor on x+
}
%on=$RR_LEVEL.data[%x-1,%y-1,%z];
if($RR_level_object_floor[%on]){
%xminusyminus=1;//floor on x-
}
%on=$RR_LEVEL.data[%x-1,%y+1,%z];
if($RR_level_object_floor[%on]){
%yplusxminus=1;//floor on y+
}
%on=$RR_LEVEL.data[%x+1,%y-1,%z];
if($RR_level_object_floor[%on]){
%yminusxplus=1;//floor on y-
}
if(%yplusxminus){
%objecttype = %object.objecttype;
%object.delete();
%object = RR_create_object($RR_level_object_corner_in[%objecttype],%x,%y,%z,1);
%object.rotation="0 0 1 90";
%hasincornered=1;
}
if(%yminusxplus&&!%hasincornered){
%objecttype = %object.objecttype;
%object.delete();
%object = RR_create_object($RR_level_object_corner_in[%objecttype],%x,%y,%z,1);
%object.rotation="0 0 -1 90";
%hasincornered=1;
}
if(%xminusyminus&&!%hasincornered){
%objecttype = %object.objecttype;
%object.delete();
%object = RR_create_object($RR_level_object_corner_in[%objecttype],%x,%y,%z,1);
%object.rotation="0 0 1 180";
%hasincornered=1;
}
if(%xplusyplus&&!%hasincornered){
%objecttype = %object.objecttype;
%object.delete();
%object = RR_create_object($RR_level_object_corner_in[%objecttype],%x,%y,%z,1);
%object.rotation="1 0 0 0";
%hasincornered=1;
}
}
if(%flooramount==3&&!%firstrotate){
%object.delete();
//surrounded on all sides by floor, collaspes.
RR_rotatesurrounding(%x,%y,%z);
}else
if(%flooramount==4&&!%firstrotate){
%object.delete();
//surrounded on all sides by floor, collaspes.
RR_rotatesurrounding(%x,%y,%z);
}
%object.firstrotate=1;
}
function RR_rotatesurrounding(%x,%y,%z){
%on=$RR_LEVEL.data[%x+1,%y,%z];
if($RR_level_object_directional[%on]){
RR_object_directional_rotate($RR_LEVEL.objects[%x+1,%y,%z]);
}
%on=$RR_LEVEL.data[%x-1,%y,%z];
if($RR_level_object_directional[%on]){
RR_object_directional_rotate($RR_LEVEL.objects[%x-1,%y,%z]);
}
%on=$RR_LEVEL.data[%x,%y+1,%z];
if($RR_level_object_directional[%on]){
RR_object_directional_rotate($RR_LEVEL.objects[%x,%y+1,%z]);
}
%on=$RR_LEVEL.data[%x,%y-1,%z];
if($RR_level_object_directional[%on]){
RR_object_directional_rotate($RR_LEVEL.objects[%x,%y-1,%z]);
}
}
Can anyone understand it enough to help us?
The issue is that rotation is severely screwed up and most of the time the pieces disappear or don't rotate at all. There is no degree of randomness as it screws up the same way each time.
You want to direct your attention here:
function RR_object_directional_rotate(%object){
I don't see help as being a weakness, but I find myself doubting that I will get help. If you need a console log with various data collected from echos I have scattered throughout, I will generate one immediately.