Author Topic: Redo Command  (Read 563 times)

I am trying to make a redo command and since the undostack only stores bricks that you have planted, I'm making a new script object that I named redostack, and it is supposed to store the Number of the object you deleted like once you kill a brick, it writes it to a file in succession IE: deletedbrick0 deletedbrick1 deletedbrick2 ect. Also, I have it set up so it writes the object ID to the Script object, and in that same function, it saves the script object to a txt file. Most of it works, but I need to know a couple of things. What do the pop and push functions do for script objects, I have only seen these functions in GUI's. Also, how would I have it so once you have killed it, it writes the number of the deletion to the script object. Right now, it just over writes the old object id and writes the object number as 1. Here is the code so far:
Code: [Select]
package redo
{
function fxDTSBrick::OnDeath(%this,%obj)
{
%BrickID = %obj.getId();
$Redocache = new scriptobject(redostack) {Objnumber = %Count; ObjectID = %BrickID; };
$Redocache.val[-1+$Redocache.count++] = %Count;
missioncleanup.add(%Redocache);
//%client.redostack.push(
$Redocache.save("config/Redocache.txt");
}
};
activatepackage(redo);
and here is what the script object looks like:
Code: [Select]
//--- OBJECT WRITE BEGIN ---
new ScriptObject(redostack) {
      ObjectID = "12689";
      count = "1";
};
//--- OBJECT WRITE END ---

Nevermind, this is too complicated for me right now.