I created a Python script/program to count the number of machines in a saved game. It’s my work around to help in allocating research points. See my post from a while ago http://positech.co.uk/forums/phpBB3/viewtopic.php?f=49&t=14309. Hopefully some of you will find it useful; at least until the function is incorporated into the game.
This is my first attempt of anything in Python so it certainly has room for improvement. I would like to be able to run it from a desktop icon directly or via a Bat file but I wanted to get this posted before I try to add more ‘bells & whistles’. It’s written in version 3.5 and will need to be ran within the IDLE editor included with Python.
On Win32 it’s a right click of the file name (Count_Machines.py) then press F5 (or use the Run Menu). The script will ask you to select the file you what to analyze then print it out in the Python shell that opened when you ran the script.
Below are some sample printouts of some saved games I download from the forms. See this thread: http://positech.co.uk/forums/phpBB3/viewtopic.php?f=49&t=14576. I could have sworn there more than two files on the thread but this was all I saw. Thanks Enzymus.
Enzymus – “Advanced - Even mo’ money 7.sav”
21 Ioniser
12 Dissolver
18 Pill Printer
14 Evaporator
32 Agglometer
10 Multimixer
2 Shaker
7 Creamer
0 Drug Packer
0 Analyzer
14 Autoclave
0 Cryogenic Condensor
3 Sachet Maker
0 Syringe Injector
1 Centrifuge
21 Chromatograph
0 Ultraviolet Curer
0 Atomic Sequencer
0 Hadron Collider
Enzymus – “Quick Start - Quick draw 5.sav”
28 Ioniser
29 Dissolver
18 Pill Printer
16 Evaporator
43 Agglometer
16 Multimixer
12 Shaker
8 Creamer
0 Drug Packer
0 Analyzer
0 Autoclave
0 Cryogenic Condensor
0 Sachet Maker
0 Syringe Injector
0 Centrifuge
3 Chromatograph
0 Ultraviolet Curer
0 Atomic Sequencer
0 Hadron Collider
You should be able to cut and past the below into a text editor and save it as Count_Machines_V1.py
[code]# Count_Machines_V1.py by Acme_Labs
Created September 19, 2015
Written for Python V3.5
Count the occurance of the phrase in varible Machine_Name in the form of (“id”:“pill_maker”)
Display_Name=‘Ioniser,Dissolver,Pill Printer,Evaporator,Agglometer,Multimixer,Shaker,Creamer,Drug Packer,Analyzer,Autoclave,Cryogenic Condensor,Sachet Maker,Syringe Injector,Centrifuge,Chromatograph,Ultraviolet Curer,Atomic Sequencer,Hadron Collider’
Machine_Name=‘ioniser,dissolver,pill_maker,evaporator,agglomerator,multimixer,shaker,cream_maker,drug_packer,analyzer,autoclave,cryogenic_condensor,sachet_maker,syringe_injector,centrifuge,chromatograph,ultraviolet_curer,atomic_sequencer,hadron_collider’
from tkinter import Tk
from tkinter.filedialog import askopenfilename
root=Tk()
root.withdraw()
Ask for the filename to read.
filename = askopenfilename()
fread = open(filename, “r”)
print(filename)
read the whole file into one string
text = fread.read()
fread.close()
Display_List = Display_Name.split(",")
Word_List = Machine_Name.split(",")
M_Cnt=len(Word_List)
for A in range(0,M_Cnt):
Text2Search = ‘“id”:"’+Word_List[A]+’"’
A_Cnt=text.count(Text2Search)
Dis_Name=Display_List[A]
print(A_Cnt, Dis_Name)
[/code]
To download Python go to: https://www.python.org/