Scripting requests

An area for discussing new ideas and additions to Oolite.

Moderators: winston, another_commander

another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6682
Joined: Wed Feb 28, 2007 7:54 am

Re: Scripting requests

Post by another_commander »

Zireael wrote:
2) Guuys, there's 4 more function keys after F8, they could be used for something useful in the future.
Ehm, actually 3. F12 on the Win/Linux builds (not sure about Mac) toggles full screen on/off.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Scripting requests

Post by Commander McLane »

Zireael wrote:
2) Have a key for console message log just like there's ~ for comms log.
Console messages are not logged. That's what distinguishes them from comms messages. If you want a message to be logged, use a comms message.
Zireael
---- E L I T E ----
---- E L I T E ----
Posts: 1396
Joined: Tue Nov 09, 2010 1:44 pm

Re: Scripting requests

Post by Zireael »

One more thing I just remembered:
I thought I saw it mentioned somewhere in the vast Progress thread that 1-8 keys have been decoupled from F1-F8. I thought that we could bind 1-8 instead to the primable equipment in order of the player acquiring them. Equipment granted automatically (such as Chupa missile ID) would be on 1, Dock Assist I bought first would be on 2 and Telescope would be at 3. I could have up to 8 such pieces of equipment and I wouldn't have to worry about cycling through them...
This would save players a lot of hassle with Shift+N cycling.
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 »

1.79 has two fast activation keys for primable equipment, plus you can have a third item on 'n' as usual. Do many people really have that much equipment on board their ships that they need instant access to four or more primable items?

Another thing that might be useful if you do have that much - you can customise your HUD to include a "drawPrimedEquipment:" dial with "n_bars" > 1

The other thing is that not every keyboard gives particularly easy access to the Fn keys, so we'd prefer to keep the default bindings for 1-8 as they are.
Zireael
---- E L I T E ----
---- E L I T E ----
Posts: 1396
Joined: Tue Nov 09, 2010 1:44 pm

Re: Scripting requests

Post by Zireael »

another_commander wrote:
Zireael wrote:
2) Guuys, there's 4 more function keys after F8, they could be used for something useful in the future.
Ehm, actually 3. F12 on the Win/Linux builds (not sure about Mac) toggles full screen on/off.
*slaps forehead* Right.

And expanding on the idea of using F9-F11, I just thought we could slap some sort of in-game Ooniverse info under F10, coded similar to the F4 menu, and just kept separately to avoid undue clutter in F4. Thoughts.
User avatar
Pleb
---- E L I T E ----
---- E L I T E ----
Posts: 908
Joined: Sun Apr 29, 2012 2:23 pm
Location: United Kingdom

Re: Scripting requests

Post by Pleb »

I'm sure this is possible but I can't find any mention of it anywhere. Is there a way of making a carrier/station refuse docking clearance by script? For example, make a station/carrier refuse docking clearance to player unless a specific variable was enabled?
Desktop PC: CPU: Intel i7-4790K Quad Core 4.4GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1080Ti RAM: 32GB DDR3

Laptop PC: CPU: Intel i5-10300H Quad Core 4.5GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1650 RAM: 32GB DDR4
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 »

