Advertisement
Guest User

Untitled

a guest
Sep 21st, 2016
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.08 KB | None | 0 0
  1. function give-player(player,item_name,count)
  2.     if game.item_prototypes[item_name] ~= nil then
  3.         player.insert{item_name, count=count}
  4.     end
  5. end
  6.  
  7. function changefilter(inventory,slot,item_name)
  8.     if game.item_prototypes[item_name] ~= nil then
  9.         inventory.set_filter(slot,item_name)
  10.     end
  11. end
  12.  
  13. -- first we establish starting inventory and filters upon player first joining a game
  14. function give_starting_equipment(event)
  15.     game.players[event.player_index].color = {r = 0, g = 0, b = 1, a = .7};  -- change player color to blue
  16.     local player = game.players[event.player_index]
  17.     local inventory = player.get_inventory(defines.inventory.player_quickbar)
  18.     inventory.clear()
  19.     changefilter(inventory, 1,"transport-belt")
  20.     changefilter(inventory, 2,"inserter")
  21.     changefilter(inventory, 3,"underground-belt")
  22.     changefilter(inventory, 4,"hacked-splitter")
  23.     changefilter(inventory, 5,"small-electric-pole")
  24.     changefilter(inventory, 6,"assembling-machine-1")
  25.     changefilter(inventory, 7,"long-handed-inserter")
  26.     changefilter(inventory, 8,"blueprint")
  27.     changefilter(inventory, 9,"deconstruction-planner")
  28.     changefilter(inventory,10,"steel-chest")
  29.     -- materials
  30.     give-player{player, item_name="steel-axe", count=10}
  31.     give-player{player, item_name="iron-plate", count=592} -- 8 extra are added by freeplay scenario starting items
  32.     give-player{player, item_name="copper-plate", count=400}
  33.     give-player{player, item_name="electronic-circuit", count=200}
  34.     give-player{player, item_name="iron-gear-wheel", count=200}
  35.     give-player{player, item_name="underground-belt", count=50}
  36.     give-player{player, item_name="hacked-splitter", count=50}
  37.     give-player{player, item_name="small-electric-pole", count=148} -- 48 required for furnace setup, 100 extra == 148
  38.     -- logistics
  39.     give-player{player, item_name="assembling-machine-1", count=20}
  40.     give-player{player, item_name="long-handed-inserter", count=50}    
  41.     give-player{player, item_name="blueprint", count=1}
  42.     give-player{player, item_name="deconstruction-planner", count=1}
  43.     give-player{player, item_name="steel-chest", count=50}
  44.     give-player{player, item_name="inserter", count=182} -- 2 inserters per stone furnace, 52 stone furnaces to start with in 2 layouts of 2x13 = 2*2*2*13 == 104 + 28 for boilers + 50 spare
  45.     give-player{player, item_name="transport-belt", count=800}
  46.     -- smelting/mining
  47.     give-player{player, item_name="electric-mining-drill", count=36} -- 13 for iron, 13 for copper, 2 for stone, 8 for coal == 36
  48.     give-player{player, item_name="stone-furnace", count=52} -- two setups of 2x13 == 52
  49.     -- power
  50.     give-player{player, item_name="boiler", count=28} -- two rows of 14 boilers == 28
  51.     give-player{player, item_name="coal", count=1400} -- 50 coal per boiler * 28 == 1400
  52.     give-player{player, item_name="steam-engine", count=20} -- two rows of 10 steam engines == 20
  53.     give-player{player, item_name="offshore-pump", count=2} -- two power chains
  54.     give-player{player, item_name="pipe-to-ground", count=50}
  55.     give-player{player, item_name="pipe", count=50}
  56.     -- car
  57.     give-player{player, item_name="car", count=1}
  58.     give-player{player, item_name="coal", count=200} -- coal for car
  59.     -- robot
  60.     give-player{player, item_name="power-armor", count=1}
  61.     give-player{player, item_name="construction-robot", count=50}
  62.     give-player{player, item_name="fusion-reactor-equipment", count=1}
  63.     give-player{player, item_name="personal-roboport-equipment", count=5}
  64.     give-player{player, item_name="battery-mk2-equipment", count=3}
  65.     -- science
  66.     give-player{player, item_name="lab", count=10}
  67.     give-player{player, item_name="science-pack-1", count=10}
  68. end
  69.  
  70. script.on_event( defines.events.on_player_created, give_starting_equipment(event))
  71. -- then we establish a new inventory if player should respawn
  72.  
  73. function give_respawn_equipment(event)
  74.     --filters
  75.     local player = game.players[event.player_index]
  76.     local inventory = player.get_inventory(defines.inventory.player_quickbar)
  77.     changefilter(inventory, 1,"transport-belt")
  78.     changefilter(inventory, 2,"inserter")
  79.     changefilter(inventory, 3,"underground-belt")
  80.     changefilter(inventory, 4,"hacked-splitter")
  81.     changefilter(inventory, 5,"small-electric-pole")
  82.     changefilter(inventory, 6,"assembling-machine-1")
  83.     changefilter(inventory, 7,"long-handed-inserter")
  84.     changefilter(inventory, 8,"blueprint")
  85.     changefilter(inventory, 9,"deconstruction-planner")
  86.     changefilter(inventory,10,"steel-chest")
  87.     -- materials
  88.     give-player{player, item_name="steel-axe", count=10}
  89.     -- logistics
  90.     give-player{player, item_name="blueprint", count=1}
  91.     give-player{player, item_name="deconstruction-planner", count=1}
  92.     -- car
  93.     give-player{player, item_name="car", count=1}
  94.     give-player{player, item_name="coal", count=200} -- coal.... for car
  95.     -- robot
  96.     give-player{player, item_name="power-armor", count=1}
  97.     give-player{player, item_name="construction-robot", count=50}
  98.     give-player{player, item_name="fusion-reactor-equipment", count=1}
  99.     give-player{player, item_name="personal-roboport-equipment", count=5}
  100.     give-player{player, item_name="battery-mk2-equipment", count=3}
  101.    
  102.    
  103. end
  104. -- script.on_event(defines.events.on_player_respawn, give_respawn_equipment(event))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement