Stars Host Editor

From Stars!wiki
Revision as of 19:59, 2 June 2008 by Gible (talk | contribs) (New page: '''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...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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.

'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 was written for v0.1, so is no longer entirely applicable.

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 to hard(says Gible XD).

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

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, I found that the script created a complete new set of .m files, which showed the changes I had made. -Gible

Examples

StarsHostEditor.vbs

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 on colonised worlds.

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")