Author Topic: Script breaks activations?  (Read 1060 times)

Fixed that problem.
« Last Edit: November 07, 2010, 02:16:38 PM by aml »

onTrigger is used for activating, and you aren't parenting it, so it no longer works. Parent.

Well that fixed the activation part, but it still doesn't display the message.

Well I started to mess with the code a bit more, and it broke the activation again.
I Parented and Packaged it.
Code: [Select]
datablock PlayerData(PlayerTest : PlayerStandardArmor)
{
minJetEnergy = 100;
canJet = 0;

rechargeRate = 3.0;

uiName = "Test Player";
showEnergyBar = 1;
};

datablock PlayerData(PlayerTestInvisible : PlayerStandardArmor)
{
minJetEnergy = 100;
jetEnergyDrain = 5;
canJet = 0;

maxForwardSpeed = 0;
maxBackwardSpeed = 0;
maxSideSpeed = 0;
maxForwardCrouchSpeed = 0;
maxBackwardCrouchSpeed = 0;
maxSideCrouchSpeed = 0;

canRide = 0;

uiName = "";
};

package testplayer
{
function Armor::onTrigger(%obj,%trigger,%val)
{
if(%trigger == 4)
{
if(%obj.getDatablock().getName() $= "PlayerTest" && %val == 1)
{
%obj.changeDatablock(PlayerTestInvisible);
%obj.hidenode("All");
}
else if(%obj.getDatablock().getName() $= "PlayerTestInvisible" && %val == 0)
{
%obj.changeDatablock(PlayerTest);
%obj.unhideNode("All");
}
}
Parent::onTrigger(%obj,%trigger,%val);
}
};
activatepackage(testplayer);


Code: [Select]
package testplayer
{
function Armor::onTrigger(%this,%obj,%trigger,%val)
{
if(%trigger == 4)
{
if(%this.getName() $= "PlayerTest" && %val == 1)
{
%obj.changeDatablock(PlayerTestInvisible);
%obj.hidenode("All");
}
else if(%this.getName() $= "PlayerTestInvisible" && %val == 0)
{
%obj.changeDatablock(PlayerTest);
%obj.unhideNode("All");
}
}
Parent::onTrigger(%this,%obj,%trigger,%val);
}
};
activatepackage(testplayer);

Should be solved. Problem: Invalid amount of arguments.

Should be solved. Problem: Invalid amount of arguments.
Well thanks for the help on that.
It doesn't hide any of the nodes though, but I think I might be able to fix that.

I think the "ALL" is case sensitive. Uppercase it.

I think the "ALL" is case sensitive. Uppercase it.
Yeah it is case sensitive, fixing now.

You might also want to "hide" the shapename by using %obj.setShapeNameDistance(10); (10 is lowest) - to make it be less buggy, you might also want to package ::setShapeNameDistance to change distance to 10 all the time if they are "invisible".

You might also want to "hide" the shapename by using %obj.setShapeNameDistance(10); (10 is lowest) - to make it be less buggy, you might also want to package ::setShapeNameDistance to change distance to 10 all the time if they are "invisible".
Is that the name thing above all of the players name?
If so I was planning on adding that in eventually.

Anyways, I'm working on the Energy Bar decreasing as the player is invisible.
I've added some more things to the code, btw.
Code: [Select]
datablock PlayerData(PlayerNinja : PlayerStandardArmor)
{
minJetEnergy = 0;
canJet = 0;

rechargeRate = 3.0;

uiName = "Ninja Player";
showEnergyBar = 1;
};

datablock PlayerData(PlayerNinjaInvisible : PlayerStandardArmor)
{
minJetEnergy = 10;
jetEnergyDrain = 5;
canJet = 0;

maxForwardSpeed = 0;
maxBackwardSpeed = 0;
maxSideSpeed = 0;
maxForwardCrouchSpeed = 0;
maxBackwardCrouchSpeed = 0;
maxSideCrouchSpeed = 0;

canRide = 0;
showEnergyBar = 1;
uiName = "";
};

package ninjaplayer
{
function Armor::onTrigger(%this,%obj,%trigger,%val)
{
if(%obj.getEnergyLevel() > 10)
{
if(%trigger == 4)
{
if(%this.getName() $= "PlayerNinja" && %val == 1)
{
%obj.changeDatablock(PlayerNinjaInvisible);
%obj.hidenode("ALL");
}
else if(%this.getName() $= "PlayerNinjaInvisible" && %val == 0)
{
%obj.changeDatablock(PlayerNinja);
%obj.unhideNode("$Pref::Avatar");
%obj.unhideNode("headskin");
}
}
}
Parent::onTrigger(%this,%obj,%trigger,%val);
}
};
activatepackage(ninjaplayer);
I'm not really sure on how I could decrease the energy bar though.
« Last Edit: November 09, 2010, 11:37:28 PM by aml »

%obj.setEnergyLevel(%obj.getEnergyLevel()-NUMBER);

How you'd do it every few seconds?
FUNction loops! :)

I'm not really good with schedule loops, but I tried.
It gets a syntax error, probably because I did the schedule wrong.

Code: [Select]
package ninjaplayer
{
function Armor::onTrigger(%this,%obj,%trigger,%val)
{
if(%obj.getEnergyLevel() > 10)
{
if(%trigger == 4)
{
if(%this.getName() $= "PlayerNinja" && %val == 1)
{
%obj.changeDatablock(PlayerNinjaInvisible);
%obj.hidenode("ALL");
%obj.setEnergyLevel(%obj.getEnergyLevel()-5);
%this.schedule(500,setEnergyLevel,%obj.getEnergyLevel()-5);
}
else if(%this.getName() $= "PlayerNinjaInvisible" && %val == 0)
{
%obj.changeDatablock(PlayerNinja);
%obj.unhideNode("$Pref::Avatar");
%obj.unhideNode("headskin");
}
}
}
Parent::onTrigger,%this,%obj,%trigger,%val);
}
};
activatepackage(ninjaplayer);
Edit: I accidentelly deleted a paranthysis on the Parent part so that was causing the error.
I still can't get the schedule loop to work D:
« Last Edit: November 11, 2010, 08:13:26 AM by aml »

That would just do it twice.

You have to make a new function and loop that.
Code: [Select]
function Player::cloakDrain(%obj)
{
cancel(%obj.cloakdrainloop);
%obj.setEnergyLevel(%obj.getEnergyLevel()-5);
%obj.cloakDrainLoop = %obj.schedule(500,cloakDrain);
}

package ninjaplayer
{
function Armor::onTrigger(%this,%obj,%trigger,%val)
{
if(%obj.getEnergyLevel() > 10)
{
if(%trigger == 4)
{
if(%this.getName() $= "PlayerNinja" && %val == 1)
{
%obj.changeDatablock(PlayerNinjaInvisible);
%obj.hidenode("ALL");
%obj.cloakDrain();
}
else if(%this.getName() $= "PlayerNinjaInvisible" && %val == 0)
{
%obj.changeDatablock(PlayerNinja);
%obj.unhideNode("$Pref::Avatar");
%obj.unhideNode("headskin");
cancel(%obj.cloakdrainLoop);
}
}
}
Parent::onTrigger,%this,%obj,%trigger,%val);
}
};
activatepackage(ninjaplayer);