Quick Question - Quick Answer : Can I add to a variable?

Freeform discussion about anything related to modding Transcendence.
Post Reply
User avatar
ThePrivateer
Militia Captain
Militia Captain
Posts: 943
Joined: Tue Oct 12, 2010 5:12 am
Location: Starton Australia

QQ-QA :

I would like a way to increment a variable of the player...but no such function seems to exist.

Code: Select all

(objSetData gPlayerShip "foo" "1")
As we all know, that sets a piece of Data (named foo) in the playership to 1. But that sets the data, no questions asked. I want to add to that number...but no function exists on the Wiki or Xelerus.

I want something like this:

Code: Select all

(objAddToData gPlayerShip "foo" "1")
In which foo would get 1 added to it. How do I do that?

If it helps to think outside the box, what I want is this (for Hell's Trinity):

When the player destroys an Ares Outpost in the Lincoln System, a variable gets added to - I want to use this later in a dockscreen to direct the player to a screen based on how many outposts he has killed.

I cannot use this (taken from Eridani.xml which has a similar thing to what I want)

Code: Select all

(setq centauriStations (sysFindObject gSource "T +centauriWarlords; +populated; -occupation; -uncharted;"))
(setq centauriStationsDestroyed (filter centauriStations theStation (objIsAbandoned theStation)))
I can't use that because it doesn't take into account if the player has destroyed the station -- it assumes that the player has, but in theory an netural or friendly could have destroyed that.

I already have this:

Code: Select all

<Events>
<OnDestroy>
(block Nil
(if (eq(sysGetNode) "Lincoln")
(objSetData gPlayerShip "AresOutpostDestroyedLincoln" "1")
)
)
</OnDestroy>
</Events>
But that will only set the variable once -- I can work with this for now, but a solution that adds to the variable would be appreciated (or something outside the box).

Thanks! :D
sdw195
Militia Captain
Militia Captain
Posts: 779
Joined: Wed Nov 18, 2009 1:01 am
Location: Still looking for the csc Antarctica
Contact:

(objIncData spaceObject string [number])
Image
Image
Image
Image
"Dash_Merc - George is a genius, in that he created this game engine that is infinitely extendable"
"<@sheepluva>Good night everybody, may the source be with you." <-- FOSG dev
"You only need THREE tools in life - WD-40 to make things go, Duct Tape to make things stop And C-4 to make things go away"
User avatar
ThePrivateer
Militia Captain
Militia Captain
Posts: 943
Joined: Tue Oct 12, 2010 5:12 am
Location: Starton Australia

sdw195 wrote:(objIncData spaceObject string [number])
:D

That sounds like it will work! :mrgreen:

So it would be :

Code: Select all

(objIncData gPlayerShip "AresOutpostLincoln" "1")
Does the number have to be in "" (quotations)?
sdw195
Militia Captain
Militia Captain
Posts: 779
Joined: Wed Nov 18, 2009 1:01 am
Location: Still looking for the csc Antarctica
Contact:

nope

Code: Select all

(objIncData gPlayerShip "rins" 100)
Adds 100 rins to the player. 
(objIncData gPlayerShip "rins")

Add 1 rin to the player.
Image
Image
Image
Image
"Dash_Merc - George is a genius, in that he created this game engine that is infinitely extendable"
"<@sheepluva>Good night everybody, may the source be with you." <-- FOSG dev
"You only need THREE tools in life - WD-40 to make things go, Duct Tape to make things stop And C-4 to make things go away"
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

what sdw195 points to is definitely the right option, but just for clarification you can also do this:

Code: Select all

(objSetData gPlayerShip "somevalue" (add (objGetData gPlayerShip "somevalue") 1))
User avatar
ThePrivateer
Militia Captain
Militia Captain
Posts: 943
Joined: Tue Oct 12, 2010 5:12 am
Location: Starton Australia

@Sdw195 - thanks for clearing that up,
alterecco wrote:what sdw195 points to is definitely the right option, but just for clarification you can also do this:

Code: Select all

(objSetData gPlayerShip "somevalue" (add (objGetData gPlayerShip "somevalue") 1))
I was going to use that, but I think it failed somewhere...thanks though that could come in handy at some point perhaps. ;)

[See? Quick question, quick answer! :D]
RPC
Fleet Admiral
Fleet Admiral
Posts: 2876
Joined: Thu Feb 03, 2011 5:21 am
Location: Hmm... I'm confused. Anybody have a starmap to the Core?

You'd also have to do a switch to find out if the player has killed the station. Something like [using pseudocode here]

Code: Select all

(switch
(eq(; the destroyer's UNID) (;the playership's UNID)
     (; increment data)
)
Tutorial List on the Wiki and Installing Mods
Get on Discord for mod help and general chat
Image
Image
Der Tod ist der zeitlose Frieden und das leben ist der Krieg
Wir müssen wissen — wir werden wissen!
I don't want any sort of copyright on my Transcendence mods. Feel free to take/modify whatever you want.
Post Reply