Skip to content

Instantly share code, notes, and snippets.

script.on_event(defines.events.on_player_created, function(event)
local player = game.players[event.player_index]
player.insert{name="iron-plate", count=8}
player.insert{name="pistol", count=1}
player.insert{name="firearm-magazine", count=10}
player.insert{name="burner-mining-drill", count = 1}
player.insert{name="stone-furnace", count = 1}
if (#game.players <= 1) then
game.show_message_dialog{text = {"msg-intro"}}
end
@Choumiko
Choumiko / speed.lua
Created October 19, 2016 08:02
Script to test performance of functions
Position = {}
function Position.to_table(pos_arr)
--fail_if_missing(pos_arr, "missing position argument")
if #pos_arr == 2 then
return { x = pos_arr[1], y = pos_arr[2] }
end
return pos_arr
end
----------PROFILER DUMP----------
2420x "__index" at "=[C]", line -1. Total Duration: 13.214977ms
907x "for iterator" at "=[C]", line -1. Total Duration: 2.936141ms
604x "productivity_allowed" at "@__ModuleInserter__/control.lua", line 15. Total Duration: 2.979765ms
22x "for iterator" at "=[C]", line -1. Total Duration: 0.255175ms
1x "pairs" at "=[C]", line -1. Total Duration: 0.013563ms
1x "__index" at "=[C]", line -1. Total Duration: 0.071194ms
152x "pairs" at "=[C]", line -1. Total Duration: 0.556930ms
151x "create_request_proxy" at "@__ModuleInserter__/control.lua", line 152. Total Duration: 32.037480ms