Scripting requests

An area for discussing new ideas and additions to Oolite.

Moderators: winston, another_commander

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

Re: Scripting requests

Post 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.
User avatar
Cmd. Cheyd
---- E L I T E ----
---- E L I T E ----
Posts: 934
Joined: Tue Dec 16, 2008 2:52 pm
Location: Deep Horizon Industries Manufacturing & Research Site somewhere in G8...

Re: Scripting requests

Post by Cmd. Cheyd »

Just trying to help spara's OXP idea out. Had to ask.
Walbrigg
Competent
Competent
Posts: 37
Joined: Sun Dec 30, 2012 1:58 pm
Location: Beds, England

Re: Scripting requests

Post 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
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Re: Scripting requests

Post by Svengali »

If you need more control, why don't you use cims [EliteWiki] New Cargos? It comes with a nice API.
Walbrigg
Competent
Competent
Posts: 37
Joined: Sun Dec 30, 2012 1:58 pm
Location: Beds, England

Re: Scripting requests

Post by Walbrigg »

I'm concerned more with the passengers & parcels contracts, and the process of completing them, than with special cargo types.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2453
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia
Contact:

Re: Scripting requests

Post 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.
User avatar
Rorschachhamster
---- E L I T E ----
---- E L I T E ----
Posts: 274
Joined: Sun Aug 05, 2012 11:46 pm
Contact:

Re: Scripting requests

Post 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!
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripting requests

Post 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)
User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6312
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

Re: Scripting requests

Post 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.
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied
Walbrigg
Competent
Competent
Posts: 37
Joined: Sun Dec 30, 2012 1:58 pm
Location: Beds, England

Re: Scripting requests

Post 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.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Scripting requests

Post 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".
Last edited by Thargoid on Sun Feb 03, 2013 2:58 pm, edited 1 time in total.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: Scripting requests

Post 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:
Walbrigg
Competent
Competent
Posts: 37
Joined: Sun Dec 30, 2012 1:58 pm
Location: Beds, England

Re: Scripting requests

Post 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.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Scripting requests

Post 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.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Re: Scripting requests

Post by another_commander »

Walbrigg's patch has been submitted as an update to the existing Berios request #5480 for consideration post-1.78.
Post Reply