-- LUA Script - precede every function and global member with lowercase name of script + '_main' g_sulphurscollected = g_sulphurscollected or 0 g_saltpeterscollected = g_saltpeterscollected or 0 g_carbonscollected = g_carbonscollected or 0 g_fhammer = g_fhammer or 0 local chemscollected = {} local chemsmined = {} local chemsscale = {} local chemschances = {} local chemstimer = {} local random = math.random function survival_chemical_mining_init(e) chemsscale[e] = random(70, 100) Scale(e, chemsscale[e]) end function survival_chemical_mining_main(e) local chance = chemschances[e] if chance == nil then chemschances[e] = {sulphur = random(1, 7), saltpeter = random(1, 7), carbon = random(1, 7)} return end if g_fhammer >= 1 then if not chemscollected[e] then local Ent = g_Entity[e] PDX, PDY, PDZ = Ent.x - g_PlayerPosX, Ent.y - g_PlayerPosY, Ent.z - g_PlayerPosZ if PDX*PDX+PDY*PDY+PDZ*PDZ < 200*200 then if not chemsmined[e] then PromptDuration("This area looks good to Mine for resources.", 3000) chemsmined[e] = true chemstimer[e] = g_Time + 100 * 1000 -- 100 seconds end if g_PlayerGunFired == 1 then PlaySound(e, 1) chemscollected[e] = true end end end else return end if chemscollected[e] and g_PlayerGunFired == 0 then chemsscale[e] = chemsscale[e] - random(1, 3) Scale(e, chemsscale[e]) chemscollected[e] = false if random(0, 10) > chance.sulphur then g_sulphurscollected = g_sulphurscollected + 1 end if random(0, 10) > chance.saltpeter then g_saltpeterscollected = g_saltpeterscollected + 1 end if random(0, 10) > chance.carbon then g_carbonscollected = g_carbonscollected + 1 end PromptDuration("You have " .. g_sulphurscollected .. " Sulphur, " .. g_saltpeterscollected .. " Saltpeter and " .. g_carbonscollected .. " Carbon.", 2000) if chemsscale[e] < 10 then Destroy(e) end end if chemsmined[e] and g_Time > chemstimer[e] then chemsmined[e] = false chemstimer[e] = math.huge end end