Tinkerer's Workshop - OXP tweaking for fun and profit!

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

User avatar
Reval
---- E L I T E ----
---- E L I T E ----
Posts: 402
Joined: Thu Oct 29, 2020 3:14 am
Location: At home in the Xexedi Cluster, driving an FE Asp II, Laenina's Flux.

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by Reval »

Attempting to use Math.trunc(x) to get the integer part of a number, my latest.log gives the error

13:06:22.407 [script.javaScript.exception.notFunction]: ***** JavaScript exception (Elite Trader 1.12): TypeError: Math.trunc is not a function

Is Math.trunc() not the commonly accepted way to do this?
Dor 'call me Grocer' Reval (a Xexedian Laver) was always considered a little backward.
dybal
---- E L I T E ----
---- E L I T E ----
Posts: 499
Joined: Mon Feb 10, 2020 12:47 pm

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by dybal »

Reval wrote: Wed Dec 09, 2020 6:17 pm
Attempting to use Math.trunc(x) to get the integer part of a number, my latest.log gives the error

13:06:22.407 [script.javaScript.exception.notFunction]: ***** JavaScript exception (Elite Trader 1.12): TypeError: Math.trunc is not a function

Is Math.trunc() not the commonly accepted way to do this?
Use x.toFixed(0)
User avatar
Reval
---- E L I T E ----
---- E L I T E ----
Posts: 402
Joined: Thu Oct 29, 2020 3:14 am
Location: At home in the Xexedi Cluster, driving an FE Asp II, Laenina's Flux.

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by Reval »

Ah ok, thanks. (I thought that was a string-function only). I want to use it to reference an array of strings.
Dor 'call me Grocer' Reval (a Xexedian Laver) was always considered a little backward.
dybal
---- E L I T E ----
---- E L I T E ----
Posts: 499
Joined: Mon Feb 10, 2020 12:47 pm

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by dybal »

Reval wrote: Wed Dec 09, 2020 6:31 pm
Ah ok, thanks. (I thought that was a string-function only).
JS loves strings... you have to go out of your way to make sure you get a number, with functions like parseInt() and passing the comparision function to array's sort method.
User avatar
Reval
---- E L I T E ----
---- E L I T E ----
Posts: 402
Joined: Thu Oct 29, 2020 3:14 am
Location: At home in the Xexedi Cluster, driving an FE Asp II, Laenina's Flux.

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by Reval »

Ouch. So you're saying I can't just do

Code: Select all

result = MyArray[x.toFixed(0)];
??
Dor 'call me Grocer' Reval (a Xexedian Laver) was always considered a little backward.
dybal
---- E L I T E ----
---- E L I T E ----
Posts: 499
Joined: Mon Feb 10, 2020 12:47 pm

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by dybal »

Yes, you can.

It's with operations that would give different results for numbers and strings that you have to be careful, like: a=1, b=2, a+b would be 3 if numbers or 12 if strings. And array sorting, the default method would sort [0, 9, 101] as [0, 101, 9]
User avatar
Nite Owl
---- E L I T E ----
---- E L I T E ----
Posts: 556
Joined: Sat Jan 20, 2018 4:08 pm
Location: In The Dark

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by Nite Owl »

If figured correctly the following code from descriptions.plist sends a Console Message to the player's ship giving a description of the contents of a just scooped cargopod. That would be something like 1 ton of Textiles scooped or 7 grams of Gem-Stones scooped or whatever else may be in such a pod.

Code: Select all

"scripted-item-scooped"		= "[shipName] scooped.";
If this premise is wrong from the outset pointing me to the proper line of code in the proper file that does generate the aforementioned Console Message would be a great help. The premise that follows would be the same just with a different string of code possibly from a different file at its base. Unless such a Console Message is hard coded in which case all bets are off as living with what exists is better than messing with C+ and recompiling a personal version of Oolite.

What has been attempted, and failed at miserably, is to convert that Console Message into a Comms Message. Having looked up all of the JavaScript references on such things and having made several failed attempts at putting together a script that would accomplish this goal my wits are spent. The finished script would go in a folder named Scripts that would be a sub-folder of the AddOns folder as this would not be a released OXZ or anything even close to it. The goal is a simple script, as simple as it can be, that would allow such a Console to Comms conversion from a string in the description.plist file or in another file if the original premise proves to be wrong.

Any pointers in the right direction or help that could be offered would be greatly appreciated.
Humor is the second most subjective thing on the planet

Brevity is the soul of wit and vulgarity is wit's downfall

Good Night and Good Luck - Read You Soon
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by another_commander »

"scripted-item-scooped" is used by this line (12965) of ShipEntity.m:

Code: Select all

[UNIVERSE addMessage:OOExpandKey(@"scripted-item-scooped", shipName) forCount:4];
What happens here is quite interesting. As you can see, there is an argument called shipName in tbe addMessage selector. At the same time, the expansion of the string "scripted-item-scooped" contains the term [shipName]. In order for the expansion to occur correctly, the argument and the term inside the square brackets in the expansion must both be called "shipName". Changing any of the two to something else will cause the exapnsion to fail.

But that is for scripted cargo only and is not the line that generates the "1t Furs" (or whatever) message normally. This happens further down, at line 13035 of ShipEntity.m, which reads:

Code: Select all

[UNIVERSE addMessage:[UNIVERSE describeCommodity:co_type amount:co_amount] forCount:4.5];
. The describeCommodity method in Universe.m builds the string that is displayed.

