Author Topic: Iban Explains it All  (Read 27028 times)

Let me try it out, guys, thanks


Edit: Does not work

After tracing the console, this is what it gave me:
Code: [Select]
Entering ConsoleEntry::eval()
   ==>servercmdobjtest();
   Entering servercmdobjtest()
     
      Add-Ons/Script_Wiremod/server.cs (5): Unable to find object: '' attempting to call function 'getEyeVector'
      BackTrace: ->ConsoleEntry::eval->servercmdobjtest
     
     
      Add-Ons/Script_Wiremod/server.cs (6): Unable to find object: '' attempting to call function 'getEyePoint'
      BackTrace: ->ConsoleEntry::eval->servercmdobjtest
     
   Leaving servercmdobjtest() - return 0
Leaving ConsoleEntry::eval() - return

And I didn't change anything in the script:
Code: [Select]
function servercmdobjtest()
{
%scale = vectorScale(%obj.getEyeVector(),100);
%ray = containerRaycast(%obj.getEyePoint(),%scale,$Typemasks::fxBrickObjectType);

if(isObject(firstWord(%ray)))
{
%brick = firstWord(%ray);
echo(%brick.getPosition());
}
}



Also, Death, look in the Torque Appendix or type DumpConsoleFunctions(); into the console and save as a text file.
« Last Edit: March 21, 2011, 09:10:20 PM by Treynolds416 »

Sigh.

I have no idea how I can make this any clearer. Variables cannot be pulled out of thin air.

Code: [Select]
function serverCmdDoObjTest(%client)
{
%obj = %client.player;

Sigh.

I have no idea how I can make this any clearer. Variables cannot be pulled out of thin air.

Code: [Select]
function serverCmdDoObjTest(%client)
{
%obj = %client.player;
I thought %obj was already defined, sorry


Edit: Actually, it didn't fix anything, still returns the same error message.

Help?
« Last Edit: March 22, 2011, 04:05:38 PM by Treynolds416 »

please post your modified script -- the ENTIRE .cs file
and the console errors.

Then we can probably help you.

Or you can try some debugging yourself. -- put echo() statements for your variables.  in particular, the ones giving errors.

I figured out the problem!

lilboarder's Object check is somehow corrupt. I have no idea why, but by removing it the script worked.

Here is the entire code I used for testing purposes:
Code: [Select]
function servercmdobjtest(%client)
{
ClientCmdCenterPrint("You activated the function", 3);
%obj = %client.player;
%scale = vectorScale(%obj.getEyeVector(),100);
%ray = containerRaycast(%obj.getEyePoint(),%scale,$Typemasks::fxBrickObjectType);

%brick = firstWord(%ray);
messageClient(%client,'',%brick.getPosition());
ClientCmdCenterPrint("It probably didn't work", 3);
}



Edit: Interesting.
It only seems able to pick up on baseplates.

When I try it on another brick the console says
Code: [Select]
Add-Ons/Script_Wiremod/server.cs (11): Unable to find object: '0' attempting to call function 'getPosition'
BackTrace: ->servercmdobjtest
« Last Edit: March 22, 2011, 05:00:14 PM by Treynolds416 »

Be sure to test your script with /getid  to make sure your getting the right answer.

so something like this:
/objtest
<some position>
/getid
< some id>
goto console:
echo(<some id>.getposition() );

do they match?

it also might be helpful to print the id and classname of the brick you found.  Then you know you got a real brick, and not something wierd.


Be sure to test your script with /getid  to make sure your getting the right answer.

so something like this:
/objtest
<some position>
/getid
< some id>
goto console:
echo(<some id>.getposition() );

do they match?

it also might be helpful to print the id and classname of the brick you found.  Then you know you got a real brick, and not something wierd.
Yes I've been doing that. It works perfectly for baseplates and the object is not found for any of the other bricks that I have tested. It matches up every time for the baseplates as well.

first and foremost why the hell are you using the actual function clientCmdCenterPrint?

commandToClient(%client, 'centerPrint', "foobar.", 3);

OR

%client.centerPrint("foobar.", 3);

clientCmdCenterPrint only works with the actual client the mod is installed on. If you try this on a dedicated server even the message will not work.



I'm getting tired of trying to find the problem in your code so here's what should work.


Code: [Select]
// Learn to camel-case.
function serverCmdObjTest(%client)
{
// Get the player.
%obj = %client.player;

// If they don't have a player we can't do anything.
if(!isObject(%obj))
{
%client.centerPrint("\c5Spawn first, dummy.", 2);
return;
}

// Space Guy's code (iban no good at math)
// Used to figure out in which direction the player is looking.
%fvec = %obj.getForwardVector();
%fX = getWord(%fvec, 0);
%fY = getWord(%fvec, 1);

%evec = %obj.getEyeVector();
%eX = getWord(%evec, 0);
%eY = getWord(%evec, 1);
%eZ = getWord(%evec, 2);

%eXY = mSqrt((%eX * %eX) + (%eY * %eY));
%aimVec = (%fX * %eXY) SPC (%fY * %eXY) SPC %eZ;

// Our range is the maximum that is stable for raycasts.
%range = 100;

// Multiple the aimvec and add it to our starting position to get an end point.
%end = vectorAdd(%start, vectorScale(%aimVec, %range));

// Masks
// AlwaysObjectType will hit non-raycasting bricks, too.
%masks = $TypeMasks::FxBrickAlwaysObjectType;

// Get the collision object of the raycast.
%col = firstWord(containerRayCast(%start, %end, %masks, %obj));

if(!isObject(%col))
{
%client.centerPrint("\c5Look at a brick, dummy.", 2);
return;
}

messageClient(%client, '', "\c5BRICK POSITION\c6:" SPC %col.getPosition());
echo("BRICK POSITION:" SPC %col.getPosition());
}

If you have any other problems, make a new thread. This is "Iban Explains it All" not "Treynolds416 gets people to resolve his scripts for him."

Iban, please make a tutorial on databases and information storing.

Alright, I understand what the emitter datablock commands do, but for color, which of the four value represents what? Red Green Blue Alpha? A R G B?

A several ideas for articles:

  • FileObject
  • SimGroup/SimSet/SimObject
  • TCPObject/HTTPObject

Just some ideas, feel free to toss them around as you please.

Alright, I understand what the emitter datablock commands do, but for color, which of the four value represents what? Red Green Blue Alpha? A R G B?
It's RBGA.

Also, where would I start if I were to make a script that replaces words in chat with a random word from a specified text file? For example replacing all "that" words with "dat". I was planning on doing this as more a scripting exercise.
« Last Edit: March 27, 2011, 03:59:42 PM by Demian »

It's RBGA.

Also, where would I start if I were to make a script that replaces words in chat with a random word from a specified text file? For example replacing all "that" words with "dat". I was planning on doing this as more a scripting exercise.
Serversided or clientsided?