Increasing a player's credits

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

Moderators: winston, another_commander

Post Reply
User avatar
byronarn
Dangerous
Dangerous
Posts: 85
Joined: Thu Nov 18, 2010 6:08 am
Location: United States

Increasing a player's credits

Post by byronarn »

I'm sure there is a method for increasing a player's credits (at the end of a successful mission, for example), but I can't find the function that does it on the wiki. Maybe I am just overlooking it. Can anyone help?
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2691
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Increasing a player's credits

Post by spara »

player.credits = 100000000;
User avatar
hoqllnq
Commodore
Commodore
Posts: 154
Joined: Sun Jan 08, 2006 7:32 pm

Re: Increasing a player's credits

Post by hoqllnq »

byronarn wrote: Mon Mar 27, 2017 11:06 am
... but I can't find the function that does it on the wiki....
Here is an overview of all available properties and methods for the player class.
User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6311
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

Re: Increasing a player's credits

Post by Diziet Sma »

spara wrote: Mon Mar 27, 2017 11:20 am
player.credits = 100000000;
Shouldn't that be:

Code: Select all

player.credits = player.credits + 100000000;
?

:mrgreen:
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2691
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Increasing a player's credits

Post by spara »

:lol: :lol:
Diziet Sma wrote: Mon Mar 27, 2017 12:49 pm
spara wrote: Mon Mar 27, 2017 11:20 am
player.credits = 100000000;
Shouldn't that be:

Code: Select all

player.credits = player.credits + 100000000;
?

:mrgreen:
:lol: True. The question was to increase, not set. I'll do better next time :).
User avatar
byronarn
Dangerous
Dangerous
Posts: 85
Joined: Thu Nov 18, 2010 6:08 am
Location: United States

Re: Increasing a player's credits

Post by byronarn »

hoqllnq wrote: Mon Mar 27, 2017 12:18 pm
byronarn wrote: Mon Mar 27, 2017 11:06 am
... but I can't find the function that does it on the wiki....
Here is an overview of all available properties and methods for the player class.
I was looking on that page but I guess I overlooked it. Guess I thought there would be a player.increaseCredits(1000) or something like that. But player.credits=player.credits+1000 makes sense, too.

Thanks for the replies everyone! I apreciate your help. :D
User avatar
byronarn
Dangerous
Dangerous
Posts: 85
Joined: Thu Nov 18, 2010 6:08 am
Location: United States

Re: Increasing a player's credits

Post by byronarn »

Does the += operator work in Oolite javascript? For example,

Code: Select all

player.credits+=1000;
I know it works in a lot of languages. Regular javascript even has, i do believe. So what about Oolite Javascript?
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6626
Joined: Wed Feb 28, 2007 7:54 am

Re: Increasing a player's credits

Post by another_commander »

byronarn wrote: Mon Mar 27, 2017 6:49 pm
Does the += operator work in Oolite javascript?
Yes. Things like player.credits++ or ++player.credits work as well.
User avatar
Prester John
Competent
Competent
Posts: 56
Joined: Mon Sep 17, 2018 5:57 am

Re: Increasing a player's credits

Post by Prester John »

*hem* ... or install this little 'cheat.oxp'.....
*hides in shame*
Post Reply