I never meant to imply that everyone follows this kind of style just that the majority of scripts I have looked at seem to follow this kind of working. Agreed, like A_C stated, we should be following the stock scripts as a template in practice, but the reality is that your scripts are among a minority (or at least a minority in the vast amount of OXPs I have installed) that seem to follow the stock scripts. This is why myself, and others as well I would imagine, have adopted a different style of script that has unfortunately seems to have become the "unofficial" standard or norm, by following scripts that were already available, like the ones I have mentioned before.Commander McLane wrote:Misunderstanding. I'm not doubting the existence of demoScript.js (I've looked it up in the meantime) in UPS-courier.oxp. I just find your assumption that "everyone seems to follow" this JS-file when laying out their scripts a little bold.Pleb wrote:I'm currently at work and therefore unable to supply you with the exact the name of the file, but if you download the UPS OXP and look in its script folder there is an example Javascript file in there.Commander McLane wrote:Where do you get this idea from? I have never heard of a "template/example" JS file. (I also don't have UPS installed.)
And that's because I never ever even once followed its layout, or used it as a template when writing my own scripts, of which I have written a fair number so far.
If you take the time to study a script of mine—for instance anarchies.js as an example for a rather long script—you will see that if it follows a template, it's that of Oolite's own scripts, which I thought to be the sensible thing to follow when I wrote the OXP (or more precisely, when I converted the script from legacy style into JS).
Perhaps the wiki should reflect the stock scripts and their layout so that this problem can be avoided in future? I know I intend to rework my own scripts now to follow the core scripts so that they are no longer flawed as Ahruman pointed out.
It's more the way that missions are offered and how choices are handled in the scripts. Again, being at work I don't have access to the game and have to rely on memory, but from what I can remember the way the script is laid out is more similar to the demoScript.js in UPS than the core scripts, which do look very different in comparison.smivs wrote:I've never used a template of any kind, and was also unaware of the script in UPS which I have never used or even downloaded.
Pleb, you metioned Xeptatl' Sword amongst others in your first post. All the scripting in that OXP is original, mostly written by Okti, but with much by me. It was written the way it is because that's the way we wrote it, not because of any 'template'.
I wonder if what we are seeing here is the simple fact that scripts tend to have the same 'look' to them simply because they are scripts, the same way the HTML/CSS of a web-page will look very similar to the HTML/CSS of a totally different web-page.
Out of interest, I had a quick scan through some of the 'core' scripts to refresh my memory, and I have to be honest and say I can't see much diffrence in the 'layout' of them to most of the OXP scripts I'm familiar with. Yes, they are well laid out and commented, but I like to think my more recent scripting efforts are as well, and I'm just an amateur who's still learning.
I still need to start using $ for custom functions, and 'use strict' I was unaware of, but I'm trying.
I didn't want to start a massive argument about how/how not to write a script and point fingers at anyone, because I am fully aware that I have only written one "working" OXP and that it contains many flaws, I simply wanted to know why there is this difference of style. However on reflection it would seem that perhaps it is simply my misunderstanding and I appologise and will try to re-write my own script to try and make it acceptable to everyone here.