Page 49 of 56

Re: Scripting requests

Posted: Sat Jan 19, 2013 9:53 am
by cim
Cmd. Cheyd wrote:
Would it be possible to make galaxy and system writable from JS (i.e. - change the current system) during startup?
No. startUp() handlers in other OXPs may be expecting the galaxy and system they see to be the one the player launches in to.

Re: Scripting requests

Posted: Sat Jan 19, 2013 9:58 pm
by Cmd. Cheyd
Just trying to help spara's OXP idea out. Had to ask.

Re: Scripting requests

Posted: Wed Jan 23, 2013 7:17 am
by Walbrigg
It would be nice to be able to interact more with the contracts system from OXPs

Currently the code that works out the payment for completing a delivery of passengers or parcels runs after docking and before shipDockedWithStation() is called, and isn't even visible to scripts, or modifiable.

The ideal would be something like:
  • on docking in main station, contracts to deliver to that system are marked as "completed", the payment and a message are worked out, and they are attached to the contract
    shipDockedWithStation() is called. The contracts are more read-write than they are at the moment
    Any completed contracts are displayed in messages on the screen and the payments actually made
That way, a script can modify the payment or message from any completed delivery, to add colour, or to integrate with a mission. Also, you could have contracts to deliver to other stations, by clearing the completed flag if in the main station, or setting it if in the actual station

(Also, my forthcoming "ship's accountant OXP" would be able to see exactly what payment was made for each contract)

I can do some work on this if it's seen as a workable idea

Re: Scripting requests

Posted: Wed Jan 23, 2013 12:05 pm
by Svengali
If you need more control, why don't you use cims [EliteWiki] New Cargos? It comes with a nice API.

Re: Scripting requests

Posted: Wed Jan 23, 2013 12:31 pm
by Walbrigg
I'm concerned more with the passengers & parcels contracts, and the process of completing them, than with special cargo types.

Re: Scripting requests

Posted: Thu Jan 24, 2013 5:17 pm
by Wildeblood
Is the illegal goods list visible to scripts yet? If not, could you add legality as a property to the station.market objects? Please?

station.market[commodity].legality

And a setMarketLegality() or setLegality() function would be nice, too.

Re: Scripting requests

Posted: Thu Jan 24, 2013 9:33 pm
by Rorschachhamster
Wildeblood wrote:
Is the illegal goods list visible to scripts yet? If not, could you add legality as a property to the station.market objects? Please?

station.market[commodity].legality

And a setMarketLegality() or setLegality() function would be nice, too.
Drug dealers, arms traders, slave catchers, all with their own stations? :D Or even quasi-legality (with GalCoop looking in the other direction) in some of the "less reputable" systems main stations? Seconded!

Re: Scripting requests

Posted: Thu Jan 24, 2013 9:37 pm
by cim
I've noted it on the list for post-1.78 development. In the meantime the workaround is to zero out illegal-goods.plist, and then manage it all manually, which isn't too difficult. (See New Cargoes for an example)

Re: Scripting requests

Posted: Fri Jan 25, 2013 12:56 am
by Diziet Sma
<takes another bite of DarkSide cookie and tosses hat in the ring>

For an OXP idea I have, I'd like to request the ability to engage/disengage the players injectors under script control, please.

Re: Scripting requests

Posted: Sun Feb 03, 2013 2:26 pm
by Walbrigg
Most of the built-in screens in a station have text lined up in columns. It's not possible to do that in an OXP (unless I'm missing something). Some of them get there nearly by padding with spaces, but that's extra complicated, and doesn't line up neatly.

It wouldn't be very hard to support columns in a mission screen. As a proof of concept, I've tried the following:

Code: Select all

Index: src/Core/Entities/PlayerEntityLegacyScriptEngine.m
===================================================================
--- src/Core/Entities/PlayerEntityLegacyScriptEngine.m	(revision 5630)
+++ src/Core/Entities/PlayerEntityLegacyScriptEngine.m	(working copy)
@@ -2415,6 +2415,18 @@
 		// must set special second as setting the descriptor resets it
 		BOOL overridden = ([self missionBackgroundDescriptor] != nil);
 		[gui setBackgroundTextureSpecial:[self missionBackgroundSpecial] withBackground:!overridden];
