Jump to content

Multiple IF statements


putnamehere

Recommended Posts

Never posted here in the forums before. I'm at a loss right now trying to script something. Normally I don't have a problem scripting but this isn't working well for me.

 

begin onactivate

 

if player.getitemcount Lead >= 10 player.getitemcount SpareParts >= 2 player.getitemcount FissionBattery >= 3 player.getitemcount PilotLight >= 2

Setstage BoatFixQuest 40

GPSSwitch.enable 0

Player.removeitem Lead 10

Player.removeitem SpareParts 2

Player.removeitem FissionBattery 3

Player.removeitem PilotLight 2

ShowMessage BoatFixedMessage

 

else

showmessage boatfixupmessage

 

endif

 

startquest boatfixquest

setstage boatfixquest 10

 

end

 

I've jumbled this around in many different ways. My core problem seems to be with the if statement. I can get everything else to work depending on where I put it. I can get the quest the start and the stage at 10 but everything in the if lines doesn't work. Anyone know what is wrong here? I'm no professional programmer but I've been able to eventually get everything working. I know I should probably be using a form list for the items but I think this makes it a little more clear.

 

I can get both messages to pop up but not when they are are in the if statement. I've narrowed it down to simply being that the if statement doesn't work. I'm pretty sure I was able to get boatfixupmessage to display under the if statement but only when each of the getitemcount's were on their own line which caused only 1 getitemcount to register. I tried putting if, if, if, if for each of the lines but that wouldn't let me save. Is there a way to add multiple lines under an if statement or is that not really the problem and the way I currently have it okay?

 

If that wasn't clear,

 

if getitemcount .......

if getitemcount ......

if getitemcount ......

if getitemcount ......

endif

 

Is there a way to do the above but rather with also or and? I wasn't able to get those two words to work either. Am I simply just needing 4 endif's after each if and it will run all 4 to check if they are true? If so, how would you script in all the other variables inbetween? Multiple if's seems convoluted but I've no idea how to fix this.

 

Thanks in advance.

Edited by putnamehere
Link to comment
Share on other sites

I can't really tell what the script is meant to say - try using the code option when writing your post.

 

You can do logical ANDs and ORs if that's what you're asking:

scn aScript

begin OnActivate

	if (PlayerREF.GetItemCount Form01 > 5) && (PlayerREF.GetItemCount Form02 > 10)

		;player has more than 5 Form01 and more than 10 Form02

	endif

	if (PlayerREF.GetItemCount Form01 == 1) || (PlayerREF.GetItemCount Form02 == 1)

		;player has exactly 1 Form01 or exactly 1 Form02, or both.

	endif

end
Link to comment
Share on other sites

 

 

I can't really tell what the script is meant to say - try using the code option when writing your post.

 

You can do logical ANDs and ORs if that's what you're asking:

scn aScriptbegin OnActivate	if (PlayerREF.GetItemCount Form01 > 5) && (PlayerREF.GetItemCount Form02 > 10)		;player has more than 5 Form01 and more than 10 Form02	endif	if (PlayerREF.GetItemCount Form01 == 1) || (PlayerREF.GetItemCount Form02 == 1)		;player has exactly 1 Form01 or exactly 1 Form02, or both.	endifend
 

 

Sorry I'm new to the forums.

 

The script is meant to sort of follow the McCarran Kitchen quest where you get items to fix something. Only this is meant to enable a switchbox that will be an activator for another quest. It will have its own script where it takes 3 containers, the player and dumps them into a location. Like a door but I need to transfer 3 containers for this so I can't use a door marker.

 

I added the ANDs between them and it now shows the message for failing getting the items but when you have the items it does nothing still but show the failure message of not having the items.

 

begin onactivate if (player.getitemcount Lead >=10) && (player.getitemcount SpareParts >= 2) && (player.getitemcount FissionBattery >= 3) && (player.getitemcount PilotLight >= 2)  Setstage BoatFixQuest 40  GPSSwitch.enable 0  Player.removeitem Lead 10  Player.removeitem SpareParts 2  Player.removeitem FissionBattery 3  Player.removeitem PilotLight 2  ShowMessage BoatFixedMessage else  showmessage boatfixupmessage endifstartquest boatfixquestsetstage boatfixquest 10end
After looking over the vanilla script, they use 2 separate parts in 1 script window or maybe 2 scripts in 1 window if that makes sense. 1 that does some stuff I'm not really familiar with at the beginning relating to the freeform quest I assume. The rest of the first one sets a short variable called hasitems to 1 or 0 depending on if the player has the items. The second script area runs a script just based off if hasitems is 1 or not. Doing most of the work if it is 1 obviously.

 

I'm going to try and do this the vanilla way first as it will break the stuff up more. I thought that if the IF statement turned back true then the rest of the lines under it would be executed. Is this not so?

Link to comment
Share on other sites

 

No problem. Glad to be of service.

 

 

If it isn't too much to ask another question. I can't googlefu my way through this problem. I have 3 containers I am moving with the player around to different locations. I have them moving where I want them and don't have any issues with inventory or anything like that but after they are moved to a new position, they lose the ability to be accessed by the player. I've tried reset3dstate and doing an enable/disable script to reset them but I can't get it to work where the player can access them. The prompt to search the containers just isn't there and the collision isn't there either. I can walk through them. It seems like the object is there along with its information but the collision markers aren't there. Any idea or experience with this?

Link to comment
Share on other sites

Use update3d. The syntax is very simple: "refname".update3d

 

It's usually pretty reliable but you'll need NVSE for it.

 

 

Also, the geck wiki's page for moveto has a workaround that's worked well for me with anim static type activators in the past that doesn't need NVSE.

 

http://geck.bethsoft.com/index.php?title=MoveTo

Edited by uhmattbravo
Link to comment
Share on other sites

 

It's usually pretty reliable but you'll need NVSE for it.

 

Also, the geck wiki's page for moveto has a workaround that's worked well for me with anim static type activators in the past that doesn't need NVSE.

 

http://geck.bethsoft.com/index.php?title=MoveTo

 

 

Currently trying to avoid an NVSE requirement at the moment but I may end up using it out of frustration lol.

 

I tried moveto but then I can't get the rest of the script to work. For some reason, when I have the setpos being used, I can still activate the thing that triggers the script to run. When I use moveto it causes the script to not run. The game doesn't crash and I can save. Not sure what is going on. I spent a good bit of time trying all kinds of different methods to make this work. Even doing separate scripts. This whole intro scene is about 10 seconds worth of time in game and is taking hours of trouble shooting :D

Link to comment
Share on other sites

If I remember right, I used a quest script calling the functions on an object ref. If it helps, I used separate "stages" ex:

 

Short state

Float xpos

 

 

If state == 1

Ref.disable

Set state to 2

 

Elseif state == 2

Ref.moveto marker

Set state to 3

 

Elseif state == 3

Set xpos to ref.getpos x

Set state to 4

 

Elseif state == 4

Ref.setpos x to xpos

Set state to 5

 

Elseif state == 5

Ref.enable

Set state to 0

Endif

 

 

Though, I don't think I actually separated it quite that much, but I also reset the y and z pos and z angle with the x pos to get my UFO and vertibird to show up properly.

Edited by uhmattbravo
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...