Page 1 of 1

Actor appearing once only

PostPosted: Wed Mar 18, 2009 10:25 pm
by Diana Kennedy
When I create a character using a periodic or random timer set to Number 1, the actor will constantly reapeat appearing as soon as he is out of the view. I solved the problem by the destroy actor action, as soon as the actor is put of view or at the end of the path. Problem is, I now need the characther active and alive even it is out of view. How can I make it that he does appear really ONCE only after his creation? If it requires scripting please explain it to me as you would to a 2 year old. :wink:

Re: Actor appearing once only

PostPosted: Thu Mar 19, 2009 12:33 am
by skydereign
If I get what you are aiming at, you want to create the actor only once, and this is done by an omnipresent timer. I believe all you would need is a variable. Where the timer creates your actor, set an if statement. So it will create the actor only when there is no other actor created.
Code: Select all
if (ActorCount("ACTOR")==0)
{
    //CreateActor
}

Sorry if this is not what you wanted, if it isn't can you explain a little more? What I don't understand is, when do you want to create the actor, and when do you not. I am not really sure on the random creation repeating if not on screen.

Re: Actor appearing once only

PostPosted: Thu Mar 19, 2009 6:40 pm
by Diana Kennedy
Yes, you understood it right! That is exactly what I need. Unfortunateley the script does not work. I was probably too dumb to put it in the right way. Here is waht I did:

Timer -> Scrupt Editor and then wrote in:

Code: Select all
if (ActorCount("Tarpan")==0)
{
    //CreateActor("Tarpan", "tarpantangallop01", "(none)", "tarpan1", 494, 160, true);
}


Now the actor does not appear at all.

Re: Actor appearing once only

PostPosted: Thu Mar 19, 2009 7:12 pm
by skydereign
Oh, I forgot that you are new to scripting.
Code: Select all
// The two slashes mean the line is commented out, in gameEditor, it will turn the code light blue
// this means that it will ignore this code. You can put them in to explain your logic, or show what needs fixing
// etc. Another way to do this is,
/*
These are also commented out
eventhough I don't have the //
*/
// so just get rid of the two // in front of the CreateActor

It should be this.
Code: Select all
if (ActorCount("Tarpan")==0)
{
    CreateActor("Tarpan", "tarpantangallop01", "(none)", "tarpan1", 494, 160, true);
}

Re: Actor appearing once only

PostPosted: Thu Mar 19, 2009 9:51 pm
by Diana Kennedy
Thank you for explaining me what the slashes mean. Yes, I am really a total noob in Scripting.
I copied the new code in, but still, the actor doesn't appear at all, now. :?

Re: Actor appearing once only

PostPosted: Thu Mar 19, 2009 9:55 pm
by skydereign
Could it be that the actor is not created on the screen? I don't know what regulation you are doing to keep the actor on the screen. This will also not work if there is another actor of the same kind already. Can you give more detail on your setup?

Re: Actor appearing once only

PostPosted: Fri Mar 20, 2009 9:52 pm
by Diana Kennedy
skydereign wrote:Could it be that the actor is not created on the screen?


What do you mean exactly? If the actor is created outside the view? Well it was indeed and so I changed it the way it is created inside the view. Still, it does not work.

I don't know what regulation you are doing to keep the actor on the screen. This will also not work if there is another actor of the same kind already. Can you give more detail on your setup?


I will try. Here is a screenshot of my actual working stage on that project.


Image

The actor in the upper left side A1, circled in red is the one that should create the Actor tarpan, that is the horse in the lesser right corner, also circled in red. There is a path "tarapan". A1 is now supposed to to create a timer at its own creation and this Timer:

Image

Should now create the Horse, which is set to follow the Path Tarpan, and therefore, gallop into the screen from the right to the left. When I do this with the normal create Actor function on the timer, the horse may appear at random in the first time, but then reappear constantly as soon as it has vanished from view. I could set a "destroy actor at path finish or at out of vision, but in fact this would prevent the hunter's arrow to take it down, even if it is out of view. 5and that is required. Since the Hunter can then move forward and find the prey.

Well actually I tried again with the non-szcript method and now, the horse does not appear also. So there must be a deeper Problem.

Re: Actor appearing once only

PostPosted: Fri Mar 20, 2009 10:05 pm
by Diana Kennedy
UPDATE: I just created another timer and tried it with this one and your script and this time it WORKS! So the old timer must have had a problem. Really dont't know what kind of problem it was, but it is not the first time that some timers just refuse to work. So thank you very much for your help !! :D

Re: Actor appearing once only

PostPosted: Sun Mar 22, 2009 3:54 pm
by BlarghNRawr
[quote="skydereign"]Oh, I forgot that you are new to scripting.
Code: Select all
// The two slashes mean the line is commented out, in gameEditor, it will turn the code light blue
// this means that it will ignore this code. You can put them in to explain your logic, or show what needs fixing
// etc. Another way to do this is,
/*
These are also commented out
eventhough I don't have the //
*/
// so just get rid of the two // in front of the CreateActor


can i use // in the actual script editor? i thought it was just in the forum... oops

Re: Actor appearing once only

PostPosted: Wed Mar 25, 2009 1:31 am
by jimmynewguy
kool looking and sounding game by the way, did u draw the sprites yourself? :lol:

Re: Actor appearing once only

PostPosted: Sun Mar 29, 2009 4:03 am
by Diana Kennedy
jimmynewguy wrote:kool looking and sounding game by the way, did u draw the sprites yourself? :lol:



Yes, I did. Glad you like it.