Possible with custom Scenario?
Possible with custom Scenario?
I'm designing some levels and was looking at scripting options. I have not yet found a way to do these things, so please do tell me if it is possible, or if you know a way to manage it.
1) Spawn each player of a multiplayer game in a different place
2) Constantly replenish an Assembler so it never runs out of materials (for 'off map' deliveries and production)
3) Disable a recipe for a player, but still allow it to be built in his Assemblers
4) Track the contents of a chest for scoring and objective purposes
5) Set all structures on the map to be 'Unminable' and 'Unoperable'
1) Spawn each player of a multiplayer game in a different place
2) Constantly replenish an Assembler so it never runs out of materials (for 'off map' deliveries and production)
3) Disable a recipe for a player, but still allow it to be built in his Assemblers
4) Track the contents of a chest for scoring and objective purposes
5) Set all structures on the map to be 'Unminable' and 'Unoperable'
-
- Smart Inserter
- Posts: 1847
- Joined: Sun Feb 23, 2014 3:37 pm
- Contact:
Re: Possible with custom Scenario?
Well, I can help you with #1, I'm not sure about 2-5, I think some are not possible yet.
This will spawn players in predesignated coordinates of the map, and will also respawn them in those coordinates if they die.
You'll obviously need to change the coordinates(you can see the coordinates in the editor with F5 pressed) and expand it if you want it to work with more players.
Code: Select all
require "defines"
function init()
if not global.deadPlayers then
global.deadPlayers = {}
end
end
game.on_init(init)
game.on_load(init)
game.on_event(defines.events.on_entity_died, function(event)
if event.entity.type == "player" then
for index, player in ipairs(game.players) do
if not player.character and not global.deadPlayers[index] then
global.deadPlayers[index] = true
break
end
end
end
end)
game.on_event(defines.events.on_tick, function(event)
for playerIndex, value in pairs(global.deadPlayers) do
local char = game.players[playerIndex]
if char.character then
if playerIndex == 1 then
local position = char.surface.find_non_colliding_position("player", {-1,-188}, 50, 1)
if position ~= nil then char.teleport(position) end
elseif playerIndex == 2 then
local position = char.surface.find_non_colliding_position("player", {149,-42}, 50, 1)
if position ~= nil then char.teleport(position) end
end
global.deadPlayers[playerIndex] = nil
end
end
end)
game.on_event(defines.events.on_player_created, function(event)
local char = game.players[event.playerindex]
if char.character then
if event.playerindex == 1 then
local position = char.surface.find_non_colliding_position("player", {-1,-188}, 50, 1)
if position ~= nil then char.teleport(position) end
elseif event.playerindex == 2 then
local position = char.surface.find_non_colliding_position("player", {149,-42}, 50, 1)
if position ~= nil then char.teleport(position) end
end
end
end)
You'll obviously need to change the coordinates(you can see the coordinates in the editor with F5 pressed) and expand it if you want it to work with more players.
Re: Possible with custom Scenario?
2) Constantly replenish an Assembler so it never runs out of materials (for 'off map' deliveries and production)
Yes, but you don't need to use an assembler to do it. If you can replenish its materials(which is possible) you can spawn in the products too
!
3) Disable a recipe for a player, but still allow it to be built in his Assemblers
Hmmm i'm not so sure about that, but it may work if there is some lua command to autoset recipe(il check so look for an update later)
4) Track the contents of a chest for scoring and objective purposes
Yes
5) Set all structures on the map to be 'Unminable' and 'Unoperable'
I guess with some coding you should be able to do it. Like if you set the structures on the enemy faction and then use lua to check everything that got destroyed and if they was in that force(enemy faction) they would instantly be replaced!
Yes, but you don't need to use an assembler to do it. If you can replenish its materials(which is possible) you can spawn in the products too

3) Disable a recipe for a player, but still allow it to be built in his Assemblers
Hmmm i'm not so sure about that, but it may work if there is some lua command to autoset recipe(il check so look for an update later)
4) Track the contents of a chest for scoring and objective purposes
Yes
5) Set all structures on the map to be 'Unminable' and 'Unoperable'
I guess with some coding you should be able to do it. Like if you set the structures on the enemy faction and then use lua to check everything that got destroyed and if they was in that force(enemy faction) they would instantly be replaced!
Logo
Noticed the told change in FFF #111 so il continue to use my signature ^_^Thanks for listening to our suggestions, devs

