Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

FPSC Classic Scripts / Variable Checking

Author
Message
knxrb
FPSC Tool Maker
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: United Kingdom
Posted: 1st Feb 2009 15:51 Edited at: 1st Feb 2009 15:52
Hi guys, I'm having a bit of trouble with my scripts

I've made a script that goes is the main script for a dynamic entity.
It checks global variable 101 and checks if it is equal to 1.
If it is then it destroys the entity and if it isn't it goes back to the start of the script and checks again etc...

I've also got another script that goes in the main script in a trigger zone.
It basically needs to set global variable 101 to 1 when the player enters the zone and then the entity that checks if the variable is 1 should be destroyed.

I've tried all sorts of different ways but I always get the same outcome: When the game starts the entity is destroyed immediately without the variable being 1!?

Please try and help me this is it's really vital for my game

I've attached the scripts to the post in a .zip file.
Dynamic Entity - Main Script: Check Var.fpi
Trigger Zone - Main Script: Set Var 1.fpi

Thanks in advance, knxrb

Attachments

Login to view attachments
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 1st Feb 2009 21:45 Edited at: 1st Feb 2009 22:05
First of all, you could have used a code snippet and saved me the trouble of the download since they are so small.

So, let's take a look....


Check Var


globalvar=101 is an action not a condition so it is in the wrong place.

So, let's try it differently, by removing the conditions from state=0.
Also if you are going to destroy, then why goto another state because the script will end anyway.




Now for the Set Var


Again let's change the state=0 to remove any conditions. (state=0 is an initialization state)
Also take note: There is no need to call a move to state=0 because we are already in that state.
The plrwithinzone should be plrwithinzone=1 even if it does work the other way, this way is less confusing. (1=true, 0=false)
We won't need to do anything else again here either since the other script will destroy, so we can move to a nonexisting state after setting the variable.




If we did want it to keep working for later use, then we could also check for when they are out of zone and set back to zero.
I separated the plrwithinzone=x to two states because we do not want to continually keep setting the variable while either condition is true.




Try these and let me know if it works ok.

knxrb
FPSC Tool Maker
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: United Kingdom
Posted: 2nd Feb 2009 15:39
Hi Conjured, thanks for your reply and tutorial

I'm still getting the problem with the entity getting destroyed before it's told to.

The entity has got the 'check var' script in it's main script and a trigger zone has the 'set var' script in it's main script but the entity still destroys itself at the start of the game

I've tried it with dynamic entities and static but it's always the same

knxrb

Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 2nd Feb 2009 19:32 Edited at: 2nd Feb 2009 19:46
You forgot the desc, and I overlooked that, sorry.

Also, why are we using global varibale 101 when they are limited to 0-99 ???

They should read...



and



Try that, and if it still doesn't work then I will play with them to see if I overlooked anything else.

knxrb
FPSC Tool Maker
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: United Kingdom
Posted: 2nd Feb 2009 20:45
I've copy and pasted the scripts directly and I've still got the same problem

If you can think of another way to script it then what I need is a script that will destroy a certain entity when requested(entered zone, killed enemy, etc...).

knxrb

Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 3rd Feb 2009 06:01
I tested it and it worked fine for me.

Here is a pic of the way I set it up in the editor...

The crate got the destroy script and the trigger zone got the withinzone script.

I'll post a video next showing that it works.

Attachments

Login to view attachments
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 3rd Feb 2009 06:05 Edited at: 3rd Feb 2009 06:10
Here is a video showing the crate disappear when I walk into the zone.

You are not accidently starting in the trigger zone are you ??

PS
I did not use any spaces in the file names.

Attachments

Login to view attachments
knxrb
FPSC Tool Maker
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: United Kingdom
Posted: 3rd Feb 2009 21:30
Thanks for your help, I've removed the spaces and it's working fine

knxrb

Login to post a reply

Server time is: 2024-11-24 18:45:13
Your offset time is: 2024-11-24 18:45:13