The [url=http://wiki.alioth.net/index.php/Oolite_JavaScript_Reference:_ship_script_event_handlers#Docks_Only]acceptDockingRequestFrom[/url] event is probably what you're looking for, if you want to refuse docking clearance to some ships but not others.

If you just want to enable and disable the dock, the various dock properties are probably sufficient. Note that if you really want to keep the player out - not just fine them for docking without clearance - disallowedDockingCollides is needed.
User avatar
Pleb
---- E L I T E ----
---- E L I T E ----
Posts: 908
Joined: Sun Apr 29, 2012 2:23 pm
Location: United Kingdom

Re: Scripting requests

Post by Pleb »

I can't seem to get the acceptDockingRequestFrom function to work. I have the following:

Code: Select all

this.acceptDockingRequestFrom = function(ship)
{
	if (ship.scanClass == "CLASS_PLAYER")
	{
		return false;
	}
}
But doesn't seem to make a difference... :(
Desktop PC: CPU: Intel i7-4790K Quad Core 4.4GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1080Ti RAM: 32GB DDR3

Laptop PC: CPU: Intel i5-10300H Quad Core 4.5GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1650 RAM: 32GB DDR4
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 »

Pleb wrote:
I can't seem to get the acceptDockingRequestFrom function to work. I have the following:

Code: Select all

this.acceptDockingRequestFrom = function(ship)
{
	if (ship.scanClass == "CLASS_PLAYER")
	{
		return false;
	}
}
But doesn't seem to make a difference... :(
You probably want to return true if the ship is not the player, and ship.isPlayer is a more reliable test. Still, that should be denying docking to the player - unless you've placed it in the wrong script: it needs to be in the dock's ship script, not the station's (because you might have multiple docks with different rules)
User avatar
Pleb
---- E L I T E ----
---- E L I T E ----
Posts: 908
Joined: Sun Apr 29, 2012 2:23 pm
Location: United Kingdom

Re: Scripting requests

Post by Pleb »

Still isn't working, this is the whole script:

Code: Select all

"use strict";

this.name 			= "himsn_carrier_dock.js";
this.author         = "Pleb";
this.copyright      = "(C) 2014 Pleb.";
this.licence        = "CC-NC-by-SA 2.0";
this.version 		= "0.6";

this.shipSpawned = function ()
{
	this.ship.allowsDocking = true;
}

this.acceptDockingRequestFrom = function(ship)
{
	if (ship.isPlayer)
	{
		return false;
	}
	else
	{
		return true;
	}
}
Desktop PC: CPU: Intel i7-4790K Quad Core 4.4GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1080Ti RAM: 32GB DDR3

Laptop PC: CPU: Intel i5-10300H Quad Core 4.5GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1650 RAM: 32GB DDR4
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 »

Should be fixed in commit e57bac0

It should also work now if you use the docking computer.

Thanks for the report
User avatar
Pleb
---- E L I T E ----
---- E L I T E ----
Posts: 908
Joined: Sun Apr 29, 2012 2:23 pm
Location: United Kingdom

Re: Scripting requests

Post by Pleb »

Yay! This works now, thanks cim! :mrgreen:
Desktop PC: CPU: Intel i7-4790K Quad Core 4.4GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1080Ti RAM: 32GB DDR3

Laptop PC: CPU: Intel i5-10300H Quad Core 4.5GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1650 RAM: 32GB DDR4
User avatar
Pleb
---- E L I T E ----
---- E L I T E ----
Posts: 908
Joined: Sun Apr 29, 2012 2:23 pm
Location: United Kingdom

Re: Scripting requests

Post by Pleb »

Just another quick one regarding docks, if the disallowedDockingCollides is read-only, as specified on the wiki, how would I set this to true to ensure that it is impossible to dock?
Desktop PC: CPU: Intel i7-4790K Quad Core 4.4GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1080Ti RAM: 32GB DDR3

Laptop PC: CPU: Intel i5-10300H Quad Core 4.5GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1650 RAM: 32GB DDR4
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 »

Documentation fixed. (It's been read/write all along...)

Thanks for testing out all these new features.
User avatar
Pleb
---- E L I T E ----
---- E L I T E ----
Posts: 908
Joined: Sun Apr 29, 2012 2:23 pm
Location: United Kingdom

Re: Scripting requests

Post by Pleb »

I'm not sure whether it's me missing something or this particular function not working the way it's supposed to (but I'm guessing it's probably the first one), but I'm still able to dock. I can disallow docking clearance but I can still dock:

Code: Select all

"use strict";

this.name 			= "himsn_station_dock.js";
this.author         = "Pleb";
this.copyright      = "(C) 2014 Pleb.";
this.licence        = "CC-NC-by-SA 2.0";
this.version 		= "0.7";

this.shipSpawned = function ()
{
	this.ship.allowsDocking = false;
	this.ship.disallowedDockingCollides = true;
}

this.acceptDockingRequestFrom = function(ship)
{
	return false;
}
This is a more simplified version of the actual script but even this will not work... :(

And thank you for all the new features, I wouldn't be able to implement Gimi's ideas for the HIMSN OXZ without them! :D
Desktop PC: CPU: Intel i7-4790K Quad Core 4.4GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1080Ti RAM: 32GB DDR3

Laptop PC: CPU: Intel i5-10300H Quad Core 4.5GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1650 RAM: 32GB DDR4
Post Reply