1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-12 10:04:40 +02:00
RedMew/map_gen/maps/snake_demo.lua
Simon ca29a047de
[Snake] Added on_snake_player_died event (#995)
* Added on_snake_player_died event and a snake_demo map

* Added score to the event

* Fixed entities being destructible

Changed comment

* Fixed cases where controller type wasn't god

* Changed players controller to spectator when their snake dies

* Changed start_game call away from remote.call

* Needed new call to show the snake button

* Changed start_game to use Snake.control

* removed snake event from demo map

* Update map_gen/maps/snake_demo.lua
2019-10-11 00:28:40 +02:00

28 lines
844 B
Lua

local Event = require 'utils.event'
local Token = require 'utils.token'
local Task = require 'utils.task'
local b = require 'map_gen.shared.builders'
local RS = require 'map_gen.shared.redmew_surface'
local floor = math.floor
local Snake_Control = require 'features.snake.control'
local config = global.config
local size = 45
config.market.enabled = false
local snake_generate = Token.register(function()
local position = {x = -floor(size), y = 5}
local max_food = 8
local speed = 30
Snake_Control.start_game(RS.get_surface(), position, size, speed, max_food)
-- An alternative is to use: remote.call('snake', 'start_game', RS.get_surface(), position, size, speed, max_food)
end)
Event.on_init(function()
Task.set_timeout_in_ticks(60, snake_generate)
end)
return b.change_tile(b.rectangle(4, 4), true, 'concrete')