Stack support? (LIFO)
by Jay · in Torque Game Builder · 08/18/2006 (6:24 pm) · 7 replies
I only had a short while to overlook the included docs. for TGB (demo) and was not sure if it supported data structures in the way of a stack, aka: LIFO (Last In First Out)...
I'm currently looking for a new (better) engine to port my current project to... My current "engine" simply isn't "cutting the mustard" so to speak.
I'm currently giving great consideration into purchasing the TGB, but this is a huge consern of mine for it is a big need of mine to complete the game.
Thanx for any info in advance
I'm currently looking for a new (better) engine to port my current project to... My current "engine" simply isn't "cutting the mustard" so to speak.
I'm currently giving great consideration into purchasing the TGB, but this is a huge consern of mine for it is a big need of mine to complete the game.
Thanx for any info in advance
#2
Thank you for your reply David, it's most appreciated.
08/18/2006 (8:55 pm)
I see... This is bad news for me. I'm not exactly the most "savy" programmer... I'm an artist who was forced to take up scripting to complete my own projects LoL. Needless to say, me and C++ don't get along.Thank you for your reply David, it's most appreciated.
#3
Now you can call pushFront/popFront on any SimSet in your game.
08/19/2006 (1:33 pm)
@Jay - If your sticking SimObject based objects into your stack, you can use a SimSet to mimic it. Just use pushToBack and bringToFront members to move your object to the approriate location after adding it. You can even write helper functions into the SimSet namespace like this:function SimSet::pushFront( %this, %obj )
{
%this.add( %obj );
%this.bringToFront( %obj );
}
function SimSet::popFront( %this )
{
%obj = %this.getObject( 0 );
%this.remove( %obj );
return %obj;
}Now you can call pushFront/popFront on any SimSet in your game.
#5
What I need this for is to keep track of my player object's (x,y) possition on the screen for use in an "undo" feature. When you make a wrong move or two you can simply click the Undo button and snap back to your previous possition(s)
Thanx for your help guys.
08/19/2006 (3:17 pm)
Yes... very nifty. It doesn't make a whole lot of sense to me right now, but thats fine. I've only been going over torquescript for a day. I'll catch on in due-time.What I need this for is to keep track of my player object's (x,y) possition on the screen for use in an "undo" feature. When you make a wrong move or two you can simply click the Undo button and snap back to your previous possition(s)
Thanx for your help guys.
#6
08/19/2006 (3:42 pm)
@Jay - If you stick the positions in an object you can then use it like this:function SimSet::popBack( %this )
{
%obj = %this.getObject( 0 );
%this.remove( %obj );
return %obj;
}
$posStack = new SimSet();
$posStack.add( new ScriptObject() { x = 1; y = 1; } );
$posStack.add( new ScriptObject() { x = 2; y = 2; } );
$posStack.add( new ScriptObject() { x = 3; y = 3; } );
while( $posStack.getCount() > 0 )
{
%posObject = $posStack.popBack();
echo( "x y = " @ %posObject.x SPC %posObject.y );
%posObject.delete();
}
#7
Thanx for the help once again... I wasn't Completly sure If I was going to side with TGB or my 2nd option. I'm leaning more to TGB now. I'm starting to see just how much it will allow me to do with it's scripting language.
Reguards,
Jay
08/19/2006 (3:48 pm)
Your tha man Tom =)Thanx for the help once again... I wasn't Completly sure If I was going to side with TGB or my 2nd option. I'm leaning more to TGB now. I'm starting to see just how much it will allow me to do with it's scripting language.
Reguards,
Jay
Associate David Higgins
DPHCoders.com
With this, I would assume your answer is No, it does not currently support a LIFO style collection/stack but this functionality would be able to be built into the engine's C++ Source code with most likely little to no trouble, though I can't really say much as I've not seen the source.