Stars Host Editor

From Stars!wiki
Revision as of 19:03, 5 July 2009 by Gible (talk | contribs) (StarsHostEditor.vbs (0.3))

Jump to: navigation, search

Sage advice from PaulCr: Everything seems to work as I expect it to but I know from experience someone may try to do something with it I would never even think of trying that could break it so I would highly recommend making a backup of any files you edit with it first and then test them out to make sure it has done what you were expecting.

Unless indicated otherwise, the information contained here applies to Stars Host Editor v0.3.

See also:

'Installing'

Run the RunMe.bat to register the ActiveX Control, You will then be able to use it in VBScript, for .net users you should be able to add a reference to the DLL as a .net object. Note: The Readme.txt supplied with v0.2 was written for v0.1, so is no longer entirely applicable.

'Upgrading'

There are two choices for upgrading:

  1. Install as usual by running RunMe.bat to register the ActiveX Control
  2. Copy the new starshosteditor.dll over the old dll. Note that the dll must overwrite the old one. Simply putting the new dll in the same directory as the script you're using is not enough - such dlls will be ignored by the script.

Usage

While knowledge of Visual Basic(or at least programming in general) would certainly help, it is by no means a pre-requisite for creating .vbs files to edit games. Studying the examples below and extrapolating to get the effect you're after shouldn't be too hard (says Gible Icon biggrin.gif).

In version 0.1 each Planet object has the following basic properties available. See the API for a full list of the properties avaliable in the current version:

PlanetID - Readonly
OwnerID, X, Y, NameID - Any changes are currently ignored, intend to have it working in next version (0=player 1, -1=not colonised)
Homeworld - The .hst file seems to ignore changes, the m files do see an effect but will lose it when the host generates
Terraformed - Readonly Boolean
Artefact - Boolean
Ironium, Boranium, Germanium & Population - Any 32 bit signed value
IroniumConcentratration, BoraniumConcentratration & GermaniumConcentratration - 0 to 255
Temperature, Gravity & Radiation - 0-100

In the readme.txt file, PaulCr says: It is possible to load a .m file instead of a .hst file and modify that to show the same changes as you have made to a .hst ie it should be possible to write a script that loads the .hst file and .m files into different objects, makes changes to the .hst file and then looks through the other objects for planets that have the same ID and modify them. However, when editing planets for the Line of Supply/Fog of War game - using v0.2 - I found that the script created a complete new set of .m files, which showed the changes I had made. -Gible

Examples

StarsHostEditor.vbs (0.1/0.2)

  • Version 0.3 was packaged by Gible not PaulCr and contains a different example starshosteditor.vbs (shown below)

This is the demo script provided by PaulCr that sets Iron to 1000000, Bora to 2000000, Germ to 3000000 and artefacts on all worlds and pop to 1100000(?) and colonised all worlds(by player #1).

set obj=createobject("AtlantisSoftware.StarsHostEditor")
obj.load("games\game.hst")
for each Planet in obj.planets
  planet.ironium=1000000
  planet.Boranium=2000000
  planet.Germanium=3000000
  planet.artefact=1
  planet.OwnerID=0
  planet.population=12000
next
obj.save ("games\game1.hst")
msgbox ("Game1 Saved")

LOS-FOW example

This is NOT the exact file I used for the game - I have altered it to maintain the anonymity of the players whose planets were edited. But you can see how I used if statements to select which planets I needed to edit. One could equally use if (planet.PlanetID=145) then planet.Factories=100 to select a planet by it ID(less one?) or if (planet.X=145) then if (planet.y=234) then planet.Mines=100 to select a single planet by its (x,y) coordinates. (bad form really - one should use if ((planet.X=145) and (planet.y=234)) then blah, but I don't know the VB for the 'and' (and? &? &&? +?). Note also that the two properties X and y have different case(X is upper case, y is lower case - I don't know if it matters, but that's what VisualStudio told me I copied the API)

set obj=createobject("AtlantisSoftware.StarsHostEditor")
obj.load("game.hst")
for each Planet in obj.planets
  if (planet.OwnerID=0) then planet.Radiation=50
  if (planet.OwnerID=1) then planet.Gravity=50
  if (planet.OwnerID=2) then planet.Temperature=50
next
obj.save ("game1.hst")
msgbox ("Game1 Saved")

StarsHostEditor.vbs (0.3)

This is an adaption of the example script for Stars Player Editor to show basic planet information instead of fleet information.

set obj=createobject("AtlantisSoftware.StarsHostEditor")
obj.load("game.hst")
dim str
str="PlanetID,OwnerID,X,Y,Grav,Temp,Rad,HW" & chr(13) & chr(10)
for each Planet in obj.planets
  str = str & Planet.PlanetID & "," & Planet.OwnerID & "," & Planet.X & "," & Planet.y & "," & Planet.Gravity & "," & Planet.Temperature & "," & Planet.Radiation & "," & Planet.Homeworld & chr(13) & chr(10)
next
set fso=createobject("Scripting.filesystemobject")
set file=fso.createtextfile (".\planets.txt")
file.write(str)
file.close
msgbox ("Game1 Saved")

Home High Ground example

For Home High Ground[1] I moved all the HWs(and secondary worlds) and then modified all three hab values for every planet. The script below is vastly abridged and sanitised. The swapPlanet() and OriginalGravity/OriginalTempurature/OriginalRadiation that are new in v0.3.

set obj=createobject("AtlantisSoftware.StarsHostEditor") 
obj.load("game.hst")
call obj.swapPlanets(83,243)
...
call obj.swapPlanets(40,128)

for each Planet in obj.planets
 if (planet.PlanetID=0) then planet.Gravity=56
 if (planet.PlanetID=1) then planet.Gravity=97
 ...
 if (planet.PlanetID=215) then planet.Gravity=24
next

for each Planet in obj.planets
 if (planet.PlanetID=0) then planet.Temperature=81
 ...
 if (planet.PlanetID=215) then planet.Radiation=0
next

for each Planet in obj.planets
 if (planet.PlanetID=0) then planet.OriginalRadiation=100
 if (planet.PlanetID=1) then planet.OriginalRadiation=10
 ...
 if (planet.PlanetID=113) then planet.OriginalGravity=45
 ...
 if (planet.PlanetID=214) then planet.OriginalTemperature=10
 if (planet.PlanetID=215) then planet. OriginalTemperature =53
next

obj.save ("hhg.hst")
msgbox ("Game1 Saved")