Game Development Community

Numbers & simsets

by John Coyne · in Torque Game Builder · 04/20/2006 (8:25 am) · 2 replies

Hi
I need a dynamic data structure to hold a group of numbers set by the user clicking the screen, a simset seemed the most obvious choice but it's causing a few problems. So far I have a scriptObject called slide, with a simset inside it. When the user clicks I call a method in my slide which adds the coords the user clicked, but it seems to cause intermittent errors. Does anyone have any ideas? I was thinking it might be having the simset INSIDE the scriptobject that maybe caused me problems.


mouse.cs
function sceneWindow2D::onMouseDown(%this, %mod, %worldPos, %mouseClicks)
{
   $slide.addSlidePoint(%worldPos);
}

slide.cs
function Slide::onAdd(%this)
{   
   //initialise the Slide simset   
   %this.slidePath = new simset();
   %this.controller(%this);
}

function Slide::addSlidePoint(%this, %newSlidePoint)
{
   echo("Adding slide point" @ %newSlidePoint);
   %this.slidePath.add(%newSlidePoint);
   echo("Slide point added");
}

from the console
Adding slide point22.250000 -32.309689
Slide point added
Adding slide point15.750000 -15.700691
Slide point added
Adding slide point0.000000 -8.953286
Set::add: Object "0.000000 -8.953286" doesn't exist
Slide point added
Adding slide point-0.750000 -9.472317
Set::add: Object "-0.750000 -9.472317" doesn't exist
Slide point added
Adding slide point-8.750000 8.434258
Set::add: Object "-8.750000 8.434258" doesn't exist
Slide point added
Adding slide point-10.750000 11.807961
Set::add: Object "-10.750000 11.807961" doesn't exist
Slide point added

#1
04/20/2006 (8:50 am)
John,

SimSets can only hold objects. Depending on the amount of numbers you have to handle, you could just put them in a string.
#2
04/20/2006 (9:20 am)
Thanks.
I was under the impressoin simsets could hold anything you like as long as you remember to treat them as what they are. Had a feeling I might have to change :)