Author Topic: playthread custom anamation problems...  (Read 1254 times)

i edited a scope script that uses animations not image changes
the only problem is the animations wont play...

Code: [Select]
package ScopeSwitch
{
function Armor::onTrigger(%this,%obj,%slot,%val)
{
Parent::onTrigger(%this,%obj,%slot,%val);
if(%slot == 4 && %val)
{
if(%obj.Scope $= (2))
{
%this.playthread(1, ScopeA);
%obj.Scope = "1";
}
else if(%obj.Scope !$= (2))
{
%this.playthread(2, ScopeB);
%obj.Scope = "2";
}
}
}
};
activatePackage(ScopeSwitch);

so why wont they play?, can you just NOT play custom animations with playthread?
« Last Edit: April 08, 2014, 05:49:50 PM by zombekillz »

feel free to test too, just pin this to the end of any weapon script and watch the console errors roll in :D

Well, lets see here..

if(%obj.Scope $= (2))
{
   ...
}
else if(%obj.Scope !$= (2))


You do not need to check if its not equal to 2, because you already know it isn't.


if(%obj.Scope $= (2))

$= is used to compare strings. Neither %obj.Scope nor 2 are strings, they are both numbers. Torque treats everything as strings, so this will actually work, but its terrible practice. You also don't need to put the 2 in brackets.


%obj.Scope = "1";

Nothing really wrong here, but you don't need to put numbers in quotation marks.


%this.playthread(2, ScopeB);

Here, %this is referring to the player's datablock, there is no playThread function for datablocks. %obj is referring to the triggering player, however there is no ScopeA or ScopeB animations for players (and its next to impossible to make one). You want to find a way to get the item the player is holding, and play the animation on that (assuming the item itself has the animations). Go do some searching on the forums, it shouldn't be too hard.


A minor problem is that you are using 1 and 2 to represent the state that the weapon is in. Id recommend using 0 and 1, because then you dont have to set the state when you first equip the weapon, and by default it will be in state 0.


Also, your package name is pretty generic. Give it a more unique name so that it doesn't overwrite anything. I always start my package names (and most function names) with the name of the add-on, eg. HatMod_Package.

Well, lets see here..

if(%obj.Scope $= (2))
{
   ...
}
else if(%obj.Scope !$= (2))


You do not need to check if its not equal to 2, because you already know it isn't.


if(%obj.Scope $= (2))

$= is used to compare strings. Neither %obj.Scope nor 2 are strings, they are both numbers. Torque treats everything as strings, so this will actually work, but its terrible practice. You also don't need to put the 2 in brackets.


%obj.Scope = "1";

Nothing really wrong here, but you don't need to put numbers in quotation marks.


%this.playthread(2, ScopeB);

Here, %this is referring to the player's datablock, there is no playThread function for datablocks. %obj is referring to the triggering player, however there is no ScopeA or ScopeB animations for players (and its next to impossible to make one). You want to find a way to get the item the player is holding, and play the animation on that (assuming the item itself has the animations). Go do some searching on the forums, it shouldn't be too hard.


A minor problem is that you are using 1 and 2 to represent the state that the weapon is in. Id recommend using 0 and 1, because then you dont have to set the state when you first equip the weapon, and by default it will be in state 0.


Also, your package name is pretty generic. Give it a more unique name so that it doesn't overwrite anything. I always start my package names (and most function names) with the name of the add-on, eg. HatMod_Package.

all good advice indeed :D, i wasn't sure if torque started scripts in a 0 or not, thanks, that is also why i had the if is not equil too in there...

i also know there is no scope animations for a player, those are animated into the model, i used %this because someone said you could use it on non player animations somewhere... oops

so basically now i am at a point where i need another way to call the weapon models animations without playthread...  :/

Help? lol i have done a few hours of research on this already and am pretty sure it would be better to just have it explained once.

You need to add a way to transition into playing the sequence you want to your image state system.


Fixed :D, turns out u cant anamate such things but i have implemented a better system that includes image change and an FOV adjust

Code: [Select]
package ScopeSwitch
{
function Armor::onTrigger(%this,%obj,%slot,%val,%client)
{
Parent::onTrigger(%this,%obj,%slot,%val);
if(%slot == 4 && %val)
{
if(%obj.Scope $= 2)
{
%obj.updateArm(ADV_SMG_SCOPEImage);
%obj.mountImage(ADV_SMG_SCOPEImage,0);
%obj.Scope = 1;
%obj.client.setControlCameraFOV(70);
}
else if(%obj.Scope !$= 2)
{
%obj.updateArm(ADV_SMGImage);
%obj.mountImage(ADV_SMGImage,0);
%obj.Scope = 2;
%obj.client.setControlCameraFOV(90);
}
}
}
};
activatePackage(ScopeSwitch);

sorry folks, its the only way to do it
for further reference here is where to put the reload part of the script...

Code: [Select]
function ADV_SMG_SCOPEImage::onReloadStart(%this,%obj,%slot)
{
if($Pref::Server::TTAmmo == 0 || $Pref::Server::TTAmmo == 1)
{
exec("function ADV_SMGImage::onReloadStart");
%obj.updateArm(ADV_SMGImage);
%obj.mountImage(ADV_SMGImage,0);
%obj.Scope = 2;
%obj.client.setControlCameraFOV(90);
commandToClient(%obj.client,'bottomPrint',"<just:right><font:impact:24><color:fff000>Ammo <font:impact:34>\c6" @ %obj.toolAmmo[%obj.currTool] @ " / " @ %obj.client.quantity["9MMrounds"] @ "", 1, 2, 3, 4);
}
}

i implemented it into some tier scripts for the time being, so it is compatible with tier ammo system, that code above is so the weapon scopes out for the reload secuence, it does not work right away if you command the reload with the R key, the first time you press R it unscopes the second time it will accually reload, not a big deal at all, i kind of like it...
« Last Edit: April 08, 2014, 05:49:07 PM by zombekillz »