Scripts / The script runs on a flashlight at a distance l It requires urgent help

Author
Message
Sergg
8
Years of Service
User Offline
Joined: 25th Aug 2015
Location:
Posted: 27th Jan 2016 12:41
Hello everybody! I urgently need your help. The script by smallg not working correctly. That is, if you move away from the object, which weighs on the script , the script stops working . I tried to put in the trigger zone - nothing changes. Thanks in advance.

flashlight_battery_life = {}
flashlight_battery_drain_delay = {}
local new_flashlight_battery_drain_delay = {}
local new_flicker_delay_off = nil
local new_flicker_delay_on = nil
local remaining_batteries = 0

local replace_battery_delay = 3 --how many seconds til battery reloading is complete
flashlight_batteries = 1 --number of batteries player starts with (can be 0, forcing player to have no flashlight until a battery is found)
max_flashlight_batteries = 5 --maximum batteries player can hold at one time
local flickering_on = 1 --set to 1 for flickering effect, 0 for constant on (when state is on)
local flickering_perc_start = 40 --what % of battery life the flickering will begin
local flicker_delay_off = math.random(1,3) --how many seconds before flashlight can go off again while flickering
local flicker_delay_on = 0.2 --how long til light comes back on while flickering

local sprite_duration = 6000
FlashlightImage1 = 0
FlashlightSprite1 = 0
FlashlightImage2 = 0
FlashlightSprite2 = 0

local current_battery = 1
local state = "off"
fpressed = 0

--sound at slot 0 is for replacing batteries
--sound at slot 1 is for clicking on/off
--set entity always active & use with flashlight_battery.lua for extra batteries

function flashlight_init(e)
FlashlightImage1 = LoadImage ( "scriptbank\\images\\Flashlight\\1.png" )
FlashlightSprite1 = CreateSprite ( FlashlightImage1 )
FlashlightImage2 = LoadImage ( "scriptbank\\images\\Flashlight\\2.png" )
FlashlightImage3 = LoadImage ( "scriptbank\\images\\Flashlight\\3.png" )
FlashlightImage4 = LoadImage ( "scriptbank\\images\\Flashlight\\4.png" )
flashlight_battery_life[0] = 0
flashlight_battery_drain_delay[0] = 0

for a = 1,flashlight_batteries do
flashlight_battery_life[a] = 100 --starting amount of life for the batteries
flashlight_battery_drain_delay[a] = 0.2 --how fast the batteries drain (in seconds)
end
end





PS - This is my adaptation of the script on the flashlight smallg, which works with lean .
PM
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 27th Jan 2016 12:44
SG's script works fine across the whole zone if the entity you use for the is set to always active.
Sergg
8
Years of Service
User Offline
Joined: 25th Aug 2015
Location:
Posted: 27th Jan 2016 13:05
Thanks!
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 27th Jan 2016 13:13
it does come with setup instructions in the post
Quote: "set an object to always active and give it flashlight.lua
set a sound a slot 0 for replacing the batteries and a sound at slot 1 for the clicking on and off if you wish.
press f to toggle the flashlight as normal
hold f to replace the battery (can be done at any time but you wont be able to return to a previous battery so use with care)"
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11

Login to post a reply

Server time is: 2024-04-28 13:13:21
Your offset time is: 2024-04-28 13:13:21