Jump to content

A fun little Python script


_Augustus_

Recommended Posts

My brother and I made this for my KSP SpaceEngine project, it generates Kerbalized stars.

Works with Python 0.7.10.

import randomimport os
import base64
prefixes = ["Ker", "Jo", "Ear", "Ju", "Jeb", "Plu", "Nep", "Bes", "Tat", "Coru", "Dego", "Ho", "Geo", "Mu", "Usta", "Pla", "Gal", "Rea", "Olym", "Mor", "Mar", "Jup", "Sa", "Sat", "Kry", "Ee", "Su", "Spar", "He", "Xa", "Sak", "So", "Ha", "Kor", "Ath", "Chand", "Rig", "Ven", "Den", "C", "Holo", "Korr", "Bo", "Ran"]
suffixes = [ "bin", "ol", "th", "to", "ne", "in", "ant", "bah", "sis", "n", "os", "ch", "dor", "vin", "s", "ury", "us", "it", "er", "urn", "une", "pau", "far", "ton", "lou", "vin", "tax", "dar", "aar", "l", "la", "nth", "il", "ifrey", "nus", "neb", "ron", "ii", "iban", "trax", "turus", "clos", "daa"]
error1 = "Invalid input."
error2 = "Please try again."
typeLetters = ["O","B","A","F","G","K","F","G","F","G","K","F","G","K","K","K","K","K","M","M","M","M","M","M","M","M","M","M","M","M","M","M","M","M","M","M","M","M","L","T","L","T","L","T","L","T","L","T","L","T","L","T","C","S"]
typeRmnNm = ["III", "IV", "IV", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "VI", "VI"]
while True:
try:
numOfNam = int(input('INSERT NUMBER OF STARS:'))
for a in range(0, numOfNam):
random.seed()
distance = random.randint(2, 50)
currentPref = random.choice(prefixes)
currentSuff = random.choice(suffixes)
currentName = "Name:" + currentPref + currentSuff
currentLetter = random.choice(typeLetters)
if currentLetter == "L":
currentRmnNm = "V"
else:
if currentLetter == "T":
currentRmnNm = "V"
else:
currentRmnNm = random.choice(typeRmnNm)
currentNum = str(random.randrange(0, 9))
currentType = "Type:" + currentLetter + currentNum + currentRmnNm
currentDist = "Distance:" + str(distance) + " parsecs"
print(currentName)
print(currentType)
print(currentDist)
except ValueError:
for letter in error:
sys.stdout.write(error1)
time.sleep(.1)
print(error2)

Link to comment
Share on other sites

Small error. In your imports, there's this:

import randomimport os

import base64

"Import randomimport os" should be

import random
import os

(It was probably just a typo)

Other than that, I ran it in Python 3.3.5 and it works just fine. :D

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...