Author Topic: Schedule/brick/setPrint Scripting help?  (Read 1019 times)

Let's say I have some bricks added as a datablock named:

"TimerMinutes" (minutes)
"TimerSeconds10" (double-digit left)
"TimerSeconds1"   (single-digit left)
(not the brick name wrench thing, it's added as a datablock, this is what I mean:)

Code: (Torque) [Select]
datablock fxDTSBrickData(CityRPTimerMinutesBrickData : brick1x1PrintData)
{
category = "RPG";
subCategory = "Tick Timers";

uiName = "Minutes";

CityRPBrickAdmin = true;
};

I need help with threads or whatever.. how can I use a thread/or um.... something to wait in Torque?

Yes, and don't forget it would need to set that print too of any brick with that.

Also, if I hopefully get an answer, remember it will need to set the print in some way...
« Last Edit: December 22, 2008, 04:11:38 PM by Kalphiter »

I don't really understand what you're trying to ask, but it sounds like you need to look up schedules. That'd be the function you'd use for "waiting".


I don't really understand what you're trying to ask, but it sounds like you need to look up schedules. That'd be the function you'd use for "waiting".


XD that would work :)

I still need help on how to datablockwhatever.setPrint or something?

just use %brick.incrementPrint(amount); and %brick.decrementPrint(amount);

just use %brick.incrementPrint(amount); and %brick.decrementPrint(amount);
%brick would be:

%CityRPTimerMinutesBrick.incr...

right?



And how do I use schedule()?

No. That's your datablock. You want to find a specific object. How you plan on scripting that is up to you.

just use %brick.incrementPrint(amount); and %brick.decrementPrint(amount);
%brick would be:

%CityRPTimerMinutesBrick.incr...

right?



And how do I use schedule()?
No. That's your datablock. You want to find a specific object. How you plan on scripting that is up to you.

And what is the specific object?

It'd be every separate brick. You have to find the objects through script; there no %bluebrick1 by default.

It'd be every separate brick. You have to find the objects through script; there no %bluebrick1 by default.
And you won't explain or give an example why...?

Because I'm clueless about that part  :cookieMonster:

Because I'm clueless about that part  :cookieMonster:
I find it better knowing that you do not know, rather than "I will not tell you".

The question on how to use schedules has already been answered before, search the forums.

To find bricks, there are two methods you can use:

Code: [Select]
for(%i=0;%i<MainBrickGroup.getCount();%i++)
{
   %group = MainBrickGroup.getObject(%i);
   for(%j=0;%j<%group.getCount();%j++)
   {
      %o = %group.getObject(%i);
      if(%o.getDatablock().getID() == CityRPTimerMinutesBrickData.getID())
      {
         //do stuff to %o
      }
   }
}
Essentially, this code checks every brick in existence for whether its datablock matches the one specified. (here, the City RP Minutes Timer) You can then perform whatever functions you want on the brick. This code probably happen every minute on your server.

Code: [Select]
initContainerBoxSearch(%position, %boxSize, %mask);
while (%searchObj= containerSearchNext())
{
   if(%searchObj.getDatablock().getID() == CityRPTimerMinutesBrickData.getID())
   {
      //do stuff to %searchObj
   }
}
This one is slightly different. It searches for objects in a particular area, given by a position (the centre of the box) and the box size, which is the size of it in Torque Units. (e.g. "0.5 0.5 0.6" is exactly the size of a 1x1 brick because a stud is 0.5 units wide and a plate is 0.2 units high) The type mask would be set to $TypeMasks::FxBrickObjectType for raycasting bricks only, or $TypeMasks::FxBrickAlwaysObjectType for all bricks.

Note that these functions can get very slow if you are attempting to perform them several times per second or on particularly large builds, such as what you might get in a large-sized City RP.

What might be more efficient is if you put all of this through the Events system in some way.