I would jump of joy if we could specify which tiles spawned in a surfaces
Re: Possible with custom Scenario?
I managed to get 3 and 5 with one bit of code.
First I set all Assemblers on the map to use the game.forces.neutral force. Then I disable the recipes for the game.forces.player force. This map requires the player use Assemblers with fixed recipes that cant be moved. Some of them will need to be 'rescued' from the biters.
Handy hint, the game.player.findentities can no longer be used. You also don't seem to be able to reference the Surface via the player at init, so use get_surface('nauvis') which is the name of the default world.
First I set all Assemblers on the map to use the game.forces.neutral force. Then I disable the recipes for the game.forces.player force. This map requires the player use Assemblers with fixed recipes that cant be moved. Some of them will need to be 'rescued' from the biters.
Code: Select all
game.on_init(function()
local s1 = game.get_surface("nauvis")
for i,e in ipairs(s1.find_entities{{-500, -500},{500, 500}}) do
e.destructible = false
e.minable = false
e.rotatable = false
e.operable = false
e.force = game.forces.neutral
end
local recipelist = game.forces.player.recipes
for i,v in pairs(recipelist) do
v.enabled = false
end
end
Re: Possible with custom Scenario?
Thanks! This looks good. At some point I want to try to build a 'Lobby Surface' with teleports to different zones.FishSandwich wrote:Well, I can help you with #1
This particular map has 2-4 players on different islands with just indestructible conveyors and trains running between them. So I will create a list of spawn points, and cycle the spawns to even the players out. If more than 4 joining then they will start doubling up.
Re: Possible with custom Scenario?
For number 2 I had considered checking contents each time a new item is produced. Any idea how one could add a custom event to listen for (on_item_assembled) ??
Re: Possible with custom Scenario?
There is a can_insert function you can use.abregado wrote:For number 2 I had considered checking contents each time a new item is produced. Any idea how one could add a custom event to listen for (on_item_assembled) ??
Logo
Noticed the told change in FFF #111 so il continue to use my signature ^_^Thanks for listening to our suggestions, devs

I would jump of joy if we could specify which tiles spawned in a surfaces
Re: Possible with custom Scenario?
Ok, so far things are looking good.
3-5 Are done. Ive created a prototype level to demonstrate the idea. This level is designed for teams of students who should work together to build infrastructure for a factory to maximize its output.
I have not implemented the spawn system in this level but it seems to work AOK.
The level is for 12.1. Feedback appreciated!
https://www.dropbox.com/s/c4scxvzih6ini ... o.zip?dl=0
3-5 Are done. Ive created a prototype level to demonstrate the idea. This level is designed for teams of students who should work together to build infrastructure for a factory to maximize its output.
I have not implemented the spawn system in this level but it seems to work AOK.
The level is for 12.1. Feedback appreciated!
https://www.dropbox.com/s/c4scxvzih6ini ... o.zip?dl=0
Re: Possible with custom Scenario?
Students :O!abregado wrote:Ok, so far things are looking good.
This level is designed for teams of students
Gosh those are some lucky students. Wish my teachers was like you

Logo
Noticed the told change in FFF #111 so il continue to use my signature ^_^Thanks for listening to our suggestions, devs

I would jump of joy if we could specify which tiles spawned in a surfaces
Re: Possible with custom Scenario?
Interesting, I just clicked on FishSandwichs 'Split Dependancies' series. Its a lot like what Im expecting the multiplayer to be like.
Fish: Did you find any gameplay issues with one area?
Did you find one player had too little to do?
if so, how did you combat it?
Fish: Did you find any gameplay issues with one area?
Did you find one player had too little to do?
if so, how did you combat it?
Its a lot of fun, and the students really respect you as a teacher. I guess that is the hardest thing for a teacher to earn!jorgenRe wrote:Gosh those are some lucky students. Wish my teachers was like you!
Re: Possible with custom Scenario?
I watched their series and the biggest problem i think they had was doing the logistics between themabregado wrote:Interesting, I just clicked on FishSandwichs 'Split Dependancies' series. Its a lot like what Im expecting the multiplayer to be like.
Fish: Did you find any gameplay issues with one area?
Did you find one player had too little to do?
if so, how did you combat it?

Its a mess to say it simply, but the series was fun

Logo
Noticed the told change in FFF #111 so il continue to use my signature ^_^Thanks for listening to our suggestions, devs

I would jump of joy if we could specify which tiles spawned in a surfaces
-
- Smart Inserter
- Posts: 1847
- Joined: Sun Feb 23, 2014 3:37 pm
- Contact:
Re: Possible with custom Scenario?
Sometimes we thought there was nothing to do, so we'd go and randomly fix issues in other 2 bases, or attack aliens. Apart from that, no real issues with it.jorgenRe wrote:Fish: Did you find any gameplay issues with one area?
Did you find one player had too little to do?
if so, how did you combat it?
Re: Possible with custom Scenario?
Ok, my levels wont have any aggressive combat in them, so I might have to entertain them some other way. Perhaps constant attacks and turret maintenance.FishSandwich wrote: Sometimes we thought there was nothing to do, so we'd go and randomly fix issues in other 2 bases, or attack aliens. Apart from that, no real issues with it.