-- LUA Script - precede every function and global member with lowercase name of script + '_main' -- Player Collects Health --set to 1 to make player press E to heal (otherwise healing will happen automatically over time set) local manual_mode = 1 --how much to heal for each delay local heal_per_tick = 100 --how long to wait before heal takes effect (to simulate applying bandage - if leave zone then heal is reset) local tick_time = 1000 --max times zone can be used (-1 for infinite) local uses_remaining = -1 local new_tick_time = nil local max_health = nil local healing = {} pressed = 0 function healingzone_init(e) healing[e] = 0 end function healingzone_main(e) if max_health == nil then max_health = g_gameloop_StartHealth return end if uses_remaining > 0 or uses_remaining == -1 then if g_Entity[e]['plrinzone']==1 and g_PlayerHealth > 0 then if g_PlayerHealth < max_health then if healing[e] == 0 then new_tick_time = nil if manual_mode == 1 then if uses_remaining > -1 then --FieldMessage(e, 3, "The Medicine looks ok!", "Press E to take", 1) TextCenterOnX(50,80,3,"This Medicine looks OK! , Press E to take. ("..uses_remaining.." uses left)") else TextCenterOnX(50,80,3,"This Medicine looks OK! , Press E to take") end if g_KeyPressE == 1 and pressed == 0 then pressed = 1 healing[e] = 1 end else TextCenterOnX(50,80,3,"This Medicine looks OK!") healing[e] = 1 end end else TextCenterOnX(50,80,3,"This Medicine looks ok but you don't need it right now") end end elseif healing[e] == 0 then Destroy(e) end if healing[e] == 1 then if GetPlayerInZone(e) == 0 then healing[e] = 0 return end if new_tick_time == nil then new_tick_time = g_Time + tick_time end TextCenterOnX(50,80,3,"Healing... "..(math.ceil((new_tick_time-g_Time)/1000)).."s") if g_Time >= new_tick_time then if uses_remaining > -1 then uses_remaining = uses_remaining - 1 end PlaySound(e,0) if g_PlayerHealth+heal_per_tick < max_health then SetPlayerHealth(g_PlayerHealth+heal_per_tick) else SetPlayerHealth(max_health) end healing[e] = 0 end end if g_KeyPressE == 0 then pressed = 0 end end