Scripts / "search for flashlight to can use it" idea script

Author
Message
JC LEON
14
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 8th Mar 2016 00:38
inspired from great smallg flashlight scripts i want to know if is there a way to improve the flashlight dynamic and want to know if is there a way to have flashlight disabled at the game start that can be activated only after player found a flashlight/torch charged or with batteries...


many of these are all done from great smallg but it will be cool if we can start our game without flashlight function active and we must search for a pickup flashlight to use it


many thkas in advance for any help
PC Specs:

Q9550@3,8GHZ - 8GB RAM - SVGA R9 280 3GB GDDR5 - HDD WD 1500TB
PM
MChapman
9
Years of Service
User Offline
Joined: 19th May 2015
Location: USA
Posted: 12th Mar 2016 15:47
You could make a script that just disables the flashlight and put it in the ol barrel and all it does is disable the flashlight.

SetFlashLightKeyEnabled(V)

V=1 for on allowing the flashlight to be used

V= 0 for off preventing the flashlight from being used.

https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
There is the link to the lua guide of all or most commands and there is what you need in the script to start in the barrel.
Markchapman10 is my Skype let's have some dev talk.
JC LEON
14
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 13th Mar 2016 15:09
ok thanks,,, but doing that flashlight remain deactivate forever... how can I renable flashlight function when i found a flashlight i my level?
PC Specs:

Q9550@3,8GHZ - 8GB RAM - SVGA R9 280 3GB GDDR5 - HDD WD 1500TB
PM
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 13th Mar 2016 15:33 Edited at: 13th Mar 2016 15:47
As I wrote in the reply to the thread you already asked this in:

You need a model for the script to disable the torch at start, this needs to be an always active object, add this script to it:

disable_flashlight.lua


Then you need a model for your torch, add the following script to this model:

collect_flashlight.lua


as soon as you walk up to the flashlight it will activate the flashlight key for you.

Remember entities that have scripts need to be set to dynamic, that means change static to no in their properties.

i7, NV960 4GB, 16GB memory, 2x 4TB Hybrid, Win10.
i5 , AMD 6770 1GB, 8GB memory, 512GB Generic SATAIII + 2TB Seagate Baracuda SATAIII, Win7.
i3, Radeon integrated graphics, 4GB memory, 512gB Generic SATAII, Win8.1.
Q6600, Intel integrated graphics, 2GB memory, 180GB Generic SATAII, WinXP.

Attachments

Login to view attachments
JC LEON
14
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 13th Mar 2016 20:06 Edited at: 13th Mar 2016 20:26
works... many thaks belidos...but

how can i integraate all this to make them works with smallg flashlight+batteries script??

how can i activate smallg scripts when i collect my flashlight?
PC Specs:

Q9550@3,8GHZ - 8GB RAM - SVGA R9 280 3GB GDDR5 - HDD WD 1500TB
PM
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 13th Mar 2016 20:13 Edited at: 13th Mar 2016 20:19
You'd have to ask smallg, I have an idea, but I'm not at my gameguru pc to test it.

I think instead of using my first script you woud use an editec version of small's flashlight scrip.

You'd have to create an array as a reference before the init, something like:



then in the init you would have something like:




and then in the main you would wrap the flashlight script in:



then in my collect flashlight script put:


after the line:



I cant check it at the moment and won't have time until tomorrow night, so if nobody else has responded before then I#ll test it out and post the full scripts for you.

i7, NV960 4GB, 16GB memory, 2x 4TB Hybrid, Win10.
i5 , AMD 6770 1GB, 8GB memory, 512GB Generic SATAIII + 2TB Seagate Baracuda SATAIII, Win7.
i3, Radeon integrated graphics, 4GB memory, 512gB Generic SATAII, Win8.1.
Q6600, Intel integrated graphics, 2GB memory, 180GB Generic SATAII, WinXP.
JC LEON
14
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 13th Mar 2016 20:32 Edited at: 13th Mar 2016 20:33
thaks for your repaly but i'm really noob at coding...i'll try but -i think i didnd understood very well


in
local is_flashight_active = {} ---flashlight is intended the flashlight.lua smallg script?

btw is there a way in lua to acrivare a certain script by another?? so when i collect my flashlight smallg script function become active?
PC Specs:

Q9550@3,8GHZ - 8GB RAM - SVGA R9 280 3GB GDDR5 - HDD WD 1500TB
PM
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 13th Mar 2016 20:47 Edited at: 14th Mar 2016 18:02
You could hide an entity with small's script in it then use the collect script to unhide it.

Place an item with my script that disables the flashlight, make it always active, and make sure it's static = no (in properties).

Place another item with small's script attached to it, make it always active, make sure it's static = no (in properties), and in properties change spawn at start to no.

Then in the collect_flashlight/lua script add this line in the init section:
SetFlashLightKeyEnabled(0)

Then in the main section, between SetFlashLightKeyEnabled(1) and Destroy(e)
Spawn(e)

Don't forget to change the e in Spawn(e) to the number of the entity with small's script in, to find that number simply hover your moouse over the item with small's script in and at the bottom of the screen on the left it will tell you the object number. So if the object with small's script in is entity number 39 then change the line to Show(39) and so on.

i7, NV960 4GB, 16GB memory, 2x 4TB Hybrid, Win10.
i5 , AMD 6770 1GB, 8GB memory, 512GB Generic SATAIII + 2TB Seagate Baracuda SATAIII, Win7.
i3, Radeon integrated graphics, 4GB memory, 512gB Generic SATAII, Win8.1.
Q6600, Intel integrated graphics, 2GB memory, 180GB Generic SATAII, WinXP.
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 13th Mar 2016 21:06 Edited at: 23rd May 2016 22:15
OK, managed to get access to GG and test it, it worked, here's the replacement scripts.

1. put flashlight3.lua on a not static item (make it always active).
2. put collect_flashlight2.lua on the item you want to collect (make sure it's not static).
3. flashlight_battery.lua goes on the batteries,(make sure the battery is not static).

Job done, it will supress the flashlight until you collect the item.

Press F to use the flashlight once you have collected it, and hold press and hold F to load a battery.

i7, NV960 4GB, 16GB memory, 2x 4TB Hybrid, Win10.
i5 , AMD 6770 1GB, 8GB memory, 512GB Generic SATAIII + 2TB Seagate Baracuda SATAIII, Win7.
i3, Radeon integrated graphics, 4GB memory, 512gB Generic SATAII, Win8.1.
Q6600, Intel integrated graphics, 2GB memory, 180GB Generic SATAII, WinXP.

Attachments

Login to view attachments
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 13th Mar 2016 21:46
Hmn, gonna need smallg to step in on this one. My changes to the scripts work to an extent, but for some reason they mess up the batteries, when you collect a battery then use it the torch stays at 0%, might need to move something around and I have no idea what. Help me smallg you're my inly hope

i7, NV960 4GB, 16GB memory, 2x 4TB Hybrid, Win10.
i5 , AMD 6770 1GB, 8GB memory, 512GB Generic SATAIII + 2TB Seagate Baracuda SATAIII, Win7.
i3, Radeon integrated graphics, 4GB memory, 512gB Generic SATAII, Win8.1.
Q6600, Intel integrated graphics, 2GB memory, 180GB Generic SATAII, WinXP.
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 13th Mar 2016 22:17
i think you're overthinking it, just set the object with my flashlight script to not spawn at start and then spawn it when you collect the flashlight (from your earlier script)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
JC LEON
14
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 13th Mar 2016 22:45 Edited at: 13th Mar 2016 22:47
Quote: "Hmn, gonna need smallg to step in on this one. My changes to the scripts work to an extent, but for some reason they mess up the batteries, when you collect a battery then use it the torch stays at 0%, might need to move something around and I have no idea what. Help me smallg you're my inly hope "


same problem here but this is related to original script since this happen with the original too... but if you collect more than a battery the counter refrsh correcly and the flashlight recharge too....posted on the related smallg thread


@ Belidos.. many many thanks... scripts work like a charm except for he bug you posted too...
PC Specs:

Q9550@3,8GHZ - 8GB RAM - SVGA R9 280 3GB GDDR5 - HDD WD 1500TB
PM
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 14th Mar 2016 07:51 Edited at: 14th Mar 2016 07:58
Quote: "i think you're overthinking it, just set the object with my flashlight script to not spawn at start and then spawn it when
you collect the flashlight (from your earlier script) "


Which is exactly what I suggested three posts up from yours, I just wanted to see if I could script it first to see if my learning brains working

Btw, as J and myself have mentioned here there's a bit of a bug with the flashlight script. Without a battery hitting F will cycle it from 100% to 0% in under a second, however a second later it bumps back up to 100% with no batteries. If you collect a battery and load it, it doesn't matter what number you give it, the battery drains in under a second and it doesn't clear the battery counter. If you pick up two batteries and load one then you get the full time of that battery, but when it drains and you try to load the second battery it says you have no spare batteries despite having one in your display. It looks like an issue with the battery count registering the first battery for display but not registering it from 0 batteries for the actual charge.

And, likewise, if you turn off the regen function, the torch will show 0% and 0 batteries correctly, when you pick up a battery it will display 1 correctly, when you load the battery it clears the 1 correctly, however the flashlight is still 0%, picking up a second battery makes it work right.

i7, NV960 4GB, 16GB memory, 2x 4TB Hybrid, Win10.
i5 , AMD 6770 1GB, 8GB memory, 512GB Generic SATAIII + 2TB Seagate Baracuda SATAIII, Win7.
i3, Radeon integrated graphics, 4GB memory, 512gB Generic SATAII, Win8.1.
Q6600, Intel integrated graphics, 2GB memory, 180GB Generic SATAII, WinXP.
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 14th Mar 2016 17:53
yh not sure what i was reading but i think i read show(e) and you meant spawn(e) which was confusing me, i should have read the entire script
for the bug, i believe i have fixed it and will update the scripts again.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
JC LEON
14
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 14th Mar 2016 21:48
hi belidos... smallg fixed the scripts and ow the works fine... can you please reupload your scirpts with working version???

many thanks...

script flashligt_battery



script flashlight2

PC Specs:

Q9550@3,8GHZ - 8GB RAM - SVGA R9 280 3GB GDDR5 - HDD WD 1500TB
PM
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 15th Mar 2016 08:40
You only need to update three lines in flashlight3.lua. the other script isn't effected.

here you go.

i7, NV960 4GB, 16GB memory, 2x 4TB Hybrid, Win10.
i5 , AMD 6770 1GB, 8GB memory, 512GB Generic SATAIII + 2TB Seagate Baracuda SATAIII, Win7.
i3, Radeon integrated graphics, 4GB memory, 512gB Generic SATAII, Win8.1.
Q6600, Intel integrated graphics, 2GB memory, 180GB Generic SATAII, WinXP.

Attachments

Login to view attachments
JC LEON
14
Years of Service
User Offline
Joined: 22nd Apr 2010
Location:
Posted: 17th Mar 2016 22:20
works great,,, many thanks.. belidos...
PC Specs:

Q9550@3,8GHZ - 8GB RAM - SVGA R9 280 3GB GDDR5 - HDD WD 1500TB
PM

Login to post a reply

Server time is: 2024-12-22 15:31:13
Your offset time is: 2024-12-22 15:31:13