Getting a variable
by Scooby Brown · in Technical Issues · 08/01/2008 (9:58 pm) · 2 replies
Ok fellow torquers, this is a very perplexing problem for me and i believe will help others around.
now after an hour of searching, i have yet found a way to do this.
its kind of hard for me to explain but,
I want to get a dynamic variable from an object using the variable passed into the function
for example
function ShapeBase::MountWeaponImage( %this, %weaponAmmoInClip, %slot, %curWeapon) <-- up here were %weaponAmmoInClip is passed in,
{
%curWeapon = %this.getMountedImage(%slot);
%playerObj = %this;
echo(%weaponAmmoInClip);
echo(%this.getDataBlock().getName());
echo(%playerObj.client.weaponammo.%weaponAmmoInClip); <-- i would like it to point to it here but i have no clue how
%ammoOnPile = %this.getInventory(%curWeapon.ammo);
%AltammoOnPile = %this.getInventory(%curWeapon.Altammo);
// Images assume a false ammo state on load.
// We need to set the state according to the current inventory.
if ((%playerObj.client.weaponammo.weaponAmmoInClip > 0) || (%ammoOnPile > 0))
{
%this.setImageAmmo(%slot,true);
}
%this.client.displayWeaponHUD(%curWeapon.getName());
%this.client.setClipAmountHud(%playerObj.client.weaponammo.weaponAmmoInClip);
%this.client.setAmmoAmountHud(%ammoOnPile);
%this.client.ShowWeaponReload( false );
}
Any help would be appreciated
now after an hour of searching, i have yet found a way to do this.
its kind of hard for me to explain but,
I want to get a dynamic variable from an object using the variable passed into the function
for example
function ShapeBase::MountWeaponImage( %this, %weaponAmmoInClip, %slot, %curWeapon) <-- up here were %weaponAmmoInClip is passed in,
{
%curWeapon = %this.getMountedImage(%slot);
%playerObj = %this;
echo(%weaponAmmoInClip);
echo(%this.getDataBlock().getName());
echo(%playerObj.client.weaponammo.%weaponAmmoInClip); <-- i would like it to point to it here but i have no clue how
%ammoOnPile = %this.getInventory(%curWeapon.ammo);
%AltammoOnPile = %this.getInventory(%curWeapon.Altammo);
// Images assume a false ammo state on load.
// We need to set the state according to the current inventory.
if ((%playerObj.client.weaponammo.weaponAmmoInClip > 0) || (%ammoOnPile > 0))
{
%this.setImageAmmo(%slot,true);
}
%this.client.displayWeaponHUD(%curWeapon.getName());
%this.client.setClipAmountHud(%playerObj.client.weaponammo.weaponAmmoInClip);
%this.client.setAmmoAmountHud(%ammoOnPile);
%this.client.ShowWeaponReload( false );
}
Any help would be appreciated
Associate James Ford
Sickhead Games
%obj.getFieldValue( %fieldName );
Search the documentation for getField, or getDataField, or getFieldValue... Its something like that and its a member of SimObject or ConsoleObject.