Switches, If's and Checking Values

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

I'm stuck again with my poor scripting abilites. This is a follow on from the incrmenting values thread BTW.

So, when an Ares Outpost is destroyed (not neccessarily by the player, but I haven't fixed that yet), a value is increased by one.

When the player talks to a mission giver, I want Trans to check the value and redirect to the correct dockscreen.

I have this:

Code: Select all

<Help
					desc=	"The General looks at you thoughtfully.\n"What kinda ship you got kid? Ronin/A right - just like we're using...Listen, we're doing our best here, but one more ship will help us a lot. Tell me, how many Ares Outposts have you taken down?"">
				<Actions>
					<Action name=""I don't think I'm right for the job..."" key="d" cancel="1">
						<ShowPane pane="Refuse"/>
					</Action>
					<Action name="(Tell him how many Outposts you have destroyed)" key="T" cancel="1">
						(block Nil
						(switch
							(and (eq(objGetData gPlayerShip "LincolnOutpostsDestroyed") Nil))
								(scrShowPane gScreen "NoGood")
						
							(geq (objGetData gPlayerShip "LincolnOutpostsDestroyed") "1")
								(scrShowPane gScreen "HelpLevel1")
						)
					)						
						
					</Action>
				</Actions>

			</Help>
It should be so simple -- but I have no idea how to get a switch to work...I have simply pasted code from source XML's and this isn't working. The first bit works - but the second bit doesn't.

Please help! :(
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

Are you going to to have multiple actions in the future (if they killed 2, 3, 4 etc.), or just those two?

Also, notice that you are checking if the value returned by objGetData is greater or equal to the string value of 1, not the integer value of 1... try changing that.
User avatar
ThePrivateer
Militia Captain
Militia Captain
Posts: 943
Joined: Tue Oct 12, 2010 5:12 am
Location: Starton Australia

alterecco wrote:Are you going to to have multiple actions in the future (if they killed 2, 3, 4 etc.), or just those two?

Also, notice that you are checking if the value returned by objGetData is greater or equal to the string value of 1, not the integer value of 1... try changing that.
I will require multiple values for the missions, that is very important.

I'll try changing the string to the integer...hold on (i'll edit in a minute).

Edit: Okay that works -- now I'm having trouble generating a mission...I've copied and pasted code from Commonwealth Habitat missions and I'm just trying to make it work with my setup.
User avatar
ThePrivateer
Militia Captain
Militia Captain
Posts: 943
Joined: Tue Oct 12, 2010 5:12 am
Location: Starton Australia

Yeah, I need to get multiple things working and it's failing.

Code: Select all

(block Nil
						(switch
							(and (eq(objGetData gPlayerShip "LincolnOutpostsDestroyed") Nil))
								(scrShowPane gScreen "NoGood")
						
							(geq (objGetData gPlayerShip "LincolnOutpostsDestroyed") 1)
								(scrShowPane gScreen "HelpLevel1")
								
							(geq (objGetData gPlayerShip "LincolnOutpostsDestroyed") 2)
								(scrShowPane gScreen "NotEnough")
						)
					)	
No matter how many stations the player takes down, I always end up going to HelpLevel1.

How should I get the best Switch going...what functions do I need so that I can have multiple choices based on how many Outposts have been destroyed? :?
Bobby
Militia Captain
Militia Captain
Posts: 675
Joined: Wed Jul 25, 2007 7:39 pm

That's because

Code: Select all

(geq (objGetData gPlayerShip "LincolnOutpostsDestroyed") 1)
is executed before

Code: Select all

(geq (objGetData gPlayerShip "LincolnOutpostsDestroyed") 2)
reverse the order, it will stop at the first condition or set of conditions that are satisfied.
ImageImage
Thanks to digdug for the banners.
User avatar
ThePrivateer
Militia Captain
Militia Captain
Posts: 943
Joined: Tue Oct 12, 2010 5:12 am
Location: Starton Australia

Bobby wrote:That's because

Code: Select all

(geq (objGetData gPlayerShip "LincolnOutpostsDestroyed") 1)
is executed before

Code: Select all

(geq (objGetData gPlayerShip "LincolnOutpostsDestroyed") 2)
reverse the order, it will stop at the first condition or set of conditions that are satisfied.
Thanks! That works a charm! :D
Post Reply