pioneerspacesim / pioneer

A game of lonely space adventure
https://pioneerspacesim.net
1.62k stars 375 forks source link

Auto-generation of custom system .lua files #1565

Open Irdwrwyn opened 11 years ago

Irdwrwyn commented 11 years ago

Hello. I hope I'm doing this right...

It's been suggested I should put an idea in here - unfortunately I'm not a programmer and I wouldn't be contribute any working code myself (unless you want a module that generates "Hello, World!"), so I'll just throw it in and see if anyone likes it.

I've been tinkering, in the simplest sense, with the custom Sol and Epsilon Eridani .lua system files - just changing names and adding a starport here and there. I have had a go at creating my own system from scratch, but I've ended up pushing it too far and caused crashes because I don't really know what I'm doing. So that's my context for this suggestion. I'm one of those people who likes to modify things at a fairly superficial level, and I've been impressed at how well Pioneer reacts to having names changed and ports added and taken away.

I understand that for most systems beyond the central hand-created ones, Pioneer procedurally generates the system contents from a seed when the player enters the system. The seed, I assume, ensures the system is the same every time - but I presume that the end result, at least while the player's in that system, is a full list of star(s), planets, moons and ports, held in the computer's memory.

My suggestion - for the benefit of those of us who like to tinker and customise but wouldn't know one end of a piece of code from the other - would be a process that can be triggered at will by the player that would have the game take the system details it has in memory, write them out into a properly-formatted .lua file, and save them out as a custom file which would replace the stock seed-generated system. I suggest this without any idea how difficult it would be, but if it could be done it would be great to collect custom files as you visit new systems. I can really imagine playing as an explorer (a pioneer?) and discovering new systems and naming things in them as I go.

Anyway, it's a thought. Congratulations on the fantastic work you've all done so far, and thank you for putting so much effort into this!

irigi commented 11 years ago

Isn't it the same as #1318? Otherwise very nice idea, I think it would help a lot.

Irdwrwyn commented 11 years ago

It does look as though it would fall into roughly the same category. What I had in mind was simply the ability to generate system files at will when you wanted to, where #1318 looks to take an area of space and generate files in bulk.

To be honest I'd be happy with either - I'm one of those people who like to be able to customise games, especially sandbox ones, and I was just hoping it could be made a little easier to tweak names and such without necessarily having to build each system file by hand from scratch - which I admit I'm not very good at. :o)

irigi commented 11 years ago

I've been playing with this a bit and I got stuck on this issue: Star systems with multiple stars orbiting each other orbit so-called gravitational points - points with no visible body attached to them, but gravity, which enable mutual rotation. I have been trying to reconstruct the Toliman system, like

local system = CustomSystem:new('Toliman', { 'STAR_G', 'STAR_K' })
        :govtype('NONE')
        :short_desc('Small-scale prospecting. No registered settlements.')
        :long_desc([[]])

local tolimanaXb = CustomSystemBody:new('Toliman A,B', 'GRAVPOINT')
        :radius(f(0,10000))
        :mass(f(16700,10000))

local tolimana = CustomSystemBody:new('Toliman A', 'STAR_G')
        :radius(f(9500,10000))
        :mass(f(9400,10000))
        :temp(5248)
        :semi_major_axis(f(59200,10000))
        :eccentricity(f(343,10000))
        :rotation_period(f(0,10000))
        :axial_tilt(fixed.deg2rad(f(0,10000)))

local tolimanb = CustomSystemBody:new('Toliman B', 'STAR_K')
        :radius(f(8200,10000))
        :mass(f(7300,10000))
        :temp(4918)
        :semi_major_axis(f(0,10000))
        :eccentricity(f(0,10000))
        :rotation_period(f(0,10000))
        :axial_tilt(fixed.deg2rad(f(0,10000)))

-- other planets

system:bodies(tolimanaXb, {tolimana, tolimanb} )
system:add_to_sector(-1,0,-1,v(6.6240,1.6320,4.1600))

But Pioneer doesn't accept the GRAV_POINT type.

Error: [string "systems/custom/05_toliman.lua"]:9: body 'Toliman A,B' does not have a valid type
stack traceback:
        [C]: in ?
        [C]: in function 'new'
        [string "systems/custom/05_toliman.lua"]:9: in main chunk

Could somebody give me a working example of custom star system with the gravpoint, please? Thanks!

irigi commented 11 years ago

And related question: the fact that Toliman B has not defined semi_major_axis and other orbit parameters is somehow connected to the fact that it is a binary star and the orbital parameters are given by Toliman A?

irigi commented 11 years ago

I wrote some exporter - consider it first version which will yet require a lot of testing. Exported files can be used with branch #1700, or with "minimal corrections branch" #1701.

impaktor commented 10 years ago

It is now possible to dump a selected part of the galaxy to a raw data format, from the command line (#2811). It does about half of what is requested here.