Page 1 of 2
Asteroidia mod [req] [idea]
Posted: Fri Jun 16, 2017 5:38 pm
by meems
Hi all, the community has just finished discussing Factorio 2 dev on the general discussion forum, and the conclusion is its time to start dev, here and now.
I won't call it Factorio 2 here, thats too cheeky, but the plan is to design the successor to F1, and hopefully get the core dev team onboard once they've finished F1.
1st thing we need is to remove the 'you' RPG element of the game. I see that has been done in the campaign ' belt madness' that comes with the game.
anyone know how to do it?
F2 is not an RPG - 4X hybrid like F1 is. Its just a 4X game. Which will make dev a lot easier.
Re: Factorio 2 dev
Posted: Fri Jun 16, 2017 6:08 pm
by meems
dev goal #1 implement god-mode
dev goal #2 implement no night time
...so that player doesn't have to select it from custom scernario, it'll just be set when mod loaded.
Status : needs doing
Re: Factorio 2 dev
Posted: Fri Jun 16, 2017 6:14 pm
by meems
dev goal #3
This one won't be so quick to solve.
The environment setting of F2 is asteroids in space.
This requires :
3a graphics mod
3b map generation mod
There's a fair amount of work there. Anyone know any mods that can be used as a template to get started? Or are we going to have to start from scratch?
Re: Asteroidia mod [req] [idea]
Posted: Fri Jun 23, 2017 6:55 am
by doc
Re: Asteroidia mod [req] [idea]
Posted: Tue Jun 27, 2017 6:14 pm
by meems
wow great work doc.
So the community has at least 1 modder who understands Asteroids are the destiny of Factorio.
Are you sticking with this Asteroids theme?
what are your ideas for it in the future?
Re: Asteroidia mod [req] [idea]
Posted: Tue Jun 27, 2017 7:13 pm
by meems
my version of asteroids would vary from yours in these respects :
- It would not be an extension to F1, player wouldn't need to play thru F1 to get to the mod. It would be asteroids from the start
- It would be in a mode similar to god mode, ( god mode a good approximation )
- no teleporters, use ships to get between 'roids, but once you got a ship to a 'roid, you could zoom there instantly, cos its god mode.
What u think to that?
Re: Asteroidia mod [req] [idea]
Posted: Wed Jun 28, 2017 12:58 am
by doc
Interesting ideas meems. I think it'd be a very different game if you had shuttles and asteroids available at the start. Balancing would be completely different. The aims of my mod have ended up a bit more complex, there is basically a whole extra game layer going on which is your "orbital network" that you manage somewhat indirectly by launching things in rockets.
I'd definitely like to do more things with the asteroids themselves - e.g. finding ancient artifacts, and new dangers. A lot more content should be added in time.
Re: Asteroidia mod [req] [idea]
Posted: Wed Jun 28, 2017 9:10 am
by meems
day #13 of asteroidia dev :
back to dev goal #1 : setting 'god mode'
So far, not managed to do it.
Searching the internet returns no immediate results, but it does give you this
/c game.player.character = nil
from
https://wiki.factorio.com/Console
this sets god mode, from the (ingame?) console
perhaps this console command can be translated into a mod script. I dunno. I'll keep searching
I've got a hypothesis : to set god mode, a modder must alter one of these files
control.lua, or settings.lua
I conjecture this, because on
https://wiki.factorio.com/Tutorial:Modd ... ctorio_mod it says :
Mods with in-game effects will also need a control.lua file, to add scripting.
Mods with configurable user settings will use settings.lua to describe those settings.
God mode could be thought of as an 'in game effect', but I think its more likely to be classed as a setting. However, the description of settings, is for user control. This isn't quite what were after in a mod that forces god-mode, but since in vanilla, god mode is a user setting, there a fair chance the god mode switch will be found in settings.
Re: Asteroidia mod [req] [idea]
Posted: Wed Jun 28, 2017 9:21 am
by British_Petroleum
Have a look at the satellite uplink mod:
viewtopic.php?f=97&t=19883
meems wrote:day #13 of asteroidia dev :
back to dev goal #1 : setting 'god mode'
So far, not managed to do it.
Searching the internet returns no immediate results, but it does give you this
/c game.player.character = nil
from
https://wiki.factorio.com/Console
this sets god mode, from the (ingame?) console
perhaps this console command can be translated into a mod script. I dunno. I'll keep searching
Re: Asteroidia mod [req] [idea]
Posted: Wed Jun 28, 2017 8:08 pm
by meems
thx BP. I had a look. That's a complicated mod with a lot of code. Almost a total mystery to me.
I was able to find the term player.character in the control.lua code in that satellite uplink code.
However, curiously, it is not pre-termed by 'game'. I haven't figured out why yet. Is this a player outside the game? Where is this player then?
I dunno. Its a mystery, like the rest of the code.
After seeing the term player.character in the satellite mod code, along with seeing it as a console command, I felt confident enough to have a go at putting it in settings.lua
as game.player.character = nil as recommended in the wiki.

