I have posted a Win32 installer for the latest code from the "javascript" branch. Get it from the Oolite-PC site:
https://developer.berlios.de/project/sh ... up_id=2999
This has the basic JavaScript scripting ability, which should be able to reproduce any existing OXP's main script with the exception that it does not allow multiple mission scripts in a single file. This feature should not be necessary within any single OXP.
Some preliminary documentation for writing scripts in JavaScript can be found at:
http://wiki.alioth.net/index.php/Oolite ... pt_Scripts
http://wiki.alioth.net/index.php/Oolite ... bjectModel
The "listen for keypress" feature is broken at present due to having lost some of the JavaScript integration code when some file renames came across from the trunk. The SVN docs say you can safely rename files, so I must have done it wrong :-(
This version also includes the initial equipment damage work I've been doing.
In answer to the database question, it is an interesting idea but not something I have time to do. It would be a pretty well isolated piece of work if anyone wants to have a go at it.
I'd like this code to make it into the main game one day, which is why it hasn't been done in the textured-planets branch. Textured-planets users should be able to save their oolite.exe and libnoise.dll files and put them back into this one's installation directory to go back to it. If this code ever gets finished and into the trunk, it can then be merged into textured-planets.
If you want to try this, I suggest you back up your current installation (zipping it up should work fine), then copy you saved game files somewhere else AGAIN, then uninstall the current version and install this one.
Here is LittleBear's Asteroid Storm! script translated into JavaScript. You can drop this in the OXP's Config directory and get rid of the existing script.plist and everything should still work.
Code: Select all
this.Name = "AsteroidStorm"
this.Description = "A large asteroid heads for a well-known station!"
this.Version = "1.0"
// This is called from a couple of places, so put into a common function
function removeStation() {
// Setting info for a specific planet has to be done the "old" way via the Player.Call method until I have added the facility to get an arbitrary system object to the object model.
Player.Call("setSpecificPlanetInfo", "0=55=station=none")
Player.Call("setSpecificPlanetInfo", "0=55=description=The planet Leesti is reasonably fabled for Zero-G cricket and Leestiian evil juice, but cursed by deadly asteroid storms. Leesti's orbital station was recently destroyed by a large asteroid strike. Ships without planet landing capabilities are therefore advised to avoid this system.")
}
this.Initialise = function () {
// Remove the station if it was blown up in a previous session
if (MissionVars["mission_asteroids_statdead"] == 1)
removeStation()
}
this.STATUS_DOCKED = function () {
if (!DockedAtMainStation)
return
if (GalaxyNumber == 0 && PlanetNumber == 55) {
if (MissionVars["mission_asteroids"] == undefined && Player.Score > 63) {
Mission.ImageFilename = ""
Mission.ShowMissionScreen()
Mission.ShowShipModel("ast1")
Mission.MusicFilename = "warning.ogg"
Mission.MissionScreenTextKey = "asteroidsbrief_1"
MissionVars["mission_asteroids"] = "B"
MissionVars["mission_asteroids_statdead"] = 0
MissionVars["mission_asteroids_rockdead"] = 0
MissionVars["mission_asteroids_toldoff"] = 0
MissionVars["mission_asteroids_final"] = 0
return
}
if (MissionVars["mission_asteroids"] == "R" && MissionVars["mission_asteroids_toldoff"] == 0) {
Mission.ImageFilename = "GalCop.PNG"
Mission.ShowMissionScreen()
Mission.MusicFilename = "warning.ogg"
Mission.MissionScreenTextKey = "asteroidsbrief_2"
MissionVars["mission_asteroids_toldoff"] = 1
return
}
}
if (MissionVars["mission_asteroids_final"] == 0) {
if (MissionVars["mission_asteroids"] == "C") {
Mission.ImageFilename = "GalCop.PNG"
Mission.ShowMissionScreen()
Mission.MissionScreenTextKey = "asteroidsbrief_3"
Player.Credits = Player.Credits - 200
Player.LegalStatus = Player.LegalStatus + 25
MissionVars["mission_asteroids"] = "F"
MissionVars["mission_asteroids_final"] = 1
return
}
if (MissionVars["mission_asteroids"] == "asteroids_OVER") {
if (MissionVars["mission_asteroids_statdead"] == 1) {
Mission.ImageFilename = "GalCop.PNG"
Mission.ShowMissionScreen()
Mission.MissionScreenTextKey = "asteroidsbrief_4"
Player.Credits = Player.Credits + 200
MissionVars["mission_asteroids"] = "F"
MissionVars["mission_asteroids_final"] = 1 // I am guessing this should have been done in the original script
return
}
if (MissionVars["mission_asteroids_statdead"] == 0 && MissionVars["mission_asteroids_rockdead"] == 1) {
Mission.ImageFilename = "GalCop.PNG"
Mission.ShowMissionScreen()
Mission.MissionScreenTextKey = "asteroidsbrief_5"
Player.Credits = Player.Credits + 1000
Player.LegalStatus = 0
Player.AwardEquipment("EQ_ENERGY_BOMB")
MissionVars["mission_asteroids"] = "F"
MissionVars["mission_asteroids_final"] = 1
return
}
}
}
}
this.STATUS_LAUNCHING = function () {
if (MissionVars["mission_asteroids"] == "B") {
Player.RemoveEquipment("EQ_ENERGY_BOMB")
Universe.AddSystemShips("ast1", 30, 1.0)
Universe.AddSystemShips("badrock", 1, 1.0)
MissionVars["mission_asteroids"] = "R"
MissionVars["mission_asteroids_toldoff"] = 0
return
}
if (MissionVars["mission_asteroids"] == "R") {
Player.RemoveEquipment("EQ_ENERGY_BOMB")
MissionVars["mission_asteroids_toldoff"] = 0
return
}
}
this.STATUS_EXITING_WITCHSPACE = function () {
if (MissionVars["mission_asteroids"] == "R") {
MissionVars["mission_asteroids"] = "C"
MissionVars["mission_asteroids_statdead"] = 1
removeStation()
}
}