[V] IdolNinja
Volition Staff
Here's a revised Sandbox+ sr3_city.lua that creates a new hellrider thread and toggles on and off your function with R+PGUP so you can see how it works. I'll likely be revising some names and using that as a standard effects function for users to cycle through different effects.
This is just the important stuff with a couple comments here and there from me (NOTE: The attached lua has this in working form.
This is just the important stuff with a couple comments here and there from me (NOTE: The attached lua has this in working form.
Code:
-- Attach effects thread vars
Hellrider_Handle = INVALID_THREAD_HANDLE --<- new thread var
HELLRIDER_THREAD_ON = 1 --<- var for the do while loop
hellflame_toggle = false --<- boolean that is switched when R+PGUP is invoked
-- new thread created within the sr3_city_main() function. The main function is called one time at loading of your save
function sr3_city_main()
Keycombo_Handle = thread_new("keycombo_thread")
TOD_Handle = thread_new ("tod_thread")
Hellrider_Handle = thread_new("hellrider_thread")
end
-- this is the thread that got created. Notice the hellflame_toggle conditional block. Since we declared it as false then that conditional block
-- will never resolve until we change it to true coming up in the actual R+PGUP conditional block
function hellrider_thread()
while HELLRIDER_THREAD_ON == 1 do
if hellflame_toggle then
explosion_create("Ammo - Incendiary", LOCAL_PLAYER)
end
delay(.5)
end
end
elseif player_action_is_pressed("CBA_OFC_PICKUP_RELOAD") then -- R(eload) - SPECIAL COMMANDS
--..
-- Each time you push this keycombo it flips the hellflame_toggle boolean. When true the above thread that is always running
-- will create those explosions
elseif player_action_is_pressed(B_PGUP) and not RELOAD_PUSHED then
if hellflame_toggle then
hellflame_toggle = false
sandboxplus_message("Hellrider effect DEACTIVATED")
else
hellflame_toggle = true
sandboxplus_message("Hellrider effect ACTIVATED")
end
RELOAD_PUSHED = true