( I'm using helocopter as a template mod )
hard to make sense of this.
seems factorio is complaining that 'game' does not yet exist, but of course, the game hasn't started yet. Perhaps I'm doing it wrong. Or perhaps god mode has to be activated in control.lua
over the next few weeks I will try to find out.
* edit *
This is what happens if I move the line
" game.player.character = nil " to control.lua
Even though at control.lua we should be ingame, Factorio still doesn't recognise 'game' as an entity.
I'll guess we need to make a script that checks to see if game exists THEN switch game.player.character = nil
Re: Asteroidia mod [req] [idea]
Posted: Thu Jun 29, 2017 9:47 am
by bobingabout
never use game.player.character in control.lua. game.player doesn't exist there anymore. Instead you need to iterate through game.players[] using a for in pairs loop.
As for your issue with the game variable, it doesn't exist in the on_load script, nor as a global. it is however accessible in most other scripts, like on_init (Which is called once the first time the game is loaded/created with this mod installed.)
Re: Asteroidia mod [req] [idea]
Posted: Fri Jun 30, 2017 5:01 am
by featherwinglove
bobingabout wrote:never use game.player.character in control.lua. game.player doesn't exist there anymore.
It does if script is responding to a remote call from the console; game.player is whoever typed it. That's pretty rare though: Muddy Mountains has 66 mods, only
one of which needs console commands.
Re: Asteroidia mod [req] [idea]
Posted: Fri Jun 30, 2017 10:33 am
by meems
Thx for help bob & fwl
Based on your suggestions, I tried this code in control.lua
Code: Select all
function on_init()
for i, player in pairs(game.players) do
player.character = nil
end
end
the game loaded the mod without error, which was an improvement. But on starting a game, god-mode was not activated. It seems factorio ignored the command to set player to nil. Or perhaps it was setting player to not nil soon afterwards. Do you know of any mod which successfully sets god mode at the start of game? I wonder if I can reverse engineer the 'belt madness' subgame and see how its done there. That'll be my next investigation.
I also tried
Code: Select all
function on_init()
for i, player in pairs(game.players) do
player.character = nil
end
game.player.character = nil
end
but got same result
Re: Asteroidia mod [req] [idea]
Posted: Fri Jun 30, 2017 3:59 pm
by DedlySpyder
IIRC, the player doesn't exist yet in on_init.
Try just using on_player_created. You can also get the player_index from that event, look then up with game.players[player_index], and just remove that character (would then work if someone else joined as well).
Re: Asteroidia mod [req] [idea]
Posted: Fri Jun 30, 2017 5:22 pm
by meems
Hi DSpyder
Code: Select all
function on_player_created()
game.player.character = nil
for i, player in pairs(game.players) do
player.character = nil
end
end
I tried your suggestion. But got same result. Player is still created after map generation.

Seems its a toughy, might have to ask Rseding91 for a new API function
Re: Asteroidia mod [req] [idea]
Posted: Fri Jun 30, 2017 5:40 pm
by Bilka
Have you actually registered you function for the event?
This is how you would do that:
Code: Select all
script.on_event(defines.events.on_player_created, your_function_here(event))
Re: Asteroidia mod [req] [idea]
Posted: Fri Jun 30, 2017 9:28 pm
by meems
Hi Bilka, thx for advice.
From programming in the 1980s on my C16+4 basic, BBC micro basic , from haskell, to clean, C , C++, blitz, blitzplus, blitzmax, java, python.. etc. I've never heard of having to register a function. I've always just wrote out a function and used it. LUA and the way factorio uses it are a mystery to me.
I tried your suggestion, my 1st attempt ever at registering a function.
Code: Select all
script.on_event(defines.events.on_player_created, on_player_created(event) )
function on_player_created()
for i, player in pairs(game.players) do
player.character = nil
end
end
I got this error message :

factorio seems to be pissed that I've called on_player_created. Or that on_player_created has a nil value and has been called.
Not sure wtf is going on. If the player is created, then how can on_player_created be nil?
Re: Asteroidia mod [req] [idea]
Posted: Fri Jun 30, 2017 10:24 pm
by Bilka
You are trying to call the function before it is defined. Place the snippet of code that I gave you below your actual function, not above it, so that you define the function before you call it with the event.
Re: Asteroidia mod [req] [idea]
Posted: Sat Jul 01, 2017 1:53 am
by meems
then how come some modders do function registration before the function is defined?
e.g.
Code: Select all
script.on_init(function() On_Init() end)
script.on_configuration_changed(function() On_Init() end)
function On_Init()
global.character_data = global.character_data or {}
global.station_data = global.station_data or {}
end
taken from
https://github.com/Suprcheese/Satellite ... ontrol.lua
Don't understand.
anyway, I tried your suggestion.
Code: Select all
function on_player_created()
for i, player in pairs(game.players) do
player.character = nil
end
end
script.on_event(defines.events.on_player_created, on_player_created(event) )
on generate map, got this error

game doesn't exist? But on_player_created has been called?
I don't understand it.

Re: Asteroidia mod [req] [idea]
Posted: Sat Jul 01, 2017 2:01 am
by Veden
meems wrote:function on_player_created()
for i, player in pairs(game.players) do
player.character = nil
end
end
script.on_event(defines.events.on_player_created, on_player_created(event) )
Code: Select all
function on_player_created()
for i, player in pairs(game.players) do
player.character = nil
end
end
script.on_event(defines.events.on_player_created, on_player_created )
Lua has first class functions, so functions can be passed as variables.
on_player_created(event) is making an invocation with a null variable event.
on_player_created is just passing the function
script.on_event takes a event ID and a function to call when the event ID comes up.