Hello, thank you and a few questions...

General discussion for players of Oolite.

Moderators: winston, another_commander

User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2687
Joined: Thu Jun 20, 2013 10:22 pm
Location: On the moon Thought, orbiting the planet Ignorance.

Hello, thank you and a few questions...

Post by Redspear »

Hello all :) ,

I'm a veteran of Spectrum Elite back in the 80's but only ever made it to Dangerous.
Did the nova mission back then (big surprise jumping to a 'coloured' system).
Thought the game was an amazing experience: beyond what I'd previously thought possible on the ol' speccy.

So, many years later I find Oolite! Wow :shock: ... Thank you all. Whether you're a developer or your contribution is strictly 'feedback only', I've certainly had some fun with the fruits of your work. If you've contributed even a few oxps then chances are I've downloaded one of them and got something from it.

Just as Elite showed me what was possible on a simple home computer, Oolite has shown me what's possible with an active and supportive online community.
So if I may, (ahem :oops: ) "Right On Commanders!" :D


OK, now for some questions...
I'd like to tweak my game to make systems vary according to their inhabitants.
More specifically:

1. Different docking stations (e.g. Neolite stations for planets inhabited by birds)
2. Different shipyards (e.g. Ghavials only available on 'lizard worlds')
3. Different market prices (e.g. perhaps less demand for furs on feline planets but maybe more for luxuries)
4. Perhaps some other 'placements' (e.g. Wasp-nest station in insect worlds only)

Whilst I appreciate that there may be reasons not to do any one of these things, I think they would each add something to my 'Ooniverse'.

I thought that a 'condition script' would be the way to do this but it seems that 'Inhabitants' cannot be set as a condition in the way that 'Government' or 'Tech Level' can. I also looked at Hoopy Casinos to see if it could be done in similar manner i.e. picking a key word or phrase from a larger piece of text (e.g. 'lizards' from 'large bug-eyed cheese-eating lizards') but no luck as yet.

Is this sort of thing currently possible?
What level of 'coding skill' is it likely to require? (my current level is 'minimal')
Would anyone else like to see these sorts of things in game?
Is this post too long? :P

As I understand it, each system has a reference number, so I could perhaps use a conditon in the sense of 'any one of these systems', although I'm not sure how to approach that yet...

I may well have missed something simple but my time is limited these days (and my ability level probably even more so...)
I wouldn't want to spend hours working on something that is currently impractical.

Any help / advice would be appreciated.

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

Re: Hello, thank you and a few questions...

Post by another_commander »

Hi and welcome.

It is indeed possible to scan the text of planet descriptions for keywords and act on them based on content, provided that localization is not an issue. Here is an example of searching for the keyword "insect" in planet descriptions using Javascript and regular expressions and using it for doing something (in this particular case, showing an image of an insect on the F7 screen):

Code: Select all

this.guiScreenChanged = function(toGUI)
{
	if (toGUI == 'GUI_SCREEN_SYSTEM_DATA')
	{
		var pat = /insect/i;
		if (System.infoForSystem(galaxyNumber, player.ship.targetSystem).inhabitants.match(pat))
		{
			setScreenOverlay("insectInhabitant.png");
		}
	}
}
Hope this helps. Glad you are enjoying the game and should you need more clarifications, don't hesitate to ask.
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Re: Hello, thank you and a few questions...

Post by Cody »

Welcome aboard, Redspear. Interesting ideas - I hope you can cobble something together.
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Hello, thank you and a few questions...

Post by cim »

Redspear wrote:
I thought that a 'condition script' would be the way to do this but it seems that 'Inhabitants' cannot be set as a condition in the way that 'Government' or 'Tech Level' can. I also looked at Hoopy Casinos to see if it could be done in similar manner i.e. picking a key word or phrase from a larger piece of text (e.g. 'lizards' from 'large bug-eyed cheese-eating lizards') but no luck as yet.
A condition script can do this. But it has to be one of the new Javascript-based condition scripts from 1.77; as you've found, the legacy condition scripts can't check inhabitants.

So you could add to the Ghavial entry in shipyard.plist the line

Code: Select all

"condition_script" = "ghavial_conditions.js";
and then add a file called ghavial_conditions.js to the Scripts folder of the OXP

Code: Select all

this.allowOfferShip = function(shipKey) {
    if (shipKey == "ghavial-player") {
        var pat = /lizard/i;
        if (system.inhabitants.match(pat)) {
             return true; // Lizard world, Ghavials allowed
        } else {
             return false; // Not lizard world, Ghavials not allowed
        }
    }
    return true; // Not a Ghavial, so allow it anywhere
}
For NPC ships or stations, the condition_script reference goes in shipdata.plist instead, and you use the allowSpawnShip test.
Jenko
Above Average
Above Average
Posts: 24
Joined: Thu Jun 13, 2013 1:18 pm
Location: Aboard the 'Dream of Wild Horses'

Re: Hello, thank you and a few questions...

Post by Jenko »

G'day all,
I'd like to firmly second these remarks of Redspear's:

"Thank you all. Whether you're a developer or your contribution is strictly 'feedback only', I've certainly had some fun with the fruits of your work. If you've contributed even a few oxps then chances are I've downloaded one of them and got something from it.

Just as Elite showed me what was possible on a simple home computer, Oolite has shown me what's possible with an active and supportive online community.
So if I may, (ahem :oops: ) "Right On Commanders!" :D"