+
+		OOGUITabSettings tab_stops;
+		tab_stops[0] = 0;
+		tab_stops[1] = 64;
+		tab_stops[2] = 128;
+		tab_stops[3] = 192;
+		tab_stops[4] = 256;
+		tab_stops[5] = 320;
+		tab_stops[6] = 384;
+		tab_stops[7] = 448;
+
+		[gui setTabStops:tab_stops];
 		
 		[gui setShowTextCursor:NO];
 	}
Index: src/Core/GuiDisplayGen.m
===================================================================
--- src/Core/GuiDisplayGen.m	(revision 5630)
+++ src/Core/GuiDisplayGen.m	(working copy)
@@ -592,10 +592,18 @@
 
 - (void) setText:(NSString *)str forRow:(OOGUIRow)row align:(OOGUIAlignment)alignment
 {
 	if (str != nil && RowInRange(row, rowRange))
 	{
-		[rowText replaceObjectAtIndex:row withObject:str];
-		rowAlignment[row] = alignment;
+	  if ([str rangeOfString:@"\t"].location != NSNotFound)
+	    {
+	      NSArray *fields = [str componentsSeparatedByString:@"\t"];
+	      [rowText replaceObjectAtIndex:row withObject:fields];
+	    } 
+	  else 
+	    {
+	      [rowText replaceObjectAtIndex:row withObject:str];
+	      rowAlignment[row] = alignment;
+	    }
 	}
 }
 
That's not quite good enough, but it shows that it's not too hard. Other things that would need fixing:
  • Script to be able to set tab stops, rather than hard-coding them
    Script to be able to set alignment per column or per field. That's the tricky bit, I think
    The mission summary text on the manifest screen is messed up by this change: it expects different tab stops.
If we had those done, it would be a great advantage.

For the alignment, I'm thinking of having an "expanding space" character. Putting one before text would push it to the right of the column it's in, putting it after would push it left. Both would centre it. I can see how the rendering logic would work.

As it stands, if text overflows a column, it gets overwritten. I think that's probably OK; if you need to clip the text to a column width that's up to the script.

Re: Scripting requests

Posted: Sun Feb 03, 2013 2:43 pm
by Thargoid
1.77 introduced a new micro-space character specifically for this kind of lining up. I've used it in a few of my 1.77-only OXPs (like the current version of Vortex for example) and there's also new functions in Cabal Commons Library to do the same more generically.

Have a look at those, as I think they will fulfil what you want, or at least give you the tools to write specific functions to do that.

Editted to add - the two useful facts are the defaultFont function (which pre-existed but is now more useful) and the pad microspace character code is "\037".

Re: Scripting requests

Posted: Sun Feb 03, 2013 2:52 pm
by Eric Walch
Nice one Walbrigg, having real tabs makes things of cause easier for most of us than constantly calculate line lengths and fill it up with micro spaces. :lol:

Re: Scripting requests

Posted: Sun Feb 03, 2013 3:00 pm
by Walbrigg
That solves the not-quite-lining-up problem, but it still seems wrong that scripts are iteratively inserting spaces to get a column in the right place, when all the code to directly write at a preset column position is already there in the GuiDisplayGen class.

Re: Scripting requests

Posted: Sun Feb 03, 2013 3:07 pm
by Thargoid
Indeed - consider it a stop-gap until your code can be considered by those who do for 1.78 perhaps :). It is a bit of a faff initially, hence why I wrote the functions used in my OXPs which I then also gave to Svengali for CCL for the very reasons you mention.

Re: Scripting requests

Posted: Sun Feb 03, 2013 4:01 pm
by another_commander
Walbrigg's patch has been submitted as an update to the existing Berios request #5480 for consideration post-1.78.