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

Merge branch 'develop' into nightfall

This commit is contained in:
Valansch 2018-10-26 23:56:37 +02:00 committed by GitHub
commit d1d62d9c5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 422 additions and 75 deletions

View File

@ -1,42 +1,25 @@
# RedMew Scenario
## RedMew
RedMew is a Factorio community that hosts custom servers, maps in different shapes and sizes, scripted scenarios and
modded servers. The majority of the games hosted, are available to the public, for all players, no matter how
experienced and can be found in the Factorio multi-player lobby.
## Getting Started
## The Community
You can join the RedMew community on Discord by visiting http://redmew.com/discord
To use our scenario download it [here](https://github.com/Valansch/RedMew/archive/develop.zip) and unzip it into %AppData%/factorio/scenarios/ (~/.factorio/scenarios for linux). If you are using our scenario for a public-facing multiplayer server, please be sure to provide attribution back here to the github and keep links to our discord/patreon/website intact.
To join a RedMew Factorio server, follow the following steps in Factorio:
- From the main menu, press "Play"
- In the next window press "Multiplayer"
- Next select "Browse public games" (this requires a factorio account and may prompt you to log in)
- In the list of "Browse games" you can filter for "RedMew" and you will see all RedMew hosted maps
## Generating maps
> _Note_: Not every server in this list will be official. If you're in doubt, join Discord and ask.
There are 3 ways to generate maps using our scenario: Vanilla, FactorioMapConverter and Custom Maps.
### Vanilla
Just start the scenario from the scenario menu and you are ready to go.
## Documentation
You can find an overview of [the documentation in the docs directory](/docs/Index.md)
### Custom Maps
## Contributing
If you wish to contribute, don't hesitate to make a Pull Request or open an issue. When in doubt, you can always ask
on [Discord](http://redmew.com/discord).
We have many premade map modules that you can combine to create a unique map.
Checkout [map_gen/data/map_previews](https://github.com/Valansch/RedMew/tree/develop/map_gen/data/.map_previews) to view all our modules.
You can select and activate a module by removing the "--" infront of the module in the map_layout.lua file.
You can mix as many modules as you want, as long as they logically fit together.
Futher instructions on this read the comments in the map_layout.lua file.
### FactorioMapConverter
You can generate your own maps from images. This works in 2 steps:
First convert the image file into a lua file (For example image_data.lua). Then use our scenario to loa the image_data.lua file and generate the map from it.
To achieve this please follow these steps:
1. Download the Map Converter [here](https://github.com/grilledham/FactorioMapConverter/releases) (Windows only) to generate the image_data.lua.
2. Place your image_data.lua file in the folder /map_gen/data/presets/
3. Create new lua file (for example my_image.lua) inside the folder map_gen/presets/. This file is used to configure your map (scale, translaten etc.)
To do this you can copy map_gen/presets/template.lua and replace line 8 to point to your image_data.lua
4. Load your new preset by adding a new line to map_layout.lua. This should look similar to this:
```MAP_GEN = require "map_gen.presets.my_image.lua"```
5. Load the scenario from the scenario menu.
## License
The RedMew codebase is licensed under the [GPL3 License](LICENSE).

6
docs/Index.md Normal file
View File

@ -0,0 +1,6 @@
## RedMew Documentation Index
- [Installing and Using the RedMew Scenario](Installation.md)
- [Creating a New Scenario Using the RedMew Framework](NewScenario.md)
### Scenario Specific Documentation
- [Diggy Installation and Configuration](scenarios/Diggy.md)

49
docs/Installation.md Normal file
View File

@ -0,0 +1,49 @@
## Installing and Using the RedMew Scenario
Some scenarios have more detailed information, please check [the index](Index.md) before continuing with the generic
RedMew installation. To install the RedMew scenario directly into something playable, [download the
archive](https://github.com/Valansch/RedMew/archive/develop.zip) and take the next step based on your Operating System.
- **Windows**: extract the the zip file into `%appdata%\Factorio\Scenarios\RedMew`
- **MacOS**: extract the the zip file into `~/Library/Application Support/factorio/Scenarios/RedMew`
- **Linux**: extract the the zip file into `~/.factorio/scenarios/RedMew`
Make sure it's called RedMew and there's a `control.lua` in the root of that directory. If you are using the RedMew
scenario for a public-facing multi-player server, be sure to provide attribution back to github and keep links to the
Discord, Patreon and website intact.
> _Note_: these locations are based on the default configuration [defined by
factorio](https://wiki.factorio.com/Application_directory). If your installation is not default, you have to find your
scenarios directory in another way.
## Generating maps
There are 3 ways to generate maps using our scenario: Vanilla, FactorioMapConverter and Custom Maps.
### Vanilla
Start the scenario from the scenario menu and you are ready to go. Additionally you can turn features on or off via
[`control.lua`](../control.lua) if desired.
### Custom Maps
There are many pre-made map modules that can be combined to create a unique map.
Map module previews can be found in [map_gen/data/.map_previews](../map_gen/data/.map_previews). You can select and
activate a module by removing the `--` in front of the require in [`map_layout.lua`](../map_layout.lua).
You can mix as many modules as you want, as long as they logically fit together.
### FactorioMapConverter (Windows only)
You can generate your own maps from images. First convert the image file into a lua file (For example `image_data.lua`).
Then use our scenario to load the `image_data.lua` file and generate the map from it.
To create your own map preview:
1. Download the Map Converter [here](https://github.com/grilledham/FactorioMapConverter/releases) to generate the
`image_data.lua`.
2. Place your `image_data.lua` file in the `map_gen/data/presets/` directory.
3. Create new lua file (for example `my_image.lua`) inside the folder `map_gen/presets/`. This file is used to configure
your map (scale, translate etc.). To do this, you can copy `map_gen/presets/template.lua` and replace line 8 to point
to your `image_data.lua`
4. Load your new preset by adding a new line to `map_layout.lua`. This should look similar to this:
```lua
MAP_GEN = require "map_gen.presets.my_image.lua"
```
5. Load the scenario from the scenario menu.

28
docs/NewScenario.md Normal file
View File

@ -0,0 +1,28 @@
## Creating a New Scenario Using the RedMew Framework
To add a new scenario and make it available to everyone that wants to use RedMew, make a Pull Request on github to
request adding your scenario to the repository.
### Starting From Scratch
Depending on the size of the scenario, it could be desired to have its own dedicated directory. By default a scenario
is added in `map_gen/combined/your_scenario.lua`.
#### Step 1
If you're not experienced with git, it's advised to read up on how git works first or ask someone else to help out. To
get your change into the repository, you need to [fork the repository](https://help.github.com/articles/fork-a-repo/)
and eventually make your Pull Request from there. [Clone](https://help.github.com/articles/cloning-a-repository/) the
fork to your local environment and get your favorite IDE or Editor ready.
#### Step 2
Small scenarios can go into a single lua file, bigger scenarios might need their own dedicated directory. To follow the
RedMew structure for scenarios, create your scenario file: `map_gen/combined/your_scenario_file.lua`.
#### Step 3 (Optional)
If you plan on making a bigger scenario, create a directory: `map_gen/combined/your_scenario_file/` where you can place
your scenario specific lua files.
#### Step 4
Regardless, the `map_gen/combined/your_scenario_file.lua` file will be the entry point for your scenario and will be
loaded via `map_layout.lua`. Underneath `--combined--`, add your require: `require map_gen.combined.your_scenario_file`.
When making the Pull Request, make sure to comment the require in `map_layout.lua` as by default it should be off. To
enable debugging and get some extra feedback during development, enable `_DEBUG` in `config.lua`.

63
docs/scenarios/Diggy.md Normal file
View File

@ -0,0 +1,63 @@
## Diggy Installation and Configuration
Diggy is a custom [RedMew](../../README.md) scenario. You start out with nothing but a market, your pick-axe and some
walls [deep, deep in the mine](https://www.youtube.com/watch?v=ov5pxaIbJlM). The goal is to launch a rocket, but be
careful, there's not a lot of space and the mine is unstable!
- Gameplay: https://www.youtube.com/watch?v=J3lheDK-6Cw
- Time lapse video: https://www.youtube.com/watch?v=4cRsx-wl_fk (By Namelesshunter Gaming)
> _Note_: Scenarios- also known as soft-mods- are scripted maps. They can be played online without having to download
any mods as the script is included in the map.
### Scenario Information
The idea of Diggy is similar to vanilla, except that it greatly changes how to build your factory. As you're in a cave,
each rock you dig, each support entity you remove and every tile you mine, can cause a collapse. You can use walls,
stone paths and (refined) concrete floor to increase the strength of your mine and reduce the chance of a collapse.
Whenever you place or remove a wall for example, the stress level of the area around it (9x9 tiles) will rise or lower.
When a certain threshold is reached, the cave will collapse. You can stop this by quickly placing walls or run away as
fast as you can. Letting the cave collapse _will_ destroy structures below it! The recommended pattern on dirt is to
place a wall every 4th tile. Using stone paths and concrete will increase this to 5 tiles while refined concrete will
make it 6.
## How to start Diggy for Single-player mode
#### Step 1
Download the zip file from
[https://github.com/Valansch/RedMew/archive/develop.zip](https://github.com/Valansch/RedMew/archive/develop.zip)
#### Step 2
- **Windows**: extract the the zip file into `%appdata%\Factorio\Scenarios\Diggy`
- **MacOS**: extract the the zip file into `~/Library/Application Support/factorio/Scenarios/Diggy`
- **Linux**: extract the the zip file into `~/.factorio/scenarios/Diggy`
Make sure it's called Diggy and there's a `control.lua` in the root of that directory.
> _Note_: these locations are based on the default configuration [defined by
factorio](https://wiki.factorio.com/Application_directory). If your installation is not default, you have to find your
scenarios directory in another way.
#### Step 3
Open `map_layout.lua` in that directory and look for `--require "map_gen.combined.diggy"`.
Change this to `require "map_gen.combined.diggy"`, by removing the double dashes.
#### Step 4
In factorio start either a local or online game via Scenarios. Select `Diggy` under
`User scenarios` and start it up.
> _Note:_ Downloading the latest version might not always be a functional version, please consult on discord for a
working version if this is the case.
#### Step 5 (optional)
Diggy is designed to work for at least 15 players online, working together. It's advised to change the configuration
to adjust the difficulty for your needs. You can find the config in `map_gen/Diggy/Config.lua`. Most options should be
well-explained. For Single-player it's recommend to enable cheats with modified values. You can change the starting
items and some pre-defined cheat values (if cheats are enabled) under the `SetupPlayer` config item.
You can turn off certain features if you wish.
- DiggyCaveCollapse, disable this feature if you wish to play without collapses.
- SimpleRoomGenerator, disable this if you want to play without room generation. _**WARNING:** this is the mechanic
that spawns water._
- AlienSpawner, disable this if you wish to disable spawning biters and spitters when mining.
- ScatteredResources, used to tweak random resource spawning.
- MarketExchange, regulates all the market related features.

View File

@ -11,6 +11,7 @@ local Debug = require 'map_gen.Diggy.Debug'
local Template = require 'map_gen.Diggy.Template'
local Global = require 'utils.global'
local insert = table.insert
local max = math.max
-- this
local MarketExchange = {}
@ -182,39 +183,192 @@ local function on_research_finished(event)
update_stone_collecting()
end
local function redraw_title(data)
data.frame.caption = stone_tracker.stone_sent_to_surface .. ' ' .. config.currency_item .. ' sent to the surface'
local function comma_value(n) -- credit http://richard.warburton.it
local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right
end
local function redraw_list(data)
local function redraw_title(data)
data.frame.caption = comma_value(stone_tracker.stone_sent_to_surface) .. ' ' .. config.currency_item .. ' sent to the surface'
end
local function get_data(unlocks, stone, type)
local result = {}
for _, data in pairs(unlocks) do
if data.stone == stone and data.type == type then
insert(result, data)
end
end
return result
end
local tag_label_stone = Gui.uid_name()
local tag_label_buff = Gui.uid_name()
local tag_label_item = Gui.uid_name()
local function apply_heading_style(style)
style.font = 'default-bold'
style.align = 'center'
end
local function redraw_heading(data)
local frame = data.market_list_heading
Gui.clear(frame)
local heading_table = frame.add {type = 'table', column_count = 3}
local label = heading_table.add {type = 'label', name = tag_label_stone, caption = 'Name'}
local label_style = label.style
apply_heading_style(label_style)
label_style.width = 90
local label = heading_table.add {type = 'label', name = tag_label_buff, caption = 'Buff'}
local label_style = label.style
apply_heading_style(label_style)
label_style.width = 200
local label = heading_table.add {type = 'label', name = tag_label_item, caption = 'Item'}
local label_style = label.style
apply_heading_style(label_style)
label_style.width = 200
end
local function redraw_progressbar(data)
local progressbar = data.market_progressbar
Gui.clear(progressbar)
progressbar.style.width = 540
-- get highest amount of stone
local number_of_unlockables = #config.unlockables
local highest_amount = config.unlockables[number_of_unlockables].stone
-- calc % of stones sent
local stone_sent = stone_tracker.stone_sent_to_surface / highest_amount
progressbar.value = stone_sent
end
local function redraw_table(data)
local market_scroll_pane = data.market_scroll_pane
Gui.clear(market_scroll_pane)
local add = market_scroll_pane.add
local buffs = {}
local items = {}
local last_stone = 0
local number_of_rows = 0
local row = {}
for _, unlockable in pairs(config.unlockables) do
local is_unlocked = unlockable.stone <= stone_tracker.stone_sent_to_surface
local message
-- only add the item to the market if it's between the old and new stone range
if (unlockable.type == 'market') then
message = 'Market item: ' .. unlockable.prototype.name
elseif (unlockable.type == 'buff' and unlockable.prototype.name == 'mining_speed') then
message = 'Manual mining speed: +' .. unlockable.prototype.value .. '%'
elseif (unlockable.type == 'buff' and unlockable.prototype.name == 'inventory_slot') then
message = 'Inventory slot: +' .. unlockable.prototype.value
elseif (unlockable.type == 'buff' and unlockable.prototype.name == 'stone_automation') then
message = 'Automate stone to surface: +' .. unlockable.prototype.value
else
Debug.print('failed getting a message for: ' .. serpent.line(unlockable))
redraw_progressbar(data)
-- create table headings
redraw_heading(data)
-- create table
for i = 1, #config.unlockables do
if config.unlockables[i].stone ~= last_stone then
-- get items and buffs for each stone value
buffs = get_data(config.unlockables, config.unlockables[i].stone, 'buff')
items = get_data(config.unlockables, config.unlockables[i].stone, 'market')
-- get number of rows
number_of_rows = max(#buffs, #items)
-- loop through buffs and items for number of rows
for j = 1, number_of_rows do
local result = {}
-- 1st column
if buffs[j] ~= nil then
result[1] = buffs[j].stone
else
result[1] = items[j].stone
end
-- 2nd column
if buffs[j] ~= nil then
if buffs[j].prototype.name == 'mining_speed' then
result[2] = '+ '.. buffs[j].prototype.value .. '% mining speed'
end
if buffs[j].prototype.name == 'inventory_slot' then
if buffs[j].prototype.value > 1 then
result[2] = '+ '.. buffs[j].prototype.value .. ' inventory slots'
else
result[2] = '+ '.. buffs[j].prototype.value .. ' inventory slot'
end
end
if buffs[j].prototype.name == 'stone_automation' then
result[2] = '+ '.. buffs[j].prototype.value .. ' stones automatically sent'
end
else
result[2] = ''
end
-- 3rd column
if items[j] ~= nil then
result[3] = '+ ' .. items[j].prototype.name
else
result[3] = ''
end
-- indicator to stop print stone number
if j > 1 then
result[4] = true
else
result[4] = false
end
-- indicator to draw horizontal line
if j == number_of_rows then
result[5] = true
else
result[5] = false
end
insert(row, result)
end
end
message = unlockable.stone .. ' stone: ' .. message
-- save lastStone
last_stone = config.unlockables[i].stone
end
local label = add({type = 'label', caption = message})
if (is_unlocked) then
label.style.font_color = {r = 1, g = 1, b = 1}
-- print table
for _, unlockable in pairs(row) do
local is_unlocked = unlockable[1] <= stone_tracker.stone_sent_to_surface
local list = market_scroll_pane.add {type = 'table', column_count = 3 }
list.style.horizontal_spacing = 16
local caption = ''
if unlockable[4] ~= true then
caption = comma_value(unlockable[1])
else
label.style.font_color = {r = 0.5, g = 0.5, b = 0.5}
caption = ''
end
local tag_stone = list.add {type = 'label', name = tag_label_stone, caption = caption}
tag_stone.style.minimal_width = 90
local tag_buffs = list.add {type = 'label', name = tag_label_buff, caption = unlockable[2]}
tag_buffs.style.minimal_width = 200
local tag_items = list.add {type = 'label', name = tag_label_item, caption = unlockable[3]}
tag_items.style.minimal_width = 200
-- draw horizontal line
if unlockable[5] == true then
list.draw_horizontal_line_after_headers = true
end
if (is_unlocked) then
tag_stone.style.font_color = {r = 1, g = 1, b = 1 }
tag_buffs.style.font_color = {r = 1, g = 1, b = 1 }
tag_items.style.font_color = {r = 1, g = 1, b = 1 }
else
tag_stone.style.font_color = {r = 0.5, g = 0.5, b = 0.5 }
tag_buffs.style.font_color = {r = 0.5, g = 0.5, b = 0.5 }
tag_items.style.font_color = {r = 0.5, g = 0.5, b = 0.5 }
end
end
end
@ -258,6 +412,10 @@ local function toggle(event)
frame = center.add({name = 'Diggy.MarketExchange.Frame', type = 'frame', direction = 'vertical'})
local market_progressbar = frame.add({type = 'progressbar', tooltip = '% stones sent'})
local market_list_heading = frame.add({type = 'flow', direction = 'horizontal'})
local market_scroll_pane = frame.add({type = 'scroll-pane'})
market_scroll_pane.style.maximal_height = 400
@ -265,11 +423,13 @@ local function toggle(event)
local data = {
frame = frame,
market_progressbar = market_progressbar,
market_list_heading = market_list_heading,
market_scroll_pane = market_scroll_pane,
}
redraw_title(data)
redraw_list(data)
redraw_table(data)
Gui.set_data(frame, data)

View File

@ -1,16 +1,3 @@
## How to start Diggy
## RedMew - Diggy, Custom Scenario
##### Step 1
Download the zip file from https://github.com/Valansch/RedMew/archive/develop.zip
##### Step 2
On Windows: extract the the zip file into `%appdata%\Factorio\Scenarios\Diggy`,
make sure it's called Diggy and there's a `control.lua` in the root of that directory.
##### Step 3
Open `map_layout.lua` in that directory and look for `--require "map_gen.combined.diggy"`.
Change this to `require "map_gen.combined.diggy"`, by removing the double dashes.
##### Step 4
In factorio start either a local or online game via Scenarios. Select `Diggy` under
`User scenarios` and start it up.
The documentation for Diggy has moved to [docs/scenarios/Diggy.md](../../docs/scenarios/Diggy.md).

70
map_gen/misc/car_body.lua Normal file
View File

@ -0,0 +1,70 @@
local Event = require 'utils.event'
local Game = require 'utils.game'
local drivers_group = "Drivers"
local function transfer_body(player)
-- Remove the player from their character and place them in a car.
local surface = player.surface
local force = player.force
local pos = force.get_spawn_position(surface)
-- Choose a random direction for the car to face
local dir = math.random (0,7)
-- Remove the players' character
if player.character then
player.character.destroy()
end
--Find a place for a car, place a car, and place fuel+ammo in it
local car_pos = surface.find_non_colliding_position('car', pos, 0, 3)
local car = surface.create_entity {name = 'car', position = car_pos, direction = dir, force = force}
car.insert({name="coal", count=50})
car.insert({name="firearm-magazine", count=10})
car.set_driver(player)
end
local function player_created(event)
local player = Game.get_player_by_index(event.player_index)
local permissions = game.permissions
-- We want to create a permission group to stop players leaving their vehicles.
-- Check if the permission group exists, if it doesn't, create it.
local permission_group = permissions.get_group(drivers_group)
if not permission_group then
permission_group = permissions.create_group(drivers_group)
-- Set all permissions to enabled
for action_name, _ in pairs(defines.input_action) do
permission_group.set_allows_action(defines.input_action[action_name], true)
end
-- Disable leaving a vehicle
permission_group.set_allows_action(defines.input_action.toggle_driving, false)
end
-- Add player to drivers group
permission_group.add_player(player)
-- Put the new player into a car.
transfer_body(player)
-- Disable the god mode spotlight.
player.disable_flashlight()
-- Welcome message to the player.
player.print('As though a dream, you find yourself without a body and instead as a sentient car. Strange...')
end
local function revive_player(event)
-- When a player's car dies, return them to spawn and create a new car for them.
local player = Game.get_player_by_index(event.player_index)
-- This check prevents a loop when we put them into a car.
if not player.driving then
transfer_body(player)
player.print('Although you left one vehicle, you just find yourself in another.')
end
end
Event.add(defines.events.on_player_created, player_created)
Event.add(defines.events.on_player_driving_changed_state, revive_player)

View File

@ -133,6 +133,7 @@ miscs = {}
--require ('map_gen.misc.restrict_landfill_tile')({['water'] = true})
--require "map_gen.ores.rso.rso_control"
--require 'map_gen.misc.nightfall'
--require 'map_gen.misc.car_body'
if #entity_modules > 0 then
shape = shape or b.full_shape