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 / Flashlight script help!

Author
Message
Mriganka
4
Years of Service
User Offline
Joined: 16th Jun 2014
Location: Virtuality
Posted: 14th Dec 2017 12:37 Edited at: 14th Dec 2017 12:48
So I have been working on a flash light script that uses a HUD. But now I have encountered a problem when using the scancodepressed is used. But it works fine with keypressed which I don't want to use as I want the flashlight to be toggleable. ANd also the battery decreases and can be replaced (no recharge). But I cannot get the toggling to work.

Conjured Entertainment
AGK Developer
13
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 14th Dec 2017 12:57 Edited at: 14th Dec 2017 13:57
It has been a long time since I scripted anything in FPSC, but I see a few things I would change in that script...

Move the state=4 to the end of the line at line 7

Same thing with line 9 with state=7

Last line.... why have two state=3 actions? (I would get rid of the first one so that all the actions moving to other states appear last for continuity)

I think the problem may be in state 4...

:state=4,varnotequal=FLASH 0,keypressed=33 0:state=7,etimerstart
:state=4,varnotequal=FLASH 0:etimerstart,state=5

If you are not pressing the key, then you go to state 7 before the other line gets checked.
The other line is essentially the same condition, because the key is not pressed in that line either.

I am really rusty because I have not used FPSC for several years now (been banging away at AGK), so bare with me as I slowly examine this and try to help.

try this
, as you can see I added a state=8 that checks for the key release before moving to state=4

Then, in state=4 I changed your keypressed to a 1 to detect a second press for the toggle.

I also added a keypressed 0 to check for a key release in state 7 too since we pressed in state 4 to get there

Not sure if this will work, because I am not able to test, and I usually write my own sripts, so editing yours is hard when I have been away this long, but maybe we'll get lucky.

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
Mriganka
4
Years of Service
User Offline
Joined: 16th Jun 2014
Location: Virtuality
Posted: 14th Dec 2017 17:53
Hello Conjuring Entertainment! Thank you for introducing the flag. It was a bit buggy but it worked. I introduced a few flags in places so the script now works almost flawlessly.

Conjured Entertainment
AGK Developer
13
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 14th Dec 2017 21:52
Glad I could help, and I am glad you got it sorted out.

I almost didn't want to post since it had been so long since I have scripted in FPI, but I am glad I did.

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
Mriganka
4
Years of Service
User Offline
Joined: 16th Jun 2014
Location: Virtuality
Posted: 15th Dec 2017 05:55
One more thing you helped me realize is that I almost never put in flags and checks and code making them not run many a time. It's one of my biggest problems. I will work on solving that!
Stealth Sin
4
Years of Service
User Offline
Joined: 18th Nov 2013
Location:
Posted: 24th Dec 2017 04:23
Mriganka, do you mind if I copy your script to test, I've been working on a freak ton of custom scripts involved with vairables and fun stuff like that. It just appeals to me because I just ponder about :setvar being as :state=1. I usually keep that in the same state underneath dimvar to keep things orginized. if I can come up with anything I'll let you know. I'll see if also I can create you a baterie model for your flash light. are you intrested?
Anthony Gonzales
Mriganka
4
Years of Service
User Offline
Joined: 16th Jun 2014
Location: Virtuality
Posted: 24th Dec 2017 06:26
The script works awesome. You can integrate it with HUDs. And everything I make is always modular for max customization. You can copy the script and do whatever you like. But if it's commercial then please credit me.

PS - I am working on a scriptpack which a shit tonne of scripts. Do you have any experience doing AI? I am needing some help on that aspect.
Stealth Sin
4
Years of Service
User Offline
Joined: 18th Nov 2013
Location:
Posted: 25th Dec 2017 01:28
Hmm, what kinda of AI? because DarkAI is not my strong point. the only best AI I've ever made was a slenderman script with sanity xD
Anthony Gonzales

Login to post a reply

Server time is: 2018-09-23 10:10:11
Your offset time is: 2018-09-23 10:10:11