Game Development Community

Help!! I just scripted myself into a corner.

by Ezra · in Torque Game Builder · 02/07/2006 (3:26 pm) · 3 replies

Ok, I did something kind of dumb.
I've spent the last few days scripting an additional tool to the level editor, it allows me to place sprites for enemies, and then give each sprite it's own set of path points, and each pathpoint can further have it's own set of corner points. (the corner points are generated using quadtratic stuff for curves, so that I can simply use the movetoward functions)
I'm using SimSets to contain these things, and referencing ALL OBJECTS by their ID, which I stupidly never tested as far as saving/loading levels goes, since the objects are recreated and lose their ID.. thus making all saved associations to ID's invalid..

it also seems like SimSets are not saved either when saving a level.. (Crap!)


I don't really know what to do now. my brain is kind of hurting.


I'm guessing, that I will have to create a new function that grabs the simsets and their objects, and sorts all the needed information into some type of array that is stored as a dynamic field in each enemy sprite... and then when loading the level have a way to rebuild all that info so I can edit it again... I probably should be using object names instead of the ID..?

*Edit*

I think I have an idea of what to do, it's just frustrating.. guess I learnt a lesson though.
here's a little video of the type of functionality I added: www.datatragedy.com/edit.wmv

#1
02/07/2006 (8:41 pm)
Ok, problem solved! *newbie?* :)

I ended up adding object names to the spots where I create new objects, and then I added 2 new dynamic fields, one for if an object should make a SimSet and another for if an object should add to a SimSet, they both end up getting evaluated.. but since I have another dynamic field for an object's index# I sort through all the objects, doing the make SimSet eval's first, then sort through and make sure the objects get added to the SimSet's in order of their index#.

that sounded kind of confusing.. but at least it seems to work.

function levelLoaded()
{
   %totalObj = levelEditorSceneWindow.scenegraph.getCount();

   for ( %i=0; %i<%totalObj; %i++ )
   {
      %obj = levelEditorSceneWindow.scenegraph.getObject(%i);
      if ( %obj.makeSimSet !$= "" )
      {
         eval( %obj.makeSimSet);
      }
   }
   
   for ( %i=0; %i<%totalObj; %i++ )
   {
      for ( %o=0; %o<%totalObj; %o++ )
      {
         %obj = levelEditorSceneWindow.scenegraph.getObject(%o);
         if ( %obj.index == %i )
         {  
            if ( %obj.addToSimSet !$= "" )
            {  
               eval( %obj.addToSimSet);
            }
         }
      }
   }
   
   MessageBoxOK("Loaded OK", "The level objects have been initialized!", "");
   
   $loadFunctionDone = true;
   
}
#2
02/09/2006 (9:26 am)
I don't suppose you would be interested in releasing your full tool and usage would you ;)

Looks nice though
#3
02/09/2006 (12:31 pm)
I was thinking of doing that, the only problem is it's got some strange phantom bugs, stuff that causes the level editor to go into an endless loop and sprew out level files over a gig in size when saving, and a couple weird quirks for doing things, plus there are lots of explicit filled comments and variables due to frustration with not knowing what I was doing during making it :D

it will get cleaned up and reorganized some more though, it's just 1 script file, with a couple changes to the level editor script and gui.