Mouse Conrol on Inventory GUI
by Ironbelly Studios · in General Discussion · 12/18/2008 (12:16 am) · 1 replies
Hi All,
I am new to the TGE 1.4.
And I am facing some problem when tried to drop items from InventoryGui by mouse...
in server/scripts/inventory.cs I am using the following functions to throw the objects from InventoryGui by key board
function ShapeBase::throw(%this,%data,%amount)
{
// Throw objects from inventory. The onThrow method is
// responsible for decrementing the inventory.
if (%this.getInventory(%data) > 0)
{
%obj = %data.onThrow(%this,%amount);
if (%obj)
{
echo(%obj.image);
%this.throwObject(%obj);
echo("\n .... Yeah, I hv thrown it.....");
return true;
}
}
return false;
}
and
function ShapeBase::throwObject(%this,%obj)
{
// Throw the given object in the direction the shape is looking.
// The force value is hardcoded according to the current default
// object mass and mission gravity (20m/s^2).
%throwForce = %this.throwForce;
if (!%throwForce)
%throwForce = 20;
// Start with the shape's eye vector...
%eye = %this.getEyeVector();
%vec = vectorScale(%eye, %throwForce);
// Add a vertical component to give the object a better arc
%verticalForce = %throwForce / 2;
%dot = vectorDot("0 0 1",%eye);
if (%dot < 0)
%dot = -%dot;
%vec = vectorAdd(%vec,vectorScale("0 0 " @ %verticalForce,1 - %dot));
// Add the shape's velocity
%vec = vectorAdd(%vec,%this.getVelocity());
// Set the object's position and initial velocity
%pos = getBoxCenter(%this.getWorldBox());
%obj.setTransform(%pos);
%obj.applyImpulse(%pos,%vec);
// Since the object is thrown from the center of the
// shape, the object needs to avoid colliding with it's
// thrower.
%obj.setCollisionTimeout(%this);
}
and I have configure default.bind.cs and init.cs properly......... and key board is working fine when InventoryGui is not top of the screen... whenever it has been toggled neither key board nor mouse is
working...
Suggest some points...
Ryan....
I am new to the TGE 1.4.
And I am facing some problem when tried to drop items from InventoryGui by mouse...
in server/scripts/inventory.cs I am using the following functions to throw the objects from InventoryGui by key board
function ShapeBase::throw(%this,%data,%amount)
{
// Throw objects from inventory. The onThrow method is
// responsible for decrementing the inventory.
if (%this.getInventory(%data) > 0)
{
%obj = %data.onThrow(%this,%amount);
if (%obj)
{
echo(%obj.image);
%this.throwObject(%obj);
echo("\n .... Yeah, I hv thrown it.....");
return true;
}
}
return false;
}
and
function ShapeBase::throwObject(%this,%obj)
{
// Throw the given object in the direction the shape is looking.
// The force value is hardcoded according to the current default
// object mass and mission gravity (20m/s^2).
%throwForce = %this.throwForce;
if (!%throwForce)
%throwForce = 20;
// Start with the shape's eye vector...
%eye = %this.getEyeVector();
%vec = vectorScale(%eye, %throwForce);
// Add a vertical component to give the object a better arc
%verticalForce = %throwForce / 2;
%dot = vectorDot("0 0 1",%eye);
if (%dot < 0)
%dot = -%dot;
%vec = vectorAdd(%vec,vectorScale("0 0 " @ %verticalForce,1 - %dot));
// Add the shape's velocity
%vec = vectorAdd(%vec,%this.getVelocity());
// Set the object's position and initial velocity
%pos = getBoxCenter(%this.getWorldBox());
%obj.setTransform(%pos);
%obj.applyImpulse(%pos,%vec);
// Since the object is thrown from the center of the
// shape, the object needs to avoid colliding with it's
// thrower.
%obj.setCollisionTimeout(%this);
}
and I have configure default.bind.cs and init.cs properly......... and key board is working fine when InventoryGui is not top of the screen... whenever it has been toggled neither key board nor mouse is
working...
Suggest some points...
Ryan....
About the author
Torque Owner Christopher Curry