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 / Whats wrong with my simple script?

Author
Message
piXX3D
17
Years of Service
User Offline
Joined: 27th Mar 2007
Location: Nowhere
Posted: 20th Nov 2008 08:51
Hi all,

I have a platform, that when the player jumps on it, it opens a door. When they get off it closes it (it's like a puzzle kinda thing).

the way to keep the door open so they can get out is to place any entity on the platform so it holds down the platform, if you know what I mean...

I have this script here, linked to a remote door:



I don't understand why it doesn't work? The If Used field definitely has the remote door name. The script is definitely assigned to the Main AI field of the platform, which is dynamic.

I got this to work with another copy of the similar script, so I KNOW the problem lies in my modified copy:

This copy was taken from the Community Guide:



Now that script worked... but I have modified mine so that not only does any entity open the door, but also the player...

Could you help?
Leon Kennedy
16
Years of Service
User Offline
Joined: 7th Sep 2008
Location: Neither here nor there
Posted: 20th Nov 2008 14:56
It's hard to give you a hint and not give you the answer, but I'll try. Look at the following 2 lines of code and figure out what's different between them.

piXX3D
17
Years of Service
User Offline
Joined: 27th Mar 2007
Location: Nowhere
Posted: 20th Nov 2008 18:22
WOOP WOOP!

Thanks LK, I did it! Although I didn't really get whaat you meant... but it did give me a starting point. I wrote the whole thing out in a flowchart and realised what went wrong.

Below is the new, even simpler script, that works:

Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 21st Nov 2008 08:43 Edited at: 21st Nov 2008 08:46
Good job with the script!!!

I bet you could make it smaller, but it gets the job done, right?


The one and only,


Those who live in the past, are destined to insanity. Those who live only for the future, will be slaves to their ambitions.
Those who live in the moment... only they, are truly happy.
piXX3D
17
Years of Service
User Offline
Joined: 27th Mar 2007
Location: Nowhere
Posted: 21st Nov 2008 08:48
Er... I can see that it would open in the case of the player being on the pressure pad. But does it still work with entities being left there? Thats what I thought you'd need anywithinzone for...

But hey, if it works for both... I'll give it a try.

Nice one ply!

Nah, wait... surely you'd need



You know... the best way to find the answer... is to give it a go
Leon Kennedy
16
Years of Service
User Offline
Joined: 7th Sep 2008
Location: Neither here nor there
Posted: 21st Nov 2008 12:52
@pixx: What I was getting at was that at the end of the PLAYER and OBJECT statements you had a colon (the ":"), which when looked at by the scripting engine is the starting point of a command. If you don't have anything after the colon, the script fails to run as the engine just stops processing at that point.

Boy, I really wish the scripting engine had a compiler that would TELL us what fails in our scripts.
piXX3D
17
Years of Service
User Offline
Joined: 27th Mar 2007
Location: Nowhere
Posted: 21st Nov 2008 17:00
@LK, thats odd... I deleted both lines ";PLAYER:" and ";OBJECT:" since thats what I thought you were saying at first, but it made no difference? Surely that would happen since they're commented out anyway?

Anyway, thanks for the help though.

A compiler and debugger would be awesome.
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 21st Nov 2008 23:19
@piXX3D:

Heh, yeah, I retracted the snippet when I saw what you were trying to do.

What you want to have in this case is a "OR" operator, and in scripting that can be a tricky thing to accomplish.


Here's your lesson for today:

What do we want this to do, exactly?
- Activate the IfUsed when an object is in the zone
- Activate the IfUsed when the player is in the zone
- DeActivate the IfUsed when an object ISN'T in the zone
- DeActivate the IfUsed when the player ISN'T in the zone

Good... now if nothing is in the zone, we don't need to check for things NOT being in the zone, right? And if something's in the zone, we don't need to check for if MORE things are in the zone... right?
We only want to check for NOTHING being in the zone if something has already entered it. And we only need to check for SOMETHING being in the zone if nothing has entered it yet, or if nothing is currently in it.

And here's another hint:
In your script, let's suppose there is an object in the zone but the player is NOT... your script would activate the IfUsed, but then immediately DEactivate it since the player isn't in the zone.
Might want to find a way around that.


The one and only,


Those who live in the past, are destined to insanity. Those who live only for the future, will be slaves to their ambitions.
Those who live in the moment... only they, are truly happy.
Punk13
17
Years of Service
User Offline
Joined: 7th Oct 2007
Location: In EpikLand!
Posted: 22nd Nov 2008 07:09
Quote: "Boy, I really wish the scripting engine had a compiler that would TELL us what fails in our scripts. "


Dosent Editpad do that? if you go to options_keywords i think it checks for malfunctions right?


Xtinction Coming Soon.
piXX3D
17
Years of Service
User Offline
Joined: 27th Mar 2007
Location: Nowhere
Posted: 22nd Nov 2008 13:22
Ok, Ply... I am incredibly confused! Nah, not really, thanks for the help. I do get it (just!).

You say:
Quote: "In your script, let's suppose there is an object in the zone but the player is NOT... your script would activate the IfUsed, but then immediately DEactivate it since the player isn't in the zone."


How does that explain that when I test the game and put an object in the zone, then walk over to the door, it is opened? AHA! So I can walk to the door whilst a gas bottle is sitting on the pedestal and the door is opened.... Now I really am confused! I don't see why it should deactivate when the player isn't there anymore?

I am assuming you are talking about the code in the 5th post...

Please give me a virtual yelling at if I am being stupid and have misread something here...
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 23rd Nov 2008 00:48
Hah, oops, my example was backwards!

When the player is in the zone but an object is NOT, your script will deactivate the IfUsed, even though it seems apparent that you want it to work with the player being in the zone as well... am I right?

Try using your script on a zone near the door specified in the IfUsed to see what I mean. If you walk into the zone, the door will not open... you need to put an object in there.


The one and only,


Those who live in the past, are destined to insanity. Those who live only for the future, will be slaves to their ambitions.
Those who live in the moment... only they, are truly happy.
piXX3D
17
Years of Service
User Offline
Joined: 27th Mar 2007
Location: Nowhere
Posted: 23rd Nov 2008 11:45
Quote: "When the player is in the zone but an object is NOT, your script will deactivate the IfUsed, even though it seems apparent that you want it to work with the player being in the zone as well... am I right?"


No, actually, you're wrong!. well, your right about what I want to happen, but you're wrong about what does happen - I've just played it and somehow the door opens when theres an object in the zone. It closes when theres nothing in the zone. And it opens when theres just the player in the zone...

I can send you a video if you want...
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 23rd Nov 2008 12:27
Interesting!

What version of FPSC are you using?

And to double check, this is the script you are using, right?
;ARTIFICIAL INTELLIGENCE SCRIPT

;HEADER

DESC = OPEN ON OBJECT OR PLAYER POSITIONING

;triggers

:plrwithinzone=0:activateifused=0
:plrwithinzone=1:activateifused=1
:anywithinzone=0:activateifused=0
:anywithinzone=1:activateifused=1

;End of script[/quote]


The one and only,


Those who live in the past, are destined to insanity. Those who live only for the future, will be slaves to their ambitions.
Those who live in the moment... only they, are truly happy.
piXX3D
17
Years of Service
User Offline
Joined: 27th Mar 2007
Location: Nowhere
Posted: 23rd Nov 2008 13:10 Edited at: 23rd Nov 2008 13:11
Plystire...

You're going to be sitting at your computer sniggering at me now.

Cringe...

OK. I fluffed up. AGAIN.

The script I was using was:



I SWEAR I replaced it for some reason with this script:



So that explains it!

Either way... it works

Oh, no, WAIT!

Theres more!

I've just found another script... in my scriptbank/user folder... identically named to the script I have been using... but containing the code you said!

I remember now, I think I was meant to apply it to the object however I never got round to it. So instead it's always used the old script.

MEHMEHMEHMEHMEH!



BTW... just for the record... I'm using 113
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 23rd Nov 2008 20:36
Ah, yes, the old script appears to work, but what I was aiming for was simplifying it down to something like:




That is the script I made for this exact purpose when the compo started.

Feel free to use it, I promise it works very well.


The one and only,


Those who live in the past, are destined to insanity. Those who live only for the future, will be slaves to their ambitions.
Those who live in the moment... only they, are truly happy.
piXX3D
17
Years of Service
User Offline
Joined: 27th Mar 2007
Location: Nowhere
Posted: 23rd Nov 2008 21:11
Many thanks Ply, thank goodness this forum has people like you on it

Login to post a reply

Server time is: 2024-11-24 16:50:48
Your offset time is: 2024-11-24 16:50:48