local math=math -- on first load mod script.on_init(function() global.cook={} global.cook.appletree={} global.cook.hunger={} global.cook.thirst={} global.cook.stamina={} global.cook.run={} global.cook.craft={} global.cook.mine={} global.cook.appletree={} global.cook.player={} global.cook.heal={} global.cook.deal={} global.cook.fishtrap={} global.cook.studycooking={} global.cook.bufffactor={} global.cook.walkaround={} global.cook.build={} global.cook.greenade={} for a, b in pairs(game.players) do add_gui(a) end end) -- function of on eat function oneat(l,a,b,c,amount,d,e,f,g,h,i,j,k,t) global.cook.hunger[l] = global.cook.hunger[l]+a global.cook.thirst[l]= global.cook.thirst[l]+b global.cook.stamina[l] = global.cook.stamina[l]+c heal(l, amount, d, t, e) run(l, f, t, g) craft(l, h, t, i) mine(l, j, t, k) end -- function of recipe function studycook1(entity,n,a) if entity.get_item_count(a) > 0 and global.cook.player[1].force.recipes[n].enabled == false then entity.remove_item({name=a, count=1}) global.cook.player[1].force.recipes[n].enabled = true for i, j in pairs(global.cook.player) do global.cook.player[i].print{"","Discovered recipe for '",n,"'!"} end end end function studycook2(entity,n,a,b) if entity.get_item_count(a) > 0 and entity.get_item_count(b) > 0 and global.cook.player[1].force.recipes[n].enabled == false then entity.remove_item({name=a, count=1}) entity.remove_item({name=b, count=1}) global.cook.player[1].force.recipes[n].enabled = true for i, j in pairs(global.cook.player) do global.cook.player[i].print{"","Discovered recipe for '",n,"'!"} end end end function studycook3(entity,n,a,b,c) if entity.get_item_count(a) > 0 and entity.get_item_count(b) > 0 and entity.get_item_count(c) > 0 and global.cook.player[1].force.recipes[n].enabled == false then entity.remove_item({name=a, count=1}) entity.remove_item({name=b, count=1}) entity.remove_item({name=c, count=1}) global.cook.player[1].force.recipes[n].enabled = true for i, j in pairs(global.cook.player) do global.cook.player[i].print{"","Discovered recipe for '",n,"'!"} end end end function studycook4(entity,n,a,b,c,d) if entity.get_item_count(a) > 0 and entity.get_item_count(b) > 0 and entity.get_item_count(c) > 0 and entity.get_item_count(d) > 0 and global.cook.player[1].force.recipes[n].enabled == false then entity.remove_item({name=a, count=1}) entity.remove_item({name=b, count=1}) entity.remove_item({name=c, count=1}) entity.remove_item({name=d, count=1}) global.cook.player[1].force.recipes[n].enabled = true for i, j in pairs(global.cook.player) do global.cook.player[i].print{"","Discovered recipe for '",n,"'!"} end end end function studycook5(entity,n,a,b,c,d,e) if entity.get_item_count(a) > 0 and entity.get_item_count(b) > 0 and entity.get_item_count(c) > 0 and entity.get_item_count(d) > 0 and entity.get_item_count(e) > 0 and global.cook.player[1].force.recipes[n].enabled == false then entity.remove_item({name=a, count=1}) entity.remove_item({name=b, count=1}) entity.remove_item({name=c, count=1}) entity.remove_item({name=d, count=1}) entity.remove_item({name=e, count=1}) global.cook.player[1].force.recipes[n].enabled = true for i, j in pairs(global.cook.player) do global.cook.player[i].print{"","Discovered recipe for '",n,"'!"} end end end function studycook6(entity,n,a,b,c,d,e,f) if entity.get_item_count(a) > 0 and entity.get_item_count(b) > 0 and entity.get_item_count(c) > 0 and entity.get_item_count(d) > 0 and entity.get_item_count(e) > 0 and entity.get_item_count(f) > 0 and global.cook.player[1].force.recipes[n].enabled == false then entity.remove_item({name=a, count=1}) entity.remove_item({name=b, count=1}) entity.remove_item({name=c, count=1}) entity.remove_item({name=d, count=1}) entity.remove_item({name=e, count=1}) entity.remove_item({name=f, count=1}) global.cook.player[1].force.recipes[n].enabled = true for i, j in pairs(global.cook.player) do global.cook.player[i].print{"","Discovered recipe for '",n,"'!"} end end end -- function of stats function heal(a, b, amount, tick, time) global.cook.player[a].character.health = global.cook.player[a].character.health + b local t = tick + time*60 if amount < 0 then global.cook.deal[a]={amount, t} end if amount > 0 then global.cook.heal[a]={amount, t} end end function run(a, amount, tick, time) local t = tick + time*60 if amount ~= 0 then global.cook.run[a]={amount, t} end end function craft(a, amount, tick, time) local t = tick + time*60 if amount ~= 0 then global.cook.craft[a]={amount, t} end end function mine(a, amount, tick, time) local t = tick + time*60 if amount ~= 0 then global.cook.mine[a]={amount, t} end end -- apply all player function add_gui(player_index) global.cook.hunger[player_index] = 50 global.cook.thirst[player_index] = 50 global.cook.stamina[player_index] = 50 global.cook.run[player_index] = {0,0} global.cook.craft[player_index] = {0,0} global.cook.mine[player_index] = {0,0} global.cook.deal[player_index] = {0,0} global.cook.heal[player_index] = {0,0} global.cook.bufffactor[player_index] = {{1,0},{1,0},{1,0}}--{{run,time},{craft,time},{mine,time}}*value global.cook.walkaround[player_index] = 0 global.cook.build[player_index] = {0,0} global.cook.greenade[player_index] = 0 global.cook.player[player_index] = game.players[player_index] -- starting items global.cook.player[player_index].insert{name="apple", count=10} global.cook.player[player_index].insert{name="apple-seed", count=10} global.cook.player[player_index].insert{name="strange-seeds", count=1} -- gui global.cook.player[player_index].gui.left.add{type="frame",name="hunger", direction="horizontal"} global.cook.player[player_index].gui.left.hunger.add{type="label",name="cap",caption="Hunger"} global.cook.player[player_index].gui.left.hunger.add{type="progressbar", name="bar",size=1, value=global.cook.hunger[player_index]/100} global.cook.player[player_index].gui.left.hunger.style.top_padding = 0 global.cook.player[player_index].gui.left.hunger.style.bottom_padding = 0 global.cook.player[player_index].gui.left.hunger.bar.style.top_padding = 8 global.cook.player[player_index].gui.left.hunger.bar.style.bottom_padding = 8 global.cook.player[player_index].gui.left.hunger.bar.style.minimal_height = 22 global.cook.player[player_index].gui.left.hunger.bar.style.minimal_width = 200 global.cook.player[player_index].gui.left.add{type="frame",name="thirst", direction="horizontal"} global.cook.player[player_index].gui.left.thirst.add{type="label",name="cap",caption="Thirst"} global.cook.player[player_index].gui.left.thirst.add{type="progressbar", name="bar",size=1, value=global.cook.thirst[player_index]/100} global.cook.player[player_index].gui.left.thirst.style.top_padding = 0 global.cook.player[player_index].gui.left.thirst.style.bottom_padding = 0 global.cook.player[player_index].gui.left.thirst.bar.style.top_padding = 8 global.cook.player[player_index].gui.left.thirst.bar.style.bottom_padding = 8 global.cook.player[player_index].gui.left.thirst.bar.style.minimal_height = 22 global.cook.player[player_index].gui.left.thirst.bar.style.maximal_width = 100 global.cook.player[player_index].gui.left.add{type="frame",name="stamina", direction="horizontal"} global.cook.player[player_index].gui.left.stamina.add{type="label",name="cap",caption="Stamina"} global.cook.player[player_index].gui.left.stamina.add{type="progressbar", name="bar",size=1, value=global.cook.stamina[player_index]/100} global.cook.player[player_index].gui.left.stamina.style.top_padding = 0 global.cook.player[player_index].gui.left.stamina.style.bottom_padding = 0 global.cook.player[player_index].gui.left.stamina.bar.style.top_padding = 8 global.cook.player[player_index].gui.left.stamina.bar.style.bottom_padding = 8 global.cook.player[player_index].gui.left.stamina.bar.style.minimal_height = 22 global.cook.player[player_index].gui.left.stamina.bar.style.maximal_width = 100 global.cook.player[player_index].gui.left.direction="vertical" end -- on created script.on_event(defines.events.on_player_created, function(event) if global.cook.hunger[event.player_index] == nil then add_gui(event.player_index) end end) -- on eat script.on_event(defines.events.on_trigger_created_entity, function(event) for l, m in pairs(game.players) do if global.cook.player[l].position.x == event.entity.position.x and global.cook.player[l].position.y == event.entity.position.y then if event.entity.name == "eat-apple" then--16 oneat(l,3,3,3,3,1,5,0,0,0,0,0,0,event.tick)--(l,hunger,thirst,stamina,healamount,dotheal,time,run,time,craft,time,mine,time,tick) if math.random() < 0.1 then global.cook.player[l].insert({name="apple-seed", count=1})end end if event.entity.name == "eat-pink-juice" then--18 oneat(l,3,10,3,0,0,0,0,0,0,0,0,0,0,event.tick) end if event.entity.name == "eat-stonade" then--20 oneat(l,5,-5,-5,-5,-1,5,-0.5,5,0,0,0,0,event.tick) end if event.entity.name == "eat-ironade" then--20 oneat(l,5,-5,-5,-5,-1,5,0,0,-0.5,5,0,0,event.tick) end if event.entity.name == "eat-copperade" then--20 oneat(l,5,-5,-5,-5,-1,5,0,0,0,0,-0.5,5,event.tick) end if event.entity.name == "eat-raw-fish" then--60 oneat(l,10,5,10,0,0,0,0,0,0,0,0,0,0,event.tick) end if event.entity.name == "eat-engineering-potion" then--90 oneat(l,0,0,0,0,0,0,0,0,0.5,10,0,0,event.tick) end if event.entity.name == "eat-pink-stew" then--90 oneat(l,10,20,10,5,1,10,0,0,0,0,0,0,event.tick) end if event.entity.name == "eat-fowerade" then--90 oneat(l,15,-15,-15,-15,0,0,1,5,1,5,1,5,event.tick) end if event.entity.name == "eat-bread" then--100 oneat(l,20,-5,10,10,1,5,0,0,0,0,0,0,event.tick) end if event.entity.name == "eat-apple-pie" then--114 oneat(l,25,0,10,15,1,5,0,0,0,0,0,0,event.tick) end if event.entity.name == "eat-fish-stew" then--135 oneat(l,10,25,10,15,1,5,0,0,0,0,0,0,event.tick) end if event.entity.name == "eat-sashimi" then--150 oneat(l,5,0,5,5,0,0,0,0,0,0,0,0,event.tick) end if event.entity.name == "eat-frog-barbecue" then--225 oneat(l,30,0,20,20,1,10,0,0,0,0,0,0,event.tick) end if event.entity.name == "eat-meat-stew" then--225 oneat(l,10,30,20,20,1,10,0,0,0,0,0,0,event.tick) end if event.entity.name == "eat-snake-noodles" then--225 oneat(l,10,15,10,10,0,0,0.5,20,0,0,0,0,event.tick) end if event.entity.name == "eat-hamburger" then--300 oneat(l,30,0,10,20,1,10,0,0,0,0,0,0,event.tick) end if event.entity.name == "eat-science-potion" then--300 oneat(l,0,0,0,0,0,0,0,0,0.5,30,0,0,event.tick) end if event.entity.name == "eat-fourhead-kebab" then--330 oneat(l,20,0,20,10,0,0,0.5,30,0,0,0,0,event.tick) global.cook.walkaround[l] = event.tick+60*30 end if event.entity.name == "eat-black-potion" then--600 oneat(l,0,0,0,0,0.1,0.1,0.1,0.1,0.1,0.1,0.5,60,event.tick) global.cook.bufffactor[l][2]={0,event.tick+60*60} end if event.entity.name == "eat-pizza" then--624 oneat(l,40,0,20,25,1,20,0,0,0,0,0,0,event.tick) end if event.entity.name == "eat-red-potion" then--675 oneat(l,0,0,50,50,1,30,0,0,0,0,0,0,event.tick) end if event.entity.name == "eat-red-stew" then--960 oneat(l,10,50,25,30,1,20,0,0,0,0,0,0,event.tick) end if event.entity.name == "eat-engineering-stew" then--2500 oneat(l,10,20,10,0,0,0,0,0,0.5,120,0.5,120,event.tick) global.cook.build[l] = {3, event.tick + 60*120} end if event.entity.name == "eat-greenade-stew" then--2500 oneat(l,10,20,10,0,0,0,0,0,0,0,0,0,event.tick) global.cook.greenade[l] = event.tick + 30*60 end if event.entity.name == "eat-flash-pie" then--2500 oneat(l,30,0,10,0,0,0,1,60,0,0,0,0,event.tick)end end end end) -- on mine script.on_event(defines.events.on_player_mined_item, function(event) global.cook.hunger[event.player_index] = global.cook.hunger[event.player_index]-0.05 global.cook.thirst[event.player_index] = global.cook.thirst[event.player_index]-0.05 end) -- on built script.on_event(defines.events.on_built_entity, function(event) global.cook.stamina[event.player_index] = global.cook.stamina[event.player_index]-0.03 global.cook.hunger[event.player_index] = global.cook.hunger[event.player_index]-0.03 if event.created_entity.name == "apple-tree-grow0" then local tick = event.tick table.insert(global.cook.appletree, {tick,event.created_entity.position.x,event.created_entity.position.y}) end if event.created_entity.name == "net-fish-trap" then if global.cook.player[1].surface.get_tile(event.created_entity.position.x, event.created_entity.position.y).name == "water" then local tick = event.tick table.insert(global.cook.fishtrap, {tick, "water", event.created_entity}) end if global.cook.player[1].surface.get_tile(event.created_entity.position.x, event.created_entity.position.y).name == "deepwater" then local tick = event.tick table.insert(global.cook.fishtrap, {tick, "deepwater", event.created_entity}) end if global.cook.player[1].surface.get_tile(event.created_entity.position.x, event.created_entity.position.y).name == "deepwater-green" then local tick = event.tick table.insert(global.cook.fishtrap, {tick, "deepwater-green", event.created_entity}) end if global.cook.player[1].surface.get_tile(event.created_entity.position.x, event.created_entity.position.y).name == "water-green" then local tick = event.tick table.insert(global.cook.fishtrap, {tick, "water-green", event.created_entity}) end end if event.created_entity.name == "kitchen-table" then table.insert(global.cook.studycooking, {event.created_entity.position.x,event.created_entity.position.y}) end end) -- on tick script.on_event(defines.events.on_tick, function(event) local fmod=math.fmod local tick=event.tick local cook=global.cook for a, b in pairs(game.players) do local player=cook.player[a] if cook.thirst[a] == nil then cook.thirst[a] = cook.thirsty[a] table.remove(cook, thirsty) end if cook.stamina[a] == nil then cook.stamina[a] = cook.healthy[a] table.remove(cook, healthy) end -- greenade if tick < cook.greenade[a] then local x=cook.player[a].position.x local y=cook.player[a].position.y local t=fmod(tick,120) if t==0 then cook.player[a].surface.create_entity{name="greenade",position={x,y},target={x+5,y+5},speed=0.5} elseif t==15 then cook.player[a].surface.create_entity{name="greenade",position={x,y},target={x,y+5*math.sqrt(2)},speed=0.5} elseif t==30 then cook.player[a].surface.create_entity{name="greenade",position={x,y},target={x-5,y+5},speed=0.5} elseif t==45 then cook.player[a].surface.create_entity{name="greenade",position={x,y},target={x-5*math.sqrt(2),y},speed=0.5} elseif t==60 then cook.player[a].surface.create_entity{name="greenade",position={x,y},target={x-5,y-5},speed=0.5} elseif t==75 then cook.player[a].surface.create_entity{name="greenade",position={x,y},target={x,y-5*math.sqrt(2)},speed=0.5} elseif t==90 then cook.player[a].surface.create_entity{name="greenade",position={x,y},target={x+5,y-5},speed=0.5} elseif t==105 then cook.player[a].surface.create_entity{name="greenade",position={x,y},target={x+5*math.sqrt(2),y},speed=0.5} end end -- walk around if tick < cook.walkaround[a] then local walking_state=cook.player[a].walking_state local t=fmod(tick, 240) if walking_state.walking == false and t < 30 then walking_state = {walking = true, direction = defines.direction.north} else if walking_state.walking == false and t < 60 then walking_state = {walking = true, direction = defines.direction.northeast} else if walking_state.walking == false and t < 90 then walking_state = {walking = true, direction = defines.direction.east} else if walking_state.walking == false and t < 120 then walking_state = {walking = true, direction = defines.direction.southeast} else if walking_state.walking == false and t < 150 then walking_state = {walking = true, direction = defines.direction.south} else if walking_state.walking == false and t < 180 then walking_state = {walking = true, direction = defines.direction.southwest} else if walking_state.walking == false and t < 210 then walking_state = {walking = true, direction = defines.direction.west} else if walking_state.walking == false and t < 240 then walking_state = {walking = true, direction = defines.direction.northwest} end end end end end end end end end --do the following checks need to be performed 60 times per second? -- build buff if tick < cook.build[a][2] then local amount = cook.build[a][1] player.character_build_distance_bonus = amount player.character_reach_distance_bonus = amount player.character_resource_reach_distance_bonus = amount end if tick > cook.build[a][2] then player.character_build_distance_bonus = 0 player.character_reach_distance_bonus = 0 player.character_resource_reach_distance_bonus = 0 end -- deal buff if tick < cook.deal[a][2] then local amount = cook.deal[a][1] / 60 player.character.health = player.character.health + amount player.surface.create_entity{name="buff-deal",position={player.position.x,player.position.y}} end -- heal buff if tick < cook.heal[a][2] then local amount = cook.heal[a][1] / 60 player.character.health = player.character.health + amount player.surface.create_entity{name="buff-heal",position={player.position.x,player.position.y}} end -- run buff if tick <= cook.run[a][2] then player.surface.create_entity { name="buff-run", position={player.position.x,player.position.y} } end if tick > cook.run[a][2] then cook.run[a][1]=0 end if tick > cook.bufffactor[a][1][2] then cook.bufffactor[a][1][1] = 1 end -- craft buff if tick <= cook.craft[a][2] then player.surface.create_entity { name="buff-craft", position={player.position.x,player.position.y} } end if tick > cook.craft[a][2] then cook.craft[a][1]=0 end if tick > cook.bufffactor[a][2][2] then cook.bufffactor[a][2][1] = 1 end -- mine buff if tick <= cook.mine[a][2] then player.surface.create_entity { name="buff-mine", position={player.position.x,player.position.y} } end if tick > cook.mine[a][2] then cook.mine[a][1]=0 end if tick > cook.bufffactor[a][3][2] then cook.bufffactor[a][3][1] = 1 end -- gui local gui=player.gui.left if gui.hunger.cap == nil then gui.hunger.destroy() gui.add{type="frame",name="hunger", direction="horizontal"} gui.hunger.add{type="label",name="cap",caption="Hunger"} gui.hunger.add{type="progressbar", name="bar",size=1, value=cook.hunger[a]/100} gui.hunger.style.top_padding = 0 gui.hunger.style.bottom_padding = 0 gui.hunger.bar.style.top_padding = 8 gui.hunger.bar.style.bottom_padding = 8 gui.hunger.bar.style.minimal_height = 22 gui.hunger.bar.style.maximal_width = 100 end if gui.thirst == nil then gui.thirsty.destroy() gui.add{type="frame",name="thirst", direction="horizontal"} gui.thirst.add{type="label",name="cap",caption="Thirst"} gui.thirst.add{type="progressbar", name="bar",size=1, value=cook.thirst[a]/100} gui.thirst.style.top_padding = 0 gui.thirst.style.bottom_padding = 0 gui.thirst.bar.style.top_padding = 8 gui.thirst.bar.style.bottom_padding = 8 gui.thirst.bar.style.minimal_height = 22 gui.thirst.bar.style.maximal_width = 100 end if gui.stamina == nil then gui.healthy.destroy() gui.add{type="frame",name="stamina", direction="horizontal"} gui.stamina.add{type="label",name="cap",caption="Stamina"} gui.stamina.add{type="progressbar", name="bar",size=1, value=cook.stamina[a]/100} gui.stamina.style.top_padding = 0 gui.stamina.style.bottom_padding = 0 gui.stamina.bar.style.top_padding = 8 gui.stamina.bar.style.bottom_padding = 8 gui.stamina.bar.style.minimal_height = 22 gui.stamina.bar.style.maximal_width = 100 end gui.hunger.bar.value=cook.hunger[a]/100 gui.thirst.bar.value=cook.thirst[a]/100 gui.stamina.bar.value=cook.stamina[a]/100 -- apply buff player.character_running_speed_modifier = (((cook.hunger[a]-50)/200) + cook.run[a][1]+1)*cook.bufffactor[a][1][1]-1 player.character_crafting_speed_modifier = (((cook.thirst[a]-50)/200) + cook.craft[a][1]+1)*cook.bufffactor[a][2][1]-1 player.character_mining_speed_modifier = (((cook.stamina[a]-50)/200) + cook.mine[a][1]+1)*cook.bufffactor[a][3][1]-1 -- hunger if player.walking_state.walking == true then cook.hunger[a] = cook.hunger[a]-(1/1200) end if cook.hunger[a] > 100 then cook.hunger[a] = 100 else if cook.hunger[a] > 0 then cook.hunger[a] = cook.hunger[a]-(1/1200) else player.character.health = player.character.health - 1/120 cook.hunger[a]=0 end end --thirst if player.walking_state.walking == true then cook.thirst[a] = cook.thirst[a]-(1/1200) end if cook.thirst[a] > 100 then cook.thirst[a]= 100 else if cook.thirst[a]> 0 then cook.thirst[a]= cook.thirst[a]-(1/1200) else player.character.health = player.character.health - 1/120 cook.thirst[a]=0 end end --stamina if player.walking_state.walking == true then cook.stamina[a] = cook.stamina[a]-(1/1200) end if cook.stamina[a] > 100 then cook.stamina[a] = 100 else if cook.stamina[a] > 0 then cook.stamina[a] = cook.stamina[a]-(1/1200) else player.character.health = player.character.health - 1/120 cook.stamina[a]=0 end end --end do the following checks need to be performed 60 times per second? end --grow apple tree for a, b in ipairs(cook.appletree) do local tick = tick if b[1] + 6000 == tick then for key, entity in pairs(cook.player[1].surface.find_entities_filtered({name="apple-tree-grow0",position={b[2],b[3]}})) do entity.destroy() cook.player[1].surface.create_entity{ name = "apple-tree-grow1", position={b[2],b[3]} } end end if b[1] + 12000 == tick then for key, entity in pairs(cook.player[1].surface.find_entities_filtered({name="apple-tree-grow1",position={b[2],b[3]}})) do entity.destroy() cook.player[1].surface.create_entity{ name = "apple-tree-grow2", position={b[2],b[3]} } end end if b[1] + 18000 == tick then for key, entity in pairs(cook.player[1].surface.find_entities_filtered({name="apple-tree-grow2",position={b[2],b[3]}})) do entity.destroy() cook.player[1].surface.create_entity{ name = "apple-tree-grow3", position={b[2],b[3]} } end end if b[1] + 24000 == tick then for key, entity in pairs(cook.player[1].surface.find_entities_filtered({name="apple-tree-grow3",position={b[2],b[3]}})) do entity.destroy() cook.player[1].surface.create_entity{ name = "apple-tree", position={b[2],b[3]} } end end end -- fish trap for a=#cook.fishtrap,1,-1 do local b=cook.fishtrap[a] if fmod(tick, 60) == 0 then local entity=b[3] if not entity.valid then table.remove(cook.fishtrap,a) end -- on water if b[2] == "water" then if entity.get_item_count("fish-bait-basic") > 0 and entity.can_insert({name="small-plane", count=1}) and math.random() < 0.01 then entity.remove_item({name="fish-bait-basic", count=1}) local random = math.random() if random > 0.8 then entity.insert({name="stone", count=1}) else if random > 0.3 then entity.insert({name="raw-fish", count=1}) else if random > 0.15 then entity.insert({name="frog", count=1}) else if random > 0.05 then entity.insert({name="stringy-snakes", count=1}) else entity.insert({name="piranha", count=1}) end end end end end -- on deepwater elseif b[2] == "deepwater" then if entity.get_item_count("deadly-bait") > 0 and entity.can_insert({name="small-plane", count=1})==true and math.random() < 0.01 then entity.remove_item({name="deadly-bait", count=1}) local random = math.random() if random > 0.5 then entity.insert({name="four-head-fish", count=1}) else if random > 0.2 then entity.insert({name="gear-head-fish", count=1}) else if random > 0 then entity.insert({name="red-whale", count=1}) else entity.insert({name="raw-fish", count=1}) end end end end -- on water-green elseif b[2] == "water-green" then if entity.get_item_count("fish-bait-basic") > 0 and entity.can_insert({name="small-plane", count=1})==true and math.random() < 0.01 then entity.remove_item({name="fish-bait-basic", count=1}) local random = math.random() if random > 0.8 then entity.insert({name="stone", count=1}) else if random > 0.3 then entity.insert({name="raw-fish", count=1}) else if random > 0.15 then entity.insert({name="frog", count=1}) else if random > 0.05 then entity.insert({name="stringy-snakes", count=1}) else entity.insert({name="piranha", count=1}) end end end end end -- deepwater-green elseif b[2] == "deepwater-green" then if entity.get_item_count("deadly-bait") > 0 and entity.can_insert({name="small-plane", count=1})==true and math.random() < 0.01 then entity.remove_item({name="deadly-bait", count=1}) local random = math.random() if random > 0.5 then entity.insert({name="four-head-fish", count=1}) else if random > 0.2 then entity.insert({name="gear-head-fish", count=1}) else if random > 0 then entity.insert({name="red-whale", count=1}) else entity.insert({name="raw-fish", count=1}) end end end end end end end -- study cooking table if fmod(tick, 60) == 0 then for a, b in ipairs(cook.studycooking) do for key, entity in pairs(cook.player[1].surface.find_entities_filtered({name="kitchen-table",position={cook.studycooking[a][1],cook.studycooking[a][2]}})) do studycook1(entity,"pink-juice","apple") studycook2(entity,"pink-stew","apple","common-vegetable") studycook1(entity,"bread","wheat") studycook2(entity,"apple-pie","apple","bread") studycook1(entity,"meat-stew","alien-meat") studycook1(entity,"fish-stew","raw-fish") studycook1(entity,"alien-meat","frog") studycook2(entity,"frog-barbecue","frog","common-vegetable") studycook2(entity,"hamburger","alien-meat","bread") studycook1(entity,"snake-noodles","stringy-snakes") studycook1(entity,"dressed-piranha","piranha") studycook1(entity,"deadly-bait","sharp-teeth") studycook1(entity,"stonade","stone") studycook1(entity,"ironade","iron-ore") studycook1(entity,"copperade","copper-ore") studycook3(entity,"fowerade","stonade","ironade","copperade") studycook1(entity,"red-potion","red-mushroom") studycook1(entity,"science-potion","science-pack-1") studycook2(entity,"black-potion","science-potion","fowerade") studycook2(entity,"pizza","alien-meat","red-mushroom") studycook1(entity,"greenade-stew","greenade-flower") studycook1(entity,"flash-pie","sparkling-plant") studycook1(entity,"engineering-potion","iron-gear-wheel") studycook1(entity,"engineering-stew","spanner-bamboo") studycook1(entity,"fourhead-kebab","four-head-fish") studycook1(entity,"red-stew","red-whale") end end end end)