Correct. In that case the function declaration would be hoisted, but not the definition. If you tried to put a function call before the line that defines the function, you'd get an error.Day wrote:Ah... But maybe it doesn't work when functions are declared this way?:Code: Select all
var thingie = function() {alert("Hello World!";)}
Scripters cove
Moderators: winston, another_commander
Re: Vectors
Re: Vectors
In this case, is there an interest to use thePhasted wrote:Correct. In that case the function declaration would be hoisted, but not the definition. If you tried to put a function call before the line that defines the function, you'd get an error.Day wrote:Ah... But maybe it doesn't work when functions are declared this way?:Code: Select all
var thingie = function() {alert("Hello World!";)}
Code: Select all
var thingie = function() {alert("Hello World!";)}
Re: Scripters cove
Is is possible to detect, from a script, what cargo will be jettisoned?
Re: Vectors
Ok, so...Wildeblood wrote:Tell more, please.
I might update this post...
First, I should point that all the math is more precisely explained here: en.wikipedia.org/wiki/Vector_space
Then, for the math part.
A vector space is simply a set of dimensions, like for example this one:
- length,
- height,
- depth,
- alpha,
- time.
These dimensions have units, so we can measure along them.
The zero vector here would be: (0, 0, 0, 0, 0), and the unit vector would be (1, 1, 1, 1, 1).
A vector is a group of n values describing a point in this vector space.
It can used to describe a position, or a displacement, this being a substraction between two positions.
Vectors may be added: +
Vectors may be multiplied: *
Multiplied? Yup, a vector is simply a matrix of dimensions [1, n] or [n, 1]
Now, what interesting physical operations can we use vector for?
- translation: adding a vector (displacement) to a vector (position),
- projection: if I want to get the alpha component of my previous vector space, i just have to multiply it by the matrix [[0, 0, 0, 1, 0]].
- rotation, scaling: well, there we go more into the explanation of matrixes.
We speak of an orthogonal vector space when all projections of unit vectors along each dimension on other dimensions give zero. Physically, they are independent.
And an orthonormal vector space is the same, plus each unit vector along each dimension has the same length when using the same function chosen as "length(vector)".
In 3D worlds, we always use orthonormal vector spaces.
Re: Scripters cove
Not that I would not enjoy lesson in vectors, but may I humbly ask for a dedicated thread for it. It will get lost here and it's got not much to do with scripting. It's more of a basic maths type of thing. Progress to quaternions and it'll be worth stickying .
Anyway, to repeat my question, so it won't get lost: Is there a way to detect what the player will be jettisoning next?
Anyway, to repeat my question, so it won't get lost: Is there a way to detect what the player will be jettisoning next?
Re: Scripters cove
A good point... perhaps one of the moderators can be persuaded to split this off.spara wrote:Not that I would not enjoy lesson in vectors, but may I humbly ask for a dedicated thread for it
Re: Scripters cove
I think you're out of luck... you'll have to ask for an event handler: this.playerDumpedCargo(commodity, quantity) that fires when the player actually ejects a container or this.playerWillDumpCargo(commodity, quantity) that fires each time the player cycles through his manifest with [crtl-r].spara wrote:Anyway, to repeat my question, so it won't get lost: Is there a way to detect what the player will be jettisoning next?
Re: Scripters cove
I'll do one (but tomorrow, now is sleepy time)Phasted wrote:A good point... perhaps one of the moderators can be persuaded to split this off.spara wrote:Not that I would not enjoy lesson in vectors, but may I humbly ask for a dedicated thread for it
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Scripters cove
How do I get an ellipsis character ("…") using Javascript? I tried
var ellip = String.fromCharCode(133);
, and even tried inserting it directly into text, but it displays it as a backwards question mark.- Norby
- ---- E L I T E ----
- Posts: 2577
- Joined: Mon May 20, 2013 9:53 pm
- Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
- Contact:
Re: Scripters cove
Even with 3DFont?phkb wrote:displays it as a backwards question mark.
- phkb
- Impressively Grand Sub-Admiral
- Posts: 4830
- Joined: Tue Jan 21, 2014 10:37 pm
- Location: Writing more OXPs, because the world needs more OXPs.
Re: Scripters cove
I've tried with the default font, Dangerous square, 3D font, and Standalone font. They all show a question mark (sorry, not a backwards one. just a regular one).
Re: Scripters cove
phkb wrote:How do I get an ellipsis character ("…") using Javascript? I triedvar ellip = String.fromCharCode(133);
, and even tried inserting it directly into text, but it displays it as a backwards question mark.
String.fromCharCode()
doesn't support high-bit (128-255) characters very well. Direct insertion into the text file should work fine - I just did mission.runScreen({title: "…"});
in the debug console - but make sure your text editor is saving the file as UTF-8 and not some other encoding.Re: Scripters cove
Downloaded 1.82 and I've just started playing around with it.
Wrote a test commodity script, just to see what would happen...
For some reason not clear to me this is being called three times... Is it supposed to be called three times, or have I done something I shouldn't have?
Here's the relevant bit from the log:
Wrote a test commodity script, just to see what would happen...
Code: Select all
this.updateGeneralCommodityDefinition = function(mD, sn, sysID)
{
var p_a = "price_average", p_e = "price_economic", p_r = "price_random";
var dL = ns.RLE_IM._difLev, eB, /*= Math.abs(ns.RLE._econBalance),*/ se = "system.economy";
var pa = mD[p_a], pe = mD[p_e], pr = mD[p_r];
if(eB == null) {eB = Math.random() * 25;} log(this.name, eB + sn + ": set by food...");
pAvg(); pEcon(); pRnd();
log(this.name, "what time is it? It's food time!");
return mD;
function pAvg() {if(dL > 3) {pa -= 5 * (dL - 3);} mD[p_a] = pa;}
function pEcon() {pe += eB * .0035; if(dL > 3) {pe -= .06 * (dL - 3);} mD[p_e] = pe;}
function pRnd() {pr += eB * .0015; mD[p_r] = pr;}
}
Here's the relevant bit from the log:
Code: Select all
19:43:03.595 [RLE-commodity-food]: 22.848355898001792: set by food...
19:43:03.595 [RLE-commodity-food]: what time is it? It's food time!
19:43:03.596 [RLE-commodity-computers]: 19.71192216405066: set by computers...
19:43:03.596 [RLE-commodity-computers]: what time is it? It's computer time!
19:43:03.601 [RLE-commodity-food]: 18.91723736814816: set by food...
19:43:03.601 [RLE-commodity-food]: what time is it? It's food time!
19:43:03.602 [RLE-commodity-computers]: 19.380363223454356: set by computers...
19:43:03.602 [RLE-commodity-computers]: what time is it? It's computer time!
19:43:03.607 [RLE-commodity-food]: 3.761511813537857: set by food...
19:43:03.607 [RLE-commodity-food]: what time is it? It's food time!
19:43:03.607 [RLE-commodity-computers]: 24.72310966388351: set by computers...
19:43:03.607 [RLE-commodity-computers]: what time is it? It's computer time!
Re: Scripters cove
Yes. Once with station null for the system prices, and then once for each secondary station of which there are presumably two in your test system.Phasted wrote:For some reason not clear to me this is being called three times... Is it supposed to be called three times