Oolite Bulletins

For information and discussion about Oolite.
It is currently Wed Dec 13, 2017 1:03 pm

All times are UTC




Post new topic  Reply to topic  [ 1405 posts ]  Go to page Previous 190 91 92 93 94
Author Message
 Post subject: Re: Scripters cove
PostPosted: Sun Nov 05, 2017 11:58 pm 
Offline
Commodore
Commodore
User avatar

Joined: Tue Jan 21, 2014 10:37 pm
Posts: 1837
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...
Part of the problem may lie in the function stacking your doing in this line:
Code:
this.startUpComplete = this.equipmentAdded = this.playerBoughtNewShip = function()
This code will run whenever you start up from a save game (as you've noted), and theoretically would run every time any equipment is added, or whenever the player buys a new ship.

I think it would be better to do something like this:
Code:
this.startUpComplete = function()
{	
	this.$adjustSpeed();
}

this.equipmentAdded = function(equipmentKey) 
{
	log(this.name, "adding equipment " + equipmentKey);
	if (equipmentKey == "EQ_TRANSIT_DEFAULT" || equipmentKey == "EQ_TRANSIT_GRADE" || equipmentKey == "EQ_PERFORMANCE_DEFAULT" || equipmentKey == "EQ_PERFORMANCE_GRADE")
		this.$adjustSpeed();
}

this.playerBoughtNewShip = function(ship, price) 
{
	log(this.name, "new ship " + ship);
	this.$adjustSpeed();
}

this.$adjustSpeed = function() 
{
	var p = player.ship;
	var td = p.equipmentStatus("EQ_TRANSIT_DEFAULT");
	var tg = p.equipmentStatus("EQ_TRANSIT_GRADE");
	var pd = p.equipmentStatus("EQ_PERFORMANCE_DEFAULT");
	var pg = p.equipmentStatus("EQ_PERFORMANCE_GRADE");

	log(this.name, "transit def " + td + ", gde " + tg);
	log(this.name, "perform def " + pd + ", gde " + pg);
	log(this.name, "maxspeed pre  = " + p.maxSpeed);
	if(tg == "EQUIPMENT_OK" && td != "EQUIPMENT_OK" && pd != "EQUIPMENT_OK") {p.maxSpeed -= 50;}
	if(pg == "EQUIPMENT_OK" && pd != "EQUIPMENT_OK" && td != "EQUIPMENT_OK") {p.maxSpeed += 50;}
	if(tg == "EQUIPMENT_OK" && pd == "EQUIPMENT_OK") {p.maxSpeed -= 100;}
	if(pg == "EQUIPMENT_OK" && td == "EQUIPMENT_OK") {p.maxSpeed += 100;}
	log(this.name, "maxspeed post = " + p.maxSpeed);
}
This way you can see which of the events is not firing, plus the equipmentAdded function won't keep adjusting your speed when non-related equipment items are added.

_________________
My OXP's


Top
   
 Post subject: Re: Scripters cove
PostPosted: Mon Nov 06, 2017 1:49 am 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Thu Jun 20, 2013 10:22 pm
Posts: 1113
Thanks so much phkb! :D

I knew about the 'any' equipment issue (planning to add conditions later), so that was to come.
I didn't know that 'this.' statements could be nested however, so that opens up some new possibilities :-)

I'll try out the script and report back.

_________________
"With our thoughts, we make the world" :-)


Top
   
 Post subject: Re: Scripters cove
PostPosted: Tue Nov 07, 2017 1:02 am 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Thu Jun 20, 2013 10:22 pm
Posts: 1113
Tried the above script. Same problem, namely this.equipmentAdded isn't firing (no log entries and no speed change using numeric hud).

The equipment is definitely being added (listed on the in game equipment list).
The way it is added may be unsual however...
Player buys transit re-fit which in turn grants (amongst other things) transit grade via script (working).

The fact that desired behaviour occurs from this.startUpComplete but not from this.equipmentAdded (with any of the three scripts so far) is curious.

I've tried swapping 'grades' for 're-fits' but to no avail.
I'll try this.playerBoughtEquipment else I might have to go down the replaceShip route...

_________________
"With our thoughts, we make the world" :-)


Top
   
 Post subject: Re: Scripters cove
PostPosted: Tue Nov 07, 2017 1:07 am 
Offline
Commodore
Commodore
User avatar

Joined: Tue Jan 21, 2014 10:37 pm
Posts: 1837
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...
Can you send me the entire script file?

_________________
My OXP's


Top
   
 Post subject: Re: Scripters cove
