mission.setinstructions creates mission variable ?

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
Lone_Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 545
Joined: Wed Aug 08, 2007 10:59 pm
Location: Netherlands

mission.setinstructions creates mission variable ?

Post by Lone_Wolf » Thu Oct 02, 2014 2:03 pm

In my shield cycler oxp i wanted to show internal vars on the F5+F5 manifest screen .
I adapted code from thargoid repairbots oxp, and made this :

Code: Select all

"use strict";
this.name           = "SC worldscript events";
this.author         = "Lone_Wolf";
this.copyright      = "(C) 2011,2012 , 2014 Lone_Wolf.";
this.licence        = "CC-by-SA 4.0";
this.description    = "SC worldscript event handler";
this.version        = "1.10.2";

this.startUp = function()
  {
    if ( worldScripts["Shield Cycler"].startUp ) { worldScripts["Shield Cycler"].startUp(); };
  };

// worldscript events
this.guiScreenWillChange = function(to, from)
  {
    if ( to !== "GUI_SCREEN_MANIFEST" ) { return; };
    if ( worldScripts["Shield Cycler"]._sc_settings.sc.version == worldScripts["Shield Cycler"]._sc_const.none ) { return; };
    var _sc_display_strings = ["none","basic","standard","advanced"];
    var sc_display_cycler = _sc_display_strings[worldScripts["Shield Cycler"]._sc_settings.sc.version];
    var sc_display_manual = "";
    var sc_display_functional = worldScripts["Shield Cycler"]._sc_settings.sc.functional ;
    if ( worldScripts["Shield Cycler"]._sc_settings.sc.manual_version != worldScripts["Shield Cycler"]._sc_const.none )
      { var sc_display_manual = _sc_display_strings[worldScripts["Shield Cycler"]._sc_settings.sc.manual_version]; };
    mission.setInstructions("Shield Cycler: " + sc_display_cycler +" ,Manual Configurator: " + sc_display_manual + " , " + sc_display_functional + " %% functional");
  };
<snip>
The code works, but in the savefile i found this :

Code: Select all

	<key>SC worldscript events</key>
	<string>Shield Cycler: standard ,Manual Configurator: standard , 100 % functional</string>
Is this intended behaviour of mission.setInstructions , a bug in my code or a bug in oolite 1.80 ?
OS : Arch Linux 64-bit - rolling release

OXPs : My user page

I am subscribed to the threads for my oxps, if you need my attention just post in them or send a pm.

User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4018
Joined: Fri Nov 11, 2011 6:19 pm

Re: mission.setinstructions creates mission variable ?

Post by cim » Thu Oct 02, 2014 3:35 pm

Intended behaviour.

The "mission variables" dictionary in the save file stores several things including the JS mission variables. JS mission variables are prefixed by "mission_" in the save file, and you can't access the instructions data through the JS missionVariables.

Post Reply