1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-09-16 09:16:22 +02:00

Change existing code to use new utility functions

This commit is contained in:
Matthew Heguy
2018-11-25 23:17:12 -05:00
parent ae024c4e10
commit 3fa0091971
6 changed files with 10 additions and 10 deletions

View File

@@ -26,7 +26,6 @@ local Utils = require 'utils.core'
local Market_items = require 'resources.market_items'
local market_item = Market_items.market_item
local fish_market_bonus_message = require 'resources.fish_messages'
local total_fish_market_bonus_messages = #fish_market_bonus_message
local function spawn_market(cmd)
local player = game.player
@@ -77,7 +76,7 @@ local function fish_earned(event, amount)
if fish % 70 == 0 then
if player and player.valid then
local message = fish_market_bonus_message[math.random(total_fish_market_bonus_messages)]
local message = table.get_random(fish_market_bonus_message, true)
player.print(message)
end
end

View File

@@ -715,7 +715,7 @@ Gui.on_click(
local count = (player_pokes[poke_player_index] or 0) + 1
player_pokes[poke_player_index] = count
local poke_str = poke_messages[math.random(#poke_messages)]
local poke_str = table.get_random(poke_messages, true)
local message = table.concat({'>> ', player.name, ' has poked ', poke_player.name, ' with ', poke_str, ' <<'})
for _, p in ipairs(game.connected_players) do

View File

@@ -10,7 +10,7 @@ local function player_built_entity(event)
if entity.name == 'train-stop' then
local y = math.random(1, 3)
if y ~= 1 then
local x = math.random(1, #game.players)
local x = table.get_random(game.players, true)
local player = Game.get_player_by_index(x)
event.created_entity.backer_name = player.name
end

View File

@@ -149,7 +149,7 @@ end
local on_collapse_timeout_finished = Token.register(collapse)
local function spawn_cracking_sound_text(surface, position)
local text = config.cracking_sounds[random(1, #config.cracking_sounds)]
local text = table.get_random(config.cracking_sounds, true)
local color = {
r = 1,

View File

@@ -2,6 +2,7 @@ local Event = require 'utils.event'
local Game = require 'utils.game'
local drivers_group = 'Drivers'
local directions = defines.direction
local function transfer_body(player)
-- Remove the player from their character and place them in a car.
@@ -10,7 +11,7 @@ local function transfer_body(player)
local pos = force.get_spawn_position(surface)
-- Choose a random direction for the car to face
local dir = math.random(0, 7)
local dir = table.get_random(directions, true)
-- Remove the players' character
if player.character then

View File

@@ -44,14 +44,14 @@ local callback =
function(entity)
entity.health = math.random(entity.health)
entity.insert(wreck_item_pool[math.random(#wreck_item_pool)])
entity.insert(wreck_item_pool[math.random(#wreck_item_pool)])
entity.insert(wreck_item_pool[math.random(#wreck_item_pool)])
entity.insert(wreck_item_pool[table.get_random(wreck_item_pool, true)])
entity.insert(wreck_item_pool[table.get_random(wreck_item_pool, true)])
entity.insert(wreck_item_pool[table.get_random(wreck_item_pool, true)])
end
)
return function(x, y, world)
local ship = entity_list[math.random(#entity_list)]
local ship = table.get_random(entity_list, true)
if math.random(ship.chance) ~= 1 then
return nil