PostPosted: Tue Nov 07, 2017 1:30 am 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Thu Jun 20, 2013 10:22 pm
Posts: 1113
I could but I think I've just solved it...

There were two seperate checks for equipment added which were somehow interfering (I wasn't aware that one might prevent another). I've just tried combining them and suddenly there are log entries...

It's currently applying the adjustment twice but I think I might know why that is:
this.equipmentAdded = this.playerBoughtEquipment = function(equipment)
As refits are both purchased and added then that's potentially two triggers.

this.playerBoughtEquipment should be unnecessary in the presence of this.equipmentAdded

Thanks for all your help phkb :)
...and apologies for the wild goose chase :oops:

_________________
"With our thoughts, we make the world" :-)


Top
   
 Post subject: Re: Scripters cove
PostPosted: Tue Nov 07, 2017 3:04 am 
Offline
Competent
Competent

Joined: Mon May 30, 2016 3:54 am
Posts: 41
Some noob questions of mine:

If I use scan class="CLASS_BUOY" is the player rewarded a kill and a bounty if defined ? From my first observation it seems not to be the case.

In which OXP I could find the tanker anaconda ? Once in a while it shows up on my scanner but I really dont remember anymore where this ship belong to.

_________________
Trying to survive behind the controls of a Caduceus Psi XT in Alpha test :lol:


Top
   
 Post subject: Re: Scripters cove
PostPosted: Tue Nov 07, 2017 10:10 am 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Mon May 20, 2013 9:53 pm
Posts: 2434
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Quote:
If I use scan class="CLASS_BUOY" is the player rewarded a kill and a bounty if defined ? From my first observation it seems not to be the case.
If you tested then it is true. Sounds logical.
Quote:
In which OXP I could find the tanker anaconda ?
I think this:
Code:
wildShips_anaconda = {
                like_ship = "anaconda";
                name = "Anaconda Tanker";
                roles = "wildShips_tanker wildShips_anaconda";
};

_________________
OXPs by Norby


Top
   
 Post subject: Re: Scripters cove
PostPosted: Tue Nov 07, 2017 10:35 am 
Offline
Competent
Competent

Joined: Mon May 30, 2016 3:54 am
Posts: 41
Quote:
Quote:
Quote:
If I use scan class="CLASS_BUOY" is the player rewarded a kill and a bounty if defined ? From my first observation it seems not to be the case.
If you tested then it is true. Sounds logical.
Actually I first faced the problem while adapting the Star Destroyer, the escorts are defined as buoy and therefore no kills or bounties are rewarded even if they are fugitives. Even "counts_as_kill" = yes; doesn't change that. After massLockedBehaviour = "OO_MASSLOCKED_NEVER"; is working this shouldn't be a problem anymore.
Quote:
Quote:
In which OXP I could find the tanker anaconda ?
I think this:
Code:
wildShips_anaconda = {
                like_ship = "anaconda";
                name = "Anaconda Tanker";
                roles = "wildShips_tanker wildShips_anaconda";
};
WildShips it is, thank you a lot

_________________
Trying to survive behind the controls of a Caduceus Psi XT in Alpha test :lol:


Top
   
 Post subject: Re: Scripters cove
PostPosted: Fri Dec 01, 2017 9:36 am 
Offline
Competent
Competent

Joined: Mon May 30, 2016 3:54 am
Posts: 41
Is there any way that I can assign specific pilots to all escape pods of a ship ? Its easy to have 8 pods with different designs but Oolite seems to accept only 1 assigned pilot and fills the remaining ones with random characters.

Update: Never mind, I found a solution already, not perfect but close enough.

_________________
Trying to survive behind the controls of a Caduceus Psi XT in Alpha test :lol:


Top
   
 Post subject: Re: Scripters cove
PostPosted: Mon Dec 04, 2017 2:05 am 
Offline
Competent
Competent

Joined: Mon May 30, 2016 3:54 am
Posts: 41
A simple way to assign multiple characters to a ship:

create your character(s) in the characters.plist

in the shipdata.plist using "like_ship" create for every character an escape pod.

with "pilot =" you can assign each character to his pod, don't forget to set "unpiloted" = no;

include to your ship like following lines:

"death_actions" =
(
"spawn: my-escape-capsule_01 1",
"spawn: my_escape-capsule_02 2"
);


Voila, multiple pods with custom made characters. For sure not the most elegant method but east to implement.

_________________
Trying to survive behind the controls of a Caduceus Psi XT in Alpha test :lol:


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 1405 posts ]  Go to page Previous 190 91 92 93 94

All times are UTC


Who is online

Users browsing this forum: No registered users and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Limited