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 / Simple Scripting - I'm trying to learn

Author
Message
Bootlicker
15
Years of Service
User Offline
Joined: 29th Mar 2009
Location: Germany
Posted: 24th Dec 2010 21:51
Hey all,

I have no idea why this simple script wont work. I want it so that when i enter a trigger zone and press enter a HUD pops up, then when I either leave that zone or press enter again the HUD disappears. Then for it to loop again incase I want to go back. I am truly stuck.



Thanks,

Ben


Gencheff
14
Years of Service
User Offline
Joined: 12th Jun 2010
Location: UK by way of USSR
Posted: 24th Dec 2010 21:57
I'm a bit too lazy to test this,but you wrote the last line wrong.You have 2 :'s .

Your last line should be
:state=12,scancodekeypressed=28:hudfadeout=hudone,state=10

Bootlicker
15
Years of Service
User Offline
Joined: 29th Mar 2009
Location: Germany
Posted: 24th Dec 2010 22:01
Quote: "I'm a bit too lazy to test this,but you wrote the last line wrong.You have 2 :'s .

Your last line should be
:state=12,scancodekeypressed=28:hudfadeout=hudone,state=10
"


yeah that still doesnt work

The HUD pops up, just it wont go away XD


BlackFox
FPSC Master
16
Years of Service
User Offline
Joined: 5th May 2008
Location: Knight to Queens Bishop 3
Posted: 24th Dec 2010 22:02 Edited at: 24th Dec 2010 22:02
Perhaps this?



- BlackFox

RPG Mod- Create a world full of adventure
Bootlicker
15
Years of Service
User Offline
Joined: 29th Mar 2009
Location: Germany
Posted: 24th Dec 2010 22:08
that one works well the first time. but if you try to go back on read it again, it fades out straight away after pressing enter. So I press enter to make it appear (the second time) then it just fades immediately.

wow, scripting is hard


BlackFox
FPSC Master
16
Years of Service
User Offline
Joined: 5th May 2008
Location: Knight to Queens Bishop 3
Posted: 24th Dec 2010 22:21


- BlackFox

RPG Mod- Create a world full of adventure
Bootlicker
15
Years of Service
User Offline
Joined: 29th Mar 2009
Location: Germany
Posted: 24th Dec 2010 22:30
ok, that one doesnt work a second time full stop. but thats fine

Thank you blackfox and gencheff


Gencheff
14
Years of Service
User Offline
Joined: 12th Jun 2010
Location: UK by way of USSR
Posted: 24th Dec 2010 22:35