I hope this helps. This was by just looking at what happens in the source and without any actual testing on my part, so I hope I got it right.
User avatar
Nite Owl
---- E L I T E ----
---- E L I T E ----
Posts: 556
Joined: Sat Jan 20, 2018 4:08 pm
Location: In The Dark

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by Nite Owl »

Well then, it appears the Console Message is generated by the base code and not in a file that can be manipulated by JavaScript. A bit of a bummer but having lived with the situation for the past few years soldiering on with things as they are now will not be a problem. If creating an original JavaScript file is a problem for me then messing around with the base code and then compiling a unique version of Oolite is way beyond my pay grade.

Most such things in my Ooniverse have been converted to audible Comms Messages by Tweaking OXZs and the other various files generated by the game upon installation. This was one of the final few such instances that such a conversion could not be found for. Find it much easy to register things that are heard then to register them after glancing at a read message that will disappear after a time.

Thank You another_commander for your quick response and for pointing me in the right direction. It is Much Appreciated.
Humor is the second most subjective thing on the planet

Brevity is the soul of wit and vulgarity is wit's downfall

Good Night and Good Luck - Read You Soon
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by another_commander »

If the objective is to have an acoustic aid for messages, then why not set Spoken Messages to On (to include everything)?
User avatar
Nite Owl
---- E L I T E ----
---- E L I T E ----
Posts: 556
Joined: Sat Jan 20, 2018 4:08 pm
Location: In The Dark

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by Nite Owl »

In my game the Spoken Messages option is currently set to Comms Only. The On option goes a bit too far in converting absolutely everything into an audible message. This includes things like Game Saved and other Game Related messages. Hearing these types of messages ruins the Suspension of Disbelief needed to keep me playing Oolite for hours on end by constantly reminding me that it is, after all, only a game. This is what led to my endless conversion of almost all OXZ related Console Messages to Comms Messages in the first place. Yes - the previous does comes across as an Obsessive Compulsive Disorder type of thing but we must live with what we have as long as we are having fun in doing so. Still it is worth another try to see if the On option can be lived with this time around as a means to this final end.

Thank You once again another_commander for your suggestions and for taking the time to do the research on my behalf.
Humor is the second most subjective thing on the planet

Brevity is the soul of wit and vulgarity is wit's downfall

Good Night and Good Luck - Read You Soon
User avatar
Reval
---- E L I T E ----
---- E L I T E ----
Posts: 402
Joined: Thu Oct 29, 2020 3:14 am
Location: At home in the Xexedi Cluster, driving an FE Asp II, Laenina's Flux.

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by Reval »

Is there a way to determine which ECMAScript version is being used by Oolite? Does this in fact change between updates as new standards become available? I ask because I'd like to know more precisely what in the various standards is supported and what isn't.

For example, let, const? - ie. is it ES6? It would be nice to know unequivocally.
Dor 'call me Grocer' Reval (a Xexedian Laver) was always considered a little backward.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by another_commander »

Straight from the console:

Code: Select all

> oolite.jsVersion
185
> oolite.jsVersionString
ECMAv5
This is the version that we have almost always had and it has not (and will most probably not) changed between versions of the game.

Edit for historical trivia: It is the same Spidermonkey version that Firefox 4 shipped with many years ago, but it is a special build for Oolite.
User avatar
Reval
---- E L I T E ----
---- E L I T E ----
Posts: 402
Joined: Thu Oct 29, 2020 3:14 am
Location: At home in the Xexedi Cluster, driving an FE Asp II, Laenina's Flux.

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by Reval »

That was 2011, then. Interesting - and thanks. At least now I know :)
Dor 'call me Grocer' Reval (a Xexedian Laver) was always considered a little backward.
User avatar
Nite Owl
---- E L I T E ----
---- E L I T E ----
Posts: 556
Joined: Sat Jan 20, 2018 4:08 pm
Location: In The Dark

Re: Tinkerer's Workshop - OXP tweaking for fun and profit!

Post by Nite Owl »

What follows is the formula for calculating quantities of goods at a Secondary Market which is entered into a dockable's shipdata.plist entry. This is taken from HERE.

Code: Select all

rnd = -1..1 // random number in range -1 to +1, slightly biased towards zero
adjusted_quantity = (local_capacity / primary_capacity) * primary_quantity;
secondary_quantity = (adjusted_quantity + quantity_adder) * (quantity_multiplier + (quantity_randomiser * rnd)))
What is presenting me with a problem is a lack of definitions for the items in the second line. Specifically local_capacity, primary_capacity, and primary_quantity. After playing around with this formula for a bit the desired end result still escapes me. Have a few ideas as to where these numbers might be coming from but something is still not working out right. Any definitive definitions would be greatly appreciated. Perhaps adding these definitive definitions to the aforementioned Wiki Page might also be in order.

When defining a Secondary Market for a specific Good how closely does the name of that Good have to match what is defined in the trade-goods.plist? As an example, in trade-goods.plist Gold is coded as follows:

Code: Select all

"gold" = {
		"name" = "[commodity-name gold]";
		<snip the rest>
		};
For my Secondary Market definition does the name have to match what is above exactly (brackets and commodity-name) or can it be coded like this:

Code: Select all

		{
			"type" = "good";
			"name" = "gold";
			<snip the rest>
			},
As always Thank You in advance for your help in these matters.
Humor is the second most subjective thing on the planet

Brevity is the soul of wit and vulgarity is wit's downfall

Good Night and Good Luck - Read You Soon
Post Reply