Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Labs now only produce science points when science-packs available. #449

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion MAIN-DyTech-Dynamics/control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ script.on_init(function()
fs.Startup()
Power.Startup()
AutoResearch.Startup()

for id, lab in pairs(game.get_surface(1).find_entities_filtered {
area = {{-200,-200},{200,200}},
name = "lab",
type = "lab",
force = "player"}) do
lab.active = false
end
end)

script.on_load(function()
Expand Down Expand Up @@ -433,4 +441,4 @@ remote.add_interface("DyTech-Dynamics",
Startup = function()
fs.StartupResearchSystem1()
end,
})
})
70 changes: 60 additions & 10 deletions MAIN-DyTech-Dynamics/scripts/rs-functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ end

function DSgetResearchLevel(technology)
return global.Technology[technology].TechLevel
end
end

function RecipeAvailableToUnlockTier1()
global.ResearchSystem.RecipeAvailableToUnlock.Tier1 = 0
Expand All @@ -67,7 +67,7 @@ for RecipeName, info in pairs(global.ResearchSystem.ItemUnlock) do
if global.ResearchSystem.science > data.Points and data.Tier==1 then
global.ResearchSystem.RecipeAvailableToUnlock.Tier1 = global.ResearchSystem.RecipeAvailableToUnlock.Tier1 + 1
end
end
end
end
end

Expand All @@ -79,7 +79,7 @@ for RecipeName, info in pairs(global.ResearchSystem.ItemUnlock) do
if global.ResearchSystem.science > data.Points and data.Tier==2 then
global.ResearchSystem.RecipeAvailableToUnlock.Tier2 = global.ResearchSystem.RecipeAvailableToUnlock.Tier2 + 1
end
end
end
end
end

Expand All @@ -91,7 +91,7 @@ for RecipeName, info in pairs(global.ResearchSystem.ItemUnlock) do
if global.ResearchSystem.science > data.Points and data.Tier==3 then
global.ResearchSystem.RecipeAvailableToUnlock.Tier3 = global.ResearchSystem.RecipeAvailableToUnlock.Tier3 + 1
end
end
end
end
end

Expand All @@ -103,7 +103,7 @@ for RecipeName, info in pairs(global.ResearchSystem.ItemUnlock) do
if global.ResearchSystem.science > data.Points and data.Tier==4 then
global.ResearchSystem.RecipeAvailableToUnlock.Tier4 = global.ResearchSystem.RecipeAvailableToUnlock.Tier4 + 1
end
end
end
end
end

Expand Down Expand Up @@ -190,9 +190,59 @@ function Ghost(STATEMENT)
end

function Lab_Increament(event)

if event.tick % 100 == 0 then
for id, lab in pairs(game.get_surface(1).find_entities_filtered {
area = {{-200,-200},{200,200}},
name = "lab",
type = "lab",
force = "player"}) do

lab.active = false

local lab_inventory = lab.get_inventory(defines.inventory.lab_input)

if lab_inventory.valid == true then
for i = 1,#lab_inventory do
stack = lab_inventory[i]

if stack.valid_for_read == true then
PlayerPrint(stack.name)
PlayerPrint(stack.durability)

if stack.durability >= 0.01 then
stack.durability = stack.durability - 0.01
else
stack.durability = 1.0
stack.count = stack.count -1

if stack.name == "science-pack-1" then
global.ResearchSystem.science = global.ResearchSystem.science + 1
end

if stack.name == "science-pack-2" then
global.ResearchSystem.science = global.ResearchSystem.science + 3
end

if stack.name == "science-pack-3" then
global.ResearchSystem.science = global.ResearchSystem.science + 5
end

if stack.name == "alien-science-pack" then
global.ResearchSystem.science = global.ResearchSystem.science + 10
end
end
end

end
end

end
end

if event.tick%36000==35999 then
local count = game.players[1].force.get_entity_count("lab")
global.ResearchSystem.science = global.ResearchSystem.science + count
local count = game.players[1].force.get_entity_count("lab")
--global.ResearchSystem.science = global.ResearchSystem.science + count
end
end

Expand All @@ -214,7 +264,7 @@ function Lottery(playerIndex)
global.Lottery.Won = global.Lottery.Won + 1
game.players[playerIndex].print("YOU WON!")
game.players[playerIndex].insert{name=global.Lottery.Rewards[math.random(#global.Lottery.Rewards)], count=math.random(1,5)}
else
else
global.Lottery.Lost = global.Lottery.Lost + 1
game.players[playerIndex].print("YOU LOST")
end
Expand All @@ -224,7 +274,7 @@ function Lottery(playerIndex)
global.Lottery.Won = global.Lottery.Won + 1
game.players[playerIndex].print("YOU WON!")
game.players[playerIndex].insert{name=global.Lottery.Rewards[math.random(#global.Lottery.Rewards)], count=math.random(1,5)}
else
else
global.Lottery.Lost = global.Lottery.Lost + 1
game.players[playerIndex].print("YOU LOST")
end
Expand All @@ -233,4 +283,4 @@ function Lottery(playerIndex)
else
game.players[playerIndex].print("Not enough Science points!")
end
end
end