1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-26 03:52:00 +02:00

fixed market spawn location

This commit is contained in:
Valansch 2017-07-19 11:54:46 +02:00
parent 404d95dc80
commit 231e151870
2 changed files with 37 additions and 30 deletions

View File

@ -248,6 +248,7 @@ commands.add_command("tpplayer", "<player> - Teleports you to the player. (Admin
commands.add_command("invoke", "<player> - Teleports the player to you. (Admins and moderators)", invoke)
commands.add_command("tppos", "Teleports you to a selected entity. (Admins only)", teleport_location)
commands.add_command("walkabout", '<player> <"close", "far", "very far", number> - Send someone on a walk. (Admins and moderators)', walkabout)
commands.add_command("market", 'Places a fish market near you. (Admins only)', spawn_market)
commands.add_command("settime", '<day> <month> <hour> <minute> - Sets the clock (Admins, moderators and regulars)', on_set_time)
commands.add_command("clock", 'Look at the clock.', clock)
commands.add_command("regulars", 'Prints a list of game regulars.', print_regulars)

View File

@ -17,9 +17,15 @@ make pet faster
make pet follow you moar
--]]
function market()
game.player.print("This command moved to /market.")
end
function spawn_market(cmd)
if not game.player.admin then
cant_run(cmd.name)
return
end
local radius = 10
local surface = game.surfaces[1]
-- clear trees and landfill in start area
@ -35,7 +41,7 @@ function market()
end
end
local player = game.players[1]
local player = game.player
local market_location = {x = player.position.x, y = player.position.y}
market_location.y = market_location.y - 4
@ -50,7 +56,7 @@ function market()
surface.set_tiles(waterTiles)
local market = surface.create_entity{name="market", position=market_location, force=force}
market.destructible = false
market.add_market_item{price={{"raw-fish", 10}}, offer={type="give-item", item="exoskeleton-equipment"}}
market.add_market_item{price={{"raw-fish", 30}}, offer={type="give-item", item="small-plane"}}
market.add_market_item{price={{"raw-fish", 1}}, offer={type="give-item", item="rail", count=2}}
@ -124,7 +130,7 @@ local function preplayer_mined_item(event)
fish_earned(event, 1)
end
end
if event.entity.name == "fish" then
fish_earned(event, 0)
end
@ -169,19 +175,19 @@ function pet(player, entity_name)
else
player = game.players[player]
end
if not entity_name then
if not entity_name then
entity_name = "small-biter"
end
if not global.player_pets then global.player_pets = {} end
local surface = game.surfaces[1]
local pos = player.position
pos.y = pos.y + 1
local x = 1
x = x + #global.player_pets
global.player_pets[x] = {}
global.player_pets[x].entity = surface.create_entity {name=entity_name, position=pos, force="player"}
global.player_pets[x].owner = player.index
@ -230,7 +236,7 @@ local function market_item_purchased(event)
if event.offer_index == 2 then
player.get_inventory(defines.inventory.player_main).remove({name="small-plane", count=event.count})
local chance = 4
local chance = 4
local x = math.random(1,3)
if x < 3 then
local x = math.random(1,chance)
@ -244,8 +250,8 @@ local function market_item_purchased(event)
local x = math.random(1,chance)
if x < chance then
rolled_pet = "big-biter"
else
rolled_pet = "behemoth-biter"
else
rolled_pet = "behemoth-biter"
end
end
end
@ -261,11 +267,11 @@ local function market_item_purchased(event)
local x = math.random(1,chance)
if x < chance then
rolled_pet = "big-spitter"
else
rolled_pet = "behemoth-spitter"
else
rolled_pet = "behemoth-spitter"
end
end
end
end
end
local str = player.name
str = str .. " bought his very own pet "
@ -274,7 +280,7 @@ local function market_item_purchased(event)
game.print(str)
pet(event.player_index, rolled_pet)
end
end
if not global.pet_command_rotation then global.pet_command_rotation = 1 end
@ -290,32 +296,32 @@ local function on_tick(event)
end
end
end
if game.tick % 200 == 0 then
for _, pets in pairs(global.player_pets) do
local player = game.players[pets.owner]
if game.tick % 200 == 0 then
for _, pets in pairs(global.player_pets) do
local player = game.players[pets.owner]
if pcall(function () local x = pets.entity.name end) then
if global.pet_command_rotation % 15 == 0 then
local surface = game.surfaces[1]
if global.pet_command_rotation % 15 == 0 then
local surface = game.surfaces[1]
local pet_pos = pets.entity.position
local pet_name = pets.entity.name
local pet_direction = pets.entity.direction
pets.entity.destroy()
pets.entity = surface.create_entity {name=pet_name, position=pet_pos, direction=pet_direction, force="player"}
pets.entity.destroy()
pets.entity = surface.create_entity {name=pet_name, position=pet_pos, direction=pet_direction, force="player"}
end
if global.pet_command_rotation % 2 == 1 then
pets.entity.set_command({type=defines.command.go_to_location, destination=player.position,distraction=defines.distraction.none})
else
local fake_pos = pets.entity.position
pets.entity.set_command({type=defines.command.go_to_location, destination=fake_pos,distraction=defines.distraction.none})
end
end
else
global.player_pets[pets.id] = nil
local str = player.name .. "´s pet died ;_;"
game.print(str)
end
end
global.pet_command_rotation = global.pet_command_rotation + 1
end
end
global.pet_command_rotation = global.pet_command_rotation + 1
end
end
@ -334,7 +340,7 @@ function help()
headline_label.style.font = "default-listbox"
headline_label.style.font_color = { r=0.98, g=0.66, b=0.22}
local text_box = info_table.add { type = "text-box", text = infotext, name = "text_box" }
text_box.read_only = true
text_box.selectable = true