Page 78 of 118
Re: Scripters cove
Posted: Sun Apr 05, 2015 7:43 am
by Wildeblood
phkb wrote:It's actually a pretty simple mistake, and one I often make:
should read as
system.government == 7
. In Javascript, the "=" sign on its own is used for assigning values (ie.
var x = 1;
) In an "If" statement, you need to use "==" or "===". Either should do the trick.
Yep, that.
And if your choice is notepad, wordpad or word, use wordpad. Make sure it's saving as txt, not rtf.
Re: Scripters cove
Posted: Sun Apr 05, 2015 4:06 pm
by Layne
Ahh, that seems to be working now, thank you. I've been using wordpad all along (except once when I tried MS Word just to see if that made a difference) because I'd already read on several threads not to ever use notepad because it ruins the formatting. I also think I've gotten the constore issue working with a few older bits of scripting. Kinda a Frankenmod, but it's working mostly how I want it to...
Re: Scripters cove
Posted: Sun Apr 05, 2015 4:12 pm
by Cody
Notepad++ is very good, btw.
Re: Scripters cove
Posted: Tue Apr 14, 2015 7:33 am
by phkb
What is the best way to determine that a ship is docking at a station? Do a check on whether dockingInstructions
exists and the station
property of the dockingInstructions
is the desired station?
Re: Scripters cove
Posted: Tue Apr 14, 2015 12:25 pm
by Wildeblood
phkb wrote:What is the best way to determine that a ship is docking at a station? Do a check on whether dockingInstructions
exists and the station
property of the dockingInstructions
is the desired station?
Don'tcha just add an
otherShipDocked
function to the station's ship script and use it to pass the data through to your worldscript(s)?
Re: Scripters cove
Posted: Tue Apr 14, 2015 4:38 pm
by cim
phkb wrote:What is the best way to determine that a ship is docking at a station? Do a check on whether dockingInstructions
exists and the station
property of the dockingInstructions
is the desired station?
That's probably most straightforward, yes.
Re: Scripters cove
Posted: Tue Apr 14, 2015 8:17 pm
by phkb
Wildeblood wrote:Don'tcha just add an
otherShipDocked
function to the station's ship script and use it to pass the data through to your worldscript(s)?
I'm doing that to determine when a ship has docked, but I also want to know when a ship is trying to dock so that you can see it on the shipping news page, but also so that I can add those ships to the shipping news page in the case where the player launches while they are trying to dock. Otherwise that ship would just disappear.
Re: Scripters cove
Posted: Thu Apr 16, 2015 5:27 pm
by Vincentz
Enters thread
"Hi!"
Looks around
"Is this where I can buy magic?"
Lifts up old tome, blows dust off cover. A big JS is imprinted on the cover
"... or any sufficiently advanced technology that is indistinguishable from it?"
----------------------------------------------------
I'd love to make this happen:
https://bb.oolite.space/viewtopic.php?f= ... 06#p235406
If my brain circuits are working somewhat properly, it would be a fairly easy script, going something like
Code: Select all
this.name = "neweconomy.js";
this.author = "YOURNAMEHERE";
this.copyright = "April 2015";
this.description = "World Script for adding new types of economies";
this.version = "1.0";
this.setUpSystem = function()
{
if(system.economy < 7)
{use indus-commodities.plist as commodities.plist}
if(system.economy < 5)
{use explo-commodities.plist as commodities.plist}
if(system.economy < 3)
{use agric-commodities.plist as commodities.plist}
else {use finan-commodities.plist as commodities.plist}
}
The above code obviously doesn't work, which is why I need someone to sprinkle some magic dust on it, so it can fly
TIA
Vincentz
Re: Scripters cove
Posted: Thu Apr 16, 2015 5:30 pm
by Smivs
I don't think it is possible to change any .plists via js.
Re: Scripters cove
Posted: Thu Apr 16, 2015 5:44 pm
by Vincentz
Smivs wrote:I don't think it is possible to change any .plists via js.
mmm. What would be the workaround?
A single commidity.plist (for 1.80) or trade-goods.plist (for 1.81) with different entries, overriding the standard, but depending on the economy levels?
Re: Scripters cove
Posted: Thu Apr 16, 2015 5:51 pm
by Smivs
This is not an area of the game I've ever tinkered with, so I'll leave trying to advise to others who know a bit more about the mechanisms.
I would certainly focus on v1.81. 1.80 won't be around for ever, and you don't want to put a lot of effort into something that could need a major overhaul quite soon.
Re: Scripters cove
Posted: Thu Apr 16, 2015 6:57 pm
by cim
For
commodities.plist
- and I would also
not recommend spending time working on this for a new OXP - you can define multiple market definition entries within the plist, and then in planetinfo.plist (or the JS equivalents) select different market definitions for different systems which coincidentally happen to match the economy numbers of those systems. The old
BlOomberg Markets OXP uses a very similar method to create rare temporary rises or falls in prices of single commodities in single systems.
For
trade-goods.plist
there are several ways to do it. In the general case, I would use the
market_script
key in [wiki]planetinfo.plist[/wiki] to set a global market script across all systems, and then use that script to set up whatever algorithm was desired for goods prices based on the economy.
That said, depending on how complex what you want is, you might be able to do it entirely in [wiki]trade-goods.plist[/wiki] by using the
peak_export
and
peak_import
properties. In the core game they're set to 0 and 7 (or 7 and 0) for all goods, so the prices line up between Rich Industrial and Poor Agricultural - but you could set them to something else, so a trade good has the highest quantities and lowest price at economy 3, the lowest quantities and highest price at economy 6, and everywhere else will automatically end up somewhere in the middle. You then just rename the economies in
descriptions.plist
so that the peak import/export you've set up makes thematic sense.
Re: Scripters cove
Posted: Thu Apr 16, 2015 7:46 pm
by Vincentz
cim wrote:For
commodities.plist
- and I would also
not recommend spending time working on this for a new OXP - you can define multiple market definition entries within the plist, and then in planetinfo.plist (or the JS equivalents) select different market definitions for different systems which coincidentally happen to match the economy numbers of those systems. The old
BlOomberg Markets OXP uses a very similar method to create rare temporary rises or falls in prices of single commodities in single systems.
For
trade-goods.plist
there are several ways to do it. In the general case, I would use the
market_script
key in [wiki]planetinfo.plist[/wiki] to set a global market script across all systems, and then use that script to set up whatever algorithm was desired for goods prices based on the economy.
That said, depending on how complex what you want is, you might be able to do it entirely in [wiki]trade-goods.plist[/wiki] by using the
peak_export
and
peak_import
properties. In the core game they're set to 0 and 7 (or 7 and 0) for all goods, so the prices line up between Rich Industrial and Poor Agricultural - but you could set them to something else, so a trade good has the highest quantities and lowest price at economy 3, the lowest quantities and highest price at economy 6, and everywhere else will automatically end up somewhere in the middle. You then just rename the economies in
descriptions.plist
so that the peak import/export you've set up makes thematic sense.
While tempting to do the peaks, which would work for most of the markets, I think I would have to go for the market_script, as my plan was to let the Financial economy be a more randomized market with possibilities of making good purchases and sells (within reasonable outswings).
So... (sorry for being so code illiterate) how would a market_script.js look like, and how would it be able to differentiate from different economiy levels?
Re: Scripters cove
Posted: Thu Apr 16, 2015 7:52 pm
by cim
Vincentz wrote:So... (sorry for being so code illiterate) how would a market_script.js look like, and how would it be able to differentiate from different economiy levels?
You'd set a market script on the system (through
planetinfo.plist
, most likely) with something like this in:
Code: Select all
this.updateLocalCommodityDefinition = function(marketdef, station, system) {
var systemInfo = System.infoForSystem(galaxyNumber,system); // get the system info
var economyNumber = systemInfo.economy; // get the economy number for the system
// you can also get other system properties or variables at this point
// the precalculated details for the tradegood are in the marketdef object at this point
// so you can still use the plist to set up a lot of the basic calculations, and only need
// to adjust the result here
var price = ...; // calculation of price based on economy
var quantity = ...; // calculation of price based on economy
// set the calculated price and quantity back onto the market definition
marketdef.price = price;
marketdef.quantity = quantity;
// and give the market definition back to Oolite to use
return marketdef;
};
Re: Scripters cove
Posted: Thu Apr 16, 2015 11:16 pm
by Vincentz
cim wrote:Vincentz wrote:So... (sorry for being so code illiterate) how would a market_script.js look like, and how would it be able to differentiate from different economiy levels?
You'd set a market script on the system (through
planetinfo.plist
, most likely) with something like this in:
Code: Select all
this.updateLocalCommodityDefinition = function(marketdef, station, system) {
var systemInfo = System.infoForSystem(galaxyNumber,system); // get the system info
var economyNumber = systemInfo.economy; // get the economy number for the system
// you can also get other system properties or variables at this point
// the precalculated details for the tradegood are in the marketdef object at this point
// so you can still use the plist to set up a lot of the basic calculations, and only need
// to adjust the result here
var price = ...; // calculation of price based on economy
var quantity = ...; // calculation of price based on economy
// set the calculated price and quantity back onto the market definition
marketdef.price = price;
marketdef.quantity = quantity;
// and give the market definition back to Oolite to use
return marketdef;
};
Thanks, I'll have a look at it tomorrow.
Actually my request shouldn't even have been in this thread, but in this one :
https://bb.oolite.space/viewtopic.php?f=6&t=3296
Sorry for the mistake