How about this (BlackFox's suggestion with slight modification)
There was an error in the first place btw

Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 24th Dec 2010 22:49
You're doing good for just learning to script, Bootlicker! At least you're not making many of the common mistakes, and you're using the commands properly.

What you need to work on now is the logic of the script. Remember that it's just a machine and it only does exactly what you tell it to, down to the "t". If you can imagine following the script, exactly the way the engine follows it, it helps to see where problems are.

Here's what you said the script should do:
Quote: "I want it so that when i enter a trigger zone and press enter a HUD pops up, then when I either leave that zone or press enter again the HUD disappears. Then for it to loop again incase I want to go back."


That's perfect! But, sadly, the engine can't read english!

I'll step through your description and write a script as I go, so you can see how to apply your english to a script.

Quote: "I want it so that when i enter a trigger zone and press enter a HUD pops up"


I'll borrow the HUD loading line from Blackfox's script, then we'll turn the above quote into a line of script!



The way you use states can be a little better, but so far you're doing good. Remember that it's not always necessary to use a state, and if you can avoid using a state while keeping good logic, you should do so.

Next line:
Quote: ", then when I either leave that zone or press enter again the HUD disappears."


This one will require a few lines, since you have two different things to check for (Leaving the zone and pressing the key again(Which will require two lines in itself))



When the script reaches state 2, the hud is already shown, but we need to wait for the player to STOP pressing the key before we check if the key has been pressed again. So once "scancodekeypressed=0" happen, we go to state 3 and wait for the keypress to hide the HUD.
The last line takes care of itself and doesn't even need a state! If the player isn't in the zone, we fade out the HUD and go back to state 1. This should happen no matter WHAT state the script is in.

Quote: "Then for it to loop again incase I want to go back."


Well, this one is already taken care of! By going back to state 1 when we hide the HUD, it will "loop".


So, we end up with the following script!




I hope this helps you to better learn scripting.


The one and only,


Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Bootlicker
15
Years of Service
User Offline
Joined: 29th Mar 2009
Location: Germany
Posted: 24th Dec 2010 22:56
wow, thanks ply!

I never realised that scripting was so hard, although I've never really looked at any tutorials just opened scripts, see what they do and study how they were written. Even though that was my first attempt at a script it did cause my pretty mega rage.

Thanks for the help everyone Ill be sure to come back here to keep checking on what your tips are

Thanks,

Ben


Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 24th Dec 2010 23:37
No problem! Scripting is like anything else. It gets easier the more you do it.

Merry Christmas!


The one and only,


Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Bootlicker
15
Years of Service
User Offline
Joined: 29th Mar 2009
Location: Germany
Posted: 28th Dec 2010 22:24
ply i added you on msn so i can ask a few questions

anyways, this script isnt working now? Yet I have no idea whats wrong with it

I want it so that when I'm over the entity a little i get hurt. But nothing happen at all.



Thanks,

Ben


Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 30th Dec 2010 03:00
Should the player be within the proximity of the entity before taking damage? If so, you'll want to include a distance check in there (plrdistwithin)

Second, you've missed the second colon on the second line:
Quote: ":state=1:plraddhealth=-5"


Sometimes it's not necessary to use states, and using them will only hurt your script. Given the logic in your script, when the player is 10 units or more above your entity, it moves to state 1. State 1 deals damage to the player. But since the script never LEAVES state 1, the player will continue to take damage no matter what they do. This logic should probably be corrected.


The one and only,


Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Cross Hair Games
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Canada Eh\'
Posted: 31st Dec 2010 05:04
Hey, I've just surged to try to learn scripting, and I've been looking at the scripts on here. And like ply said, that it continues to hurt the player even after he leaves the entity.
I'm just gonna give this a shot, so please tell me if this won't work.
So if you want him to be hurt only while over the entity then should you add this line after state=1. :
:state=2:plrlower=10:state=3
:state=3:plraddhealth=0

Would you add that? So that it stops lowering health and stabilizes? That was my very first attempt at anything with scripting so please help If I did something wrong.
old_School
15
Years of Service
User Offline
Joined: 29th Aug 2009
Location:
Posted: 31st Dec 2010 07:54
Why not just use a hurt zone for that and just edit the damage in there?
Cross Hair Games
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Canada Eh\'
Posted: 31st Dec 2010 08:03
I thought of suggesting that too, but I think he wants to dig into scripting and get a feel for it, like I am.
Do you think the script line I suggested would solve the problem keeps getting hurt even after leavin the entity?

If you don't try, you fail.
old_School
15
Years of Service
User Offline
Joined: 29th Aug 2009
Location:
Posted: 31st Dec 2010 08:17 Edited at: 31st Dec 2010 08:21
I'd need to review a tech manuel for the keywords in FPSC. Speaking of is there a scripting Keyword light anywhere? The Manuel in catagories, I preffer a list of keywords.

Edit:
Never mind I see what he was going for now. The script is designed it appears to hurt you in the zone and lower your health to 10. Once your health hits 10 it stops hurting you.

I think it needs a Else statement or If maybe.

Else

plrhelath = 9 state:0 return;

I dont think thats correct but general just of what he is missing i think. I think thats a bit of c# creeping into DBPro codeing lol Im not sure if DBPro uses If or Else Statements and returns in that form.
Cross Hair Games
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Canada Eh\'
Posted: 31st Dec 2010 08:21
I believe there's keyword > lighton and > lightoff
To place after a state as a condition, or action result, like in the script I just posted

If you don't try, you fail.
old_School
15
Years of Service
User Offline
Joined: 29th Aug 2009
Location:
Posted: 31st Dec 2010 08:23
I think lighton and lightoff reffers to lightmaps condition and not a trigger for players.
Cross Hair Games
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Canada Eh\'
Posted: 31st Dec 2010 08:25
Ohk, I'm just starting so I know not slot bout scripting,
And since it's not a player trigger, could you look at my script post and tell me if I had a mistake? It's a very small script

If you don't try, you fail.
old_School
15
Years of Service
User Offline
Joined: 29th Aug 2009
Location:
Posted: 31st Dec 2010 08:54
Im probly the worse person to ask for script troubleshoting advice for DBPro. I mainly know C# and C++. DBPro a beast of its own. I can read the code and understand it but not good enough yet to really write from scratch with it. Still a newb to DBPro lang my self sorry.

Yours I dont think will work. I read in the FPSC guide something earlier about only being able to have 1 state per script or something. I need to reread it cause that don't make sense to me but if thats tru and the case. Then no your would not work, otherwise it should be correct. Test it and find out I guess. Programmings all trial and error no big secret lol
Cross Hair Games
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Canada Eh\'
Posted: 31st Dec 2010 09:06
Ohm thanks! Yea I looked at it more and I found a way to better revise it:
what do u think of that instead?
Im still asking you because you said you can read and understand what it means, so what this one make better sense?
Also I'm gonna go to sleep so I'll check back in, in the morning. I've just been really stressed with some thing happening with my girlfriend

If you don't try, you fail.
Cross Hair Games
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Canada Eh\'
Posted: 31st Dec 2010 09:10
Sorry about double post*
what script did you look at? The one where I did just a line up there^?
if so, my bad, I ment the one where I made a thread for it, and thats the one I thought you were talking about too. Sorry should have been more specific ( proves I'm stressed )

If you don't try, you fail.
old_School
15
Years of Service
User Offline
Joined: 29th Aug 2009
Location:
Posted: 31st Dec 2010 09:38
Im not sure but i dont think its right and you still need to clean it up looks like. Basicly you want a light to turn on with a plr is with in tiles? Might want to adjust that, seems like a large distance.

:state=0:state=1
:state=1,activateused:state=2
:state=2,lighton:plrdistwithin=300:state=3
:state=3:scancodekeypressed=28:state=4
:state=4,lightoff
:state=4:plrdistwithin=300,scancodekeypressed=28:state=2

;End of Script


This still dont look right to me. Id set it up as a zone. Try reviewing zone activate if any script. Its a core script i think. This just dont look right no matter how I play with it in my head.
Cross Hair Games
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Canada Eh\'
Posted: 31st Dec 2010 18:38
Ohk thanks, like I'm trying to make it so that when the player is close to the light, he can press enter to turn it off, then press enter again to turn it on, and so the script is supposed to cycle. And I agree, 3 segments is pretty big, that leads to about a 7x7 area around the light, maybe i should do
plrdistwithin=150
what that be better?

If you don't try, you fail.
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 1st Jan 2011 02:03
There are some elementary mistakes in your script, old_School.

Many of your lines contain bad formatting. The format of each and every line of code in the script should be like this:
[colon] [conditions] [colon] [actions]

Notice there should only ever be 2 colons per line. Also, make sure that conditions come after the first colon, while actions come after the second colon. Actions are not recognized in the conditions list, while conditions are not recognized in the actions list.


As for your light script, you should probably take a look into the door script (The USE door) since it has similar behavior to what you're wanting. Combine that script with one of the scripts for dynamic lights (they turn on and off when actived, you would just change this to turning on/off when player presses use key)


The one and only,


Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Cross Hair Games
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Canada Eh\'
Posted: 1st Jan 2011 02:55
thanks! so like take part of the use door script and combine it with the light script and use that for the light?

If you don't try, you fail.
old_School
15
Years of Service
User Offline
Joined: 29th Aug 2009
Location:
Posted: 1st Jan 2011 04:53
Sorry Ply It was like 3 am lol I told him I did not think mine was even right lol

Login to post a reply

Server time is: 2024-11-24 14:37:31
Your offset time is: 2024-11-24 14:37:31