Page 1 of 1

actor count

PostPosted: Sun Jul 31, 2011 12:19 am
by raminjoon
Hi i was wondering to know how can I set a amount on a weapon. like let say I got 10 apples so after I used up all ten I want it to set the number text to 0. how?

Re: actor count

PostPosted: Sun Jul 31, 2011 12:40 am
by JamesLeonardo32
If you make a vairable named apple, then colecting the apple should have a code like:

Code: Select all
apple+=1; // add one apple


And most likely touching the apple will result in destroying the apple actor.

So now if you want to use the apple, a code such as:

Code: Select all
if (apple>=1) // if you have more than one
{
apple-=1;  //takes away one

// Your special code for throwing the apple.

}


Renember the actor apple should have a diffrent name to the vairable, eg: Actor, Apple - Vairable, apple (Cap first letter)

I hope this helps.

(Please reply back to let me know if this helps! :wink: )

Re: actor count

PostPosted: Sun Jul 31, 2011 12:48 am
by skydereign
If you want the number of existing actors, just use ActorCount. This code will make the text actor display how many apples exist.
apple_num -> Draw Actor -> Script Editor
Code: Select all
textNumber=ActorCount("apple");