In the last two weeks since discovering Oolite - I've had a lot of fun - & don't tell me to get a life (as if anyone here would). I've already had a long & good'un.
Cheers
Jenko
User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2687
Joined: Thu Jun 20, 2013 10:22 pm
Location: On the moon Thought, orbiting the planet Ignorance.

Re: Hello, thank you and a few questions...

Post by Redspear »

Thanks for the warm welcome! :D

Really appreciate you taking the time to give me some coding examples. That's both improved my understanding and saved me a lot of time and experimentation. Great stuff! :D

another_commander : It does help, thanks. I'm likely to need my fair share of clarifications, so that's good to know :)
Cody : Thanks for your interest. Yes, 'cobble' sounds about right for my programming 'skills' :lol:
cim : Ahh, so I need to upgrade my thinking to 1.77... Nicely explained :) .
Jenko : Nice to know that the sentiment is shared :D . Glad you're enjoying the game.

Thanks everyone!

Looks like I've got some tweaking to do :wink:
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: Hello, thank you and a few questions...

Post by Diziet Sma »

And yet another victim one slips closer to the Dark Side™™.. :twisted:

Welcome aboard, Redspear! 8)
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
User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2687
Joined: Thu Jun 20, 2013 10:22 pm
Location: On the moon Thought, orbiting the planet Ignorance.

Re: Hello, thank you and a few questions...

Post by Redspear »

Diziet Sma wrote:
And yet another victim one slips closer to the Dark Side™™.. :twisted:

Welcome aboard, Redspear! 8)
Thanks Diziet Sma!
I hear it's a slippery slope :wink:
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: Hello, thank you and a few questions...

Post by Diziet Sma »

It is indeed.. very few can resist its' siren song, once heard..

Cody is one of the rare few who manages to resist.. but even he still hears it calling to him, in the dark of the night.
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
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Re: Hello, thank you and a few questions...

Post by Cody »

Diziet Sma wrote:
It is indeed.. very few can resist its' siren song, once heard..
'I was drawn by the Sirens of Titan
Carried along by their call
Seeking for a way to enlighten
Searching for the sense of it all!'

Diziet Sma wrote:
Cody is one of the rare few who manages to resist.. but even he still hears it calling to him, in the dark of the night.
Some nights, I awake suddenly, drenched in cold sweat. Visions of plists and AIs haunt me... and cookies!
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Hello, thank you and a few questions...

Post by Smivs »

The cookies make it worth it :D
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Fatleaf
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 1988
Joined: Tue Jun 08, 2010 5:11 am
Location: In analysis mode on Phaelon
Contact:

Re: Hello, thank you and a few questions...

Post by Fatleaf »

Who mentioned Cookies :shock:

Where? :D
Find out about the early influences of Fatleaf here. Also his OXP's!
Holds the Ooniversal record for "Thread Necromancy"
User avatar
Tricky
---- E L I T E ----
---- E L I T E ----
Posts: 821
Joined: Sun May 13, 2012 11:12 pm
Location: Bradford, UK. (Anarchic)

Re: Hello, thank you and a few questions...

Post by Tricky »

Mmm... Cookies!

Cookie dispener OXP anyone? 8)
User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2687
Joined: Thu Jun 20, 2013 10:22 pm
Location: On the moon Thought, orbiting the planet Ignorance.

Re: Hello, thank you and a few questions...

Post by Redspear »

Having trouble getting this to work using the allowSpawnShip method for stations...
cim wrote:
So you could add to the Ghavial entry in shipyard.plist the line

Code: Select all

"condition_script" = "ghavial_conditions.js";
and then add a file called ghavial_conditions.js to the Scripts folder of the OXP

Code: Select all

this.allowOfferShip = function(shipKey) {
    if (shipKey == "ghavial-player") {
        var pat = /lizard/i;
        if (system.inhabitants.match(pat)) {
             return true; // Lizard world, Ghavials allowed
        } else {
             return false; // Not lizard world, Ghavials not allowed
        }
    }
    return true; // Not a Ghavial, so allow it anywhere
}
For NPC ships or stations, the condition_script reference goes in shipdata.plist instead, and you use the allowSpawnShip test.
I've created the file example above, swapped allowOfferShip for allowSpawnShip, changed Ghavial-player for the relevant station name and I've even remembered to add the condition script line to the relevant shipdata.plist.

Here's part of the log report:
[script.javaScript.exception.unexpectedType]: ***** JavaScript exception (zocto_conditions.js.anon-script): TypeError: system.inhabitants is undefined
13:44:58.300 [script.javaScript.exception.unexpectedType]: ../AddOns/Stations.oxp/Z_GrOovy_System_Stations.oxp/Scripts/zocto_conditions.js, line 4.
Some things that may be relevant :?: :

You may have noticed that I group oxps in folders to make it easier for me to manage them; such as all of my station oxps within the imaginatively titled, 'Stations.oxp".

I was having all sorts of problems making sense of the log reports until I realised that I was editing them using Notepad :roll:
I've since 'fixed' (or have I :?: ) them by simply opening the affected files with wordpad and then saving them.

Any ideas what I might be doing wrong?
I've mucked about with plists aplenty before but scripting is still new to me.
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Re: Hello, thank you and a few questions...

Post by Cody »

Do get Notepad++ - it's free and excellent. Grouping OXPs should be no problem - I've done similar for ages.
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
Post Reply