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 »

Great. Thanks. And - probably a pipedream - are the prices for the last system visited (ie. the one before the current station) stored somewhere for retrieval, so that profit can be calculated?

Edit: or the contents of the player-ship's cargo hold?

Edit2: or will the playerBoughtCargo still hold that value, even after exiting witchspace and docking?
Dor 'call me Grocer' Reval (a Xexedian Laver) was always considered a little backward.
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 »

Or are any variables I set within the two functions persistent? And if not, can I make them global somehow for future reference?
Dor 'call me Grocer' Reval (a Xexedian Laver) was always considered a little backward.
User avatar
montana05
---- E L I T E ----
---- E L I T E ----
Posts: 1166
Joined: Mon May 30, 2016 3:54 am
Location: lurking in The Devils Triangle (G1)

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

Post by montana05 »

Reval wrote: Mon Nov 09, 2020 10:05 am
Edit: or the contents of the player-ship's cargo hold?
You can use manifest for players and cargoList for NPC's. http://wiki.alioth.net/index.php/Oolite ... p#manifest and http://wiki.alioth.net/index.php/Oolite ... #cargoList could help there.
Scars remind us where we've been. They don't have to dictate where we're going.
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 »

Thanks. Manifest gives the quantities of all items in the hold; it doesn't seem to indicate the prices they were bought at (That's what I need to calculate profit) - is there any way to get at those? I mean, is it a question of setting global variables (if that's even possible)?
Dor 'call me Grocer' Reval (a Xexedian Laver) was always considered a little backward.
User avatar
montana05
---- E L I T E ----
---- E L I T E ----
Posts: 1166
Joined: Mon May 30, 2016 3:54 am
Location: lurking in The Devils Triangle (G1)

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

Post by montana05 »

Reval wrote: Mon Nov 09, 2020 10:26 am
Or are any variables I set within the two functions persistent? And if not, can I make them global somehow for future reference?
Yes, you can define global variables by using this.$yourName for example. Please never forget the $ so you don't mess with the core source. If you define a script as a worlscript you can reference to it from other OXP's as well.
Scars remind us where we've been. They don't have to dictate where we're going.
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 »

Thanks again :) And global arrays/lists - what's the notation for those? (I mean, is this standard Javascript? If so, I can get a lot of this info from a textbook and not have to bother people here so much ;) )
Dor 'call me Grocer' Reval (a Xexedian Laver) was always considered a little backward.
User avatar
montana05
---- E L I T E ----
---- E L I T E ----
Posts: 1166
Joined: Mon May 30, 2016 3:54 am
Location: lurking in The Devils Triangle (G1)

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

Post by montana05 »

Reval wrote: Mon Nov 09, 2020 11:38 am
Thanks again :) And global arrays/lists - what's the notation for those? (I mean, is this standard Javascript? If so, I can get a lot of this info from a textbook and not have to bother people here so much ;) )
I would recommend https://www.w3schools.com/js/js_array_sort.asp for better knowledge of the js on Oolite, as much as I checked its pretty useful. Never forget that manifest or CargoList are arrays. :wink:

What I would suggest is to look at some OXP's from the past, phkb, Thargoid, Norby would come to my mind.
Scars remind us where we've been. They don't have to dictate where we're going.
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 »

Cheers :) That link looks very useful. Thanks for your suggestion about delving into existing OXP js scripts too: I have been taking a look at Spara's Market Observer script and learned a bit from that. Now that I know how the globals are notated, I can learn even more from it :)
Dor 'call me Grocer' Reval (a Xexedian Laver) was always considered a little backward.
User avatar
montana05
---- E L I T E ----
---- E L I T E ----
Posts: 1166
Joined: Mon May 30, 2016 3:54 am
Location: lurking in The Devils Triangle (G1)

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

Post by montana05 »

