-
Notifications
You must be signed in to change notification settings - Fork 11
Init module for generation scripts #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
iskrich
wants to merge
3
commits into
lanit-summer:master
Choose a base branch
from
iskrich:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| from datetime import date, datetime | ||
|
|
||
| """Generate custom script | ||
| https://en.wikibooks.org/wiki/Celestia/Scripting | ||
| """ | ||
| def makeScript(shipName="ORBIT", beginDate=date.today().year): | ||
| if (beginDate==date.today().year): | ||
| beginDate = str(beginDate) +'-01-01T00:01:24.0000'+'"}\n' | ||
|
|
||
| script = [ | ||
| '{\n', | ||
| 'time{utc "2015-01-01T00:01:24.0000"}\n', | ||
| 'select{object "Orbit-test-spacecraft"}\n', | ||
| 'center {time 5.0}\n', | ||
| 'goto { time 5.0 }\n', | ||
| 'follow{}\n', | ||
| 'lock{}\n', | ||
| '}' | ||
| ] | ||
| #set new begin date | ||
| script[1] = 'time{utc "' + str(beginDate) + '"}\n' | ||
|
|
||
| #set new ship object | ||
| script[2] = 'select{object "' + str(shipName) + '"}\n' | ||
|
|
||
| f = open("script.cel","w") | ||
| for line in script: | ||
| f.write(line) | ||
| return script | ||
|
|
||
| """Generate ssc script | ||
| https://en.wikibooks.org/wiki/Celestia/SSC_File | ||
| """ | ||
| def makeSSCScript(shipName="ORBIT",beginDate=date.today().year, endDate=date.today().year+1): | ||
| if (beginDate==date.today().year): | ||
| beginDate = str(beginDate) +'-01-01T00:01:24.0000'+'"}\n' | ||
| endDate = str(endDate)+ '-01-01T00:01:24.0000'+'"}\n' | ||
|
|
||
| scriptSSC = [ | ||
| '"Orbit-test-spacecraft" "Sol"\n', | ||
| '{\n', | ||
| '\tClass "spacecraft"\n', | ||
| '\tMesh "orbit.3ds"\n', | ||
| '\tRadius 0.011\n', | ||
| '\tOrientation [ 180 1 0 0 ]\n', | ||
| '\tTimeline [\n', | ||
| '\t# Phase 3: Solstice mission\n', | ||
| '\t{\n', | ||
| '\tBeginning "2015 01 01 00:00:00"\n', | ||
| '\tEnding "2020 9 15 17:02:00"\n', | ||
| '\tOrbitFrame { EclipticJ2000 { Center "Sol/Earth" } }\n', | ||
| '\tSampledTrajectory { Source "orbit.xyzv" }\n', | ||
| '\t}\n', | ||
| '\t]\n', | ||
| '}\n', | ||
| ] | ||
| #set new ship name | ||
| scriptSSC[0] = '"'+str(shipName)+'" "Sol"\n' | ||
| #set new begin/end date | ||
|
|
||
| #when end/begin default | ||
| scriptSSC[9] = '\tBeginning "' +str(beginDate)+'"\n' | ||
| scriptSSC[10] = '\tEnding "' +str(endDate)+'"\n' | ||
|
|
||
| f = open("orbit.ssc","w") | ||
| for line in scriptSSC: | ||
| f.write(line) | ||
| return scriptSSC | ||
|
|
||
| if __name__ == '__main__': | ||
| print makeScript() #return default script | ||
| print makeSSCScript() #return default ssc script | ||
| #and some custom scripts | ||
| print makeSSCScript(beginDate="2015 01 01 00:00:00",endDate="2016 01 01 00:00:00",shipName="ORBIT") | ||
| print makeScript(beginDate="2023 02 03 00:00:00") | ||
| print makeScript(shipName="Orbital battlestation Death Star I") | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(beginDate==null)
{
beginDate=DateTime.Now.Year
}
script = [
-'}' + 'follow{}\n',
-] + 'lock{}\n',