Reval wrote: Mon Nov 09, 2020 11:57 am
Cheers :) That link looks very useful. Thanks for your suggestion about delving into existing OXP js scripts too: I have been taking a look at Spara's Market Observer script and learned a bit from that. Now that I know how the globals are notated, I can learn even more from it :)
Glad that I can help, when I joined Oolite my last (serious) language was PL/I and SQL (DB/2) so by learning from experts here and reading all the references I was able to improve, my current curse nowadays is that I don't have a budget or a deadline anymore but a lot of creativity, so I usually I implement more than necessary. :oops:
Scars remind us where we've been. They don't have to dictate where we're going.
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 »

montana05 wrote: Mon Nov 09, 2020 12:13 pm
Reval wrote: Mon Nov 09, 2020 11:57 am
Cheers :) That link looks very useful. Thanks for your suggestion about delving into existing OXP js scripts too: I have been taking a look at Spara's Market Observer script and learned a bit from that. Now that I know how the globals are notated, I can learn even more from it :)
Glad that I can help, when I joined Oolite my last (serious) language was PL/I and SQL (DB/2) so by learning from experts here and reading all the references I was able to improve, my current curse nowadays is that I don't have a budget or a deadline anymore but a lot of creativity, so I usually I implement more than necessary. :oops:
I can certainly relate to that :) I come from a Pascal and C/C++/PHP background, so I guess JS is not quite as strange to me as it must have been for you. Ditto about the oceans of time and lack of deadlines + plenty of ideas :)

Oolite, it seems, is the ideal playground now, hehe...
Dor 'call me Grocer' Reval (a Xexedian Laver) was always considered a little backward.
User avatar
montana05
---- E L I T E ----
---- E L I T E ----
Posts: 1166
Joined: Mon May 30, 2016 3:54 am
Location: lurking in The Devils Triangle (G1)

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

Post by montana05 »

Reval wrote: Mon Nov 09, 2020 11:57 am
I can certainly relate to that :) I come from a Pascal and C/C++/PHP background, so I guess JS is not quite as strange to me as it must have been for you. Ditto about the oceans of time and lack of deadlines + plenty of ideas :)

Oolite, it seems, is the ideal playground now, hehe...
I did some Pascal and C ++ before, however, 1999 was a golden year, we had 2K and Euro, and I made more money in 6 months than in 6 years before. Enough to change my carrier and open my own business.
Scars remind us where we've been. They don't have to dictate where we're going.
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 »

Ahh... the '90s :) Good times...
Dor 'call me Grocer' Reval (a Xexedian Laver) was always considered a little backward.
User avatar
montana05
---- E L I T E ----
---- E L I T E ----
Posts: 1166
Joined: Mon May 30, 2016 3:54 am
Location: lurking in The Devils Triangle (G1)

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

Post by montana05 »

Reval wrote: Mon Nov 09, 2020 12:40 pm
Ahh... the '90s :) Good times...
You ever used assembler ?
Scars remind us where we've been. They don't have to dictate where we're going.
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 »

Hmmm. I dabbled in Z80 and 68000 asm way back when (Those were Atari ST days, hehe). Yes, enjoyed it but never really got into it deeply. Too much for too little, if you know what I mean ;)
Dor 'call me Grocer' Reval (a Xexedian Laver) was always considered a little backward.
User avatar
montana05
---- E L I T E ----
---- E L I T E ----
Posts: 1166
Joined: Mon May 30, 2016 3:54 am
Location: lurking in The Devils Triangle (G1)

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

Post by montana05 »

Reval wrote: Mon Nov 09, 2020 12:47 pm
Hmmm. I dabbled in Z80 and 68000 asm way back when (Those were Atari ST days, hehe). Yes, enjoyed it but never really got into it deeply. Too much for too little, if you know what I mean ;)
Very useful in the past, going down to bits and bytes, at 64C (or Atari ST) nowadays not a much in use anymore.
Scars remind us where we've been. They don't have to dictate where we're going.
Post Reply