how is the "if not" statement

Post » Sat Nov 17, 2012 5:34 am

"if not x == 1" does not work

"if x <> 1" for unequal also does not work
"if x >< 1" for unequal also does not work

how is the "if not" or unequal statement?
User avatar
Steph
 
Posts: 3469
Joined: Sun Nov 19, 2006 7:44 am

Post » Sat Nov 17, 2012 1:04 am

could you just have something like this:

Spoiler

if x == 1
return
else
whatever you want
endif
User avatar
Andrew
 
Posts: 3521
Joined: Tue May 08, 2007 1:44 am

Post » Fri Nov 16, 2012 3:14 pm

if x != 1
User avatar
patricia kris
 
Posts: 3348
Joined: Tue Feb 13, 2007 5:49 am

Post » Fri Nov 16, 2012 4:40 pm

hmm yes but that's not nice, it's nothing to do with "=="

if x == 1
else
whatever i want
endif

.. not nice ;-(
User avatar
Valerie Marie
 
Posts: 3451
Joined: Wed Aug 15, 2007 10:29 am

Post » Sat Nov 17, 2012 1:09 am

if x != 1

There's also the "not" symbol: !

So you could use: If !(x == 1) ;NOT A GOOD EXAMPLE

but usually used like:
If !x	 ;Read as: If X is NOT True;It's true, so do thisElse;It's false, so do thisEndIf
User avatar
stevie trent
 
Posts: 3460
Joined: Thu Oct 11, 2007 3:33 pm

Post » Sat Nov 17, 2012 3:23 am

if x != 1

aha yes exactly what I was looking for.. thank you
User avatar
priscillaaa
 
Posts: 3309
Joined: Sat Dec 30, 2006 8:22 pm

Post » Sat Nov 17, 2012 3:04 am

There's also the "not" symbol: !

So you could use: If !(x == 1) ;NOT A GOOD EXAMPLE

It's not in that example, but I use that form for things such as,

if !(Game.GetPlayer().HasSpell(MyCoolSpell)) ;The player doesn't have my cool spell... I think I might cry!
User avatar
Sammygirl500
 
Posts: 3511
Joined: Wed Jun 14, 2006 4:46 pm

Post » Sat Nov 17, 2012 3:43 am

Yeah != is the 'not' version of '=='.

If X does not equal 1. 'If X != 1'
User avatar
Elizabeth Davis
 
Posts: 3406
Joined: Sat Aug 18, 2007 10:30 am

Post » Fri Nov 16, 2012 9:52 pm

So how would you use that in a quest script? For example:

If quest 1 is complete, enable item.
If quest 1 is not complete, do nothing.
User avatar
Rex Help
 
Posts: 3380
Joined: Mon Jun 18, 2007 6:52 pm

Post » Fri Nov 16, 2012 7:06 pm

So how would you use that in a quest script? For example:

If quest 1 is complete, enable item.
If quest 1 is not complete, do nothing.
If Quest1.IsCompleted()	SomeObjectReference.Enable()EndIf
Inverted:
If !Quest1.IsCompleted()	SomeObjectReference.Disable()EndIf
Two-way hinge:
If Quest1.IsCompleted() != SomeObjectReference.IsEnabled()	If SomeObjectReference.IsEnabled()		SomeObjectReference.Disable()	Else		SomeObjectReference.Enable()	EndIfEndIf
User avatar
Sara Lee
 
Posts: 3448
Joined: Mon Sep 25, 2006 1:40 pm

Post » Sat Nov 17, 2012 5:25 am

So how would you use that in a quest script? For example:

If quest 1 is complete, enable item.
If quest 1 is not complete, do nothing.

First, you need to define the quest and item properties so you can pass it in to the script:
Quest Property dunHunterQST AutoObjectReference Property Item Auto

Then you can check if it's completed:
If dunHunterQST.IsCompleted()  Item.Enable()Endif

or if you want to check if it's not completed:
If !(dunHunterQST.IsCompleted());It's not completed...Endif
User avatar
Lisa
 
Posts: 3473
Joined: Thu Jul 13, 2006 3:57 am

Post » Fri Nov 16, 2012 6:18 pm

So how would you use that in a quest script? For example:

If quest 1 is complete, enable item.
If quest 1 is not complete, do nothing.
You wouldn't.

Both of those lines can be done with one line.

If MyQuest.IsCompleted() == 1;do stuff
That would do stuff if it was completed, and if it was anything but completed (i.e. not completed), it wouldn't do anything. You don't even need to have the '== 1' since that's the default check, as JustinOther posted. You only need to use != when there can be multiple things, and you can have anything but one of them.

For example; lets say I'm getting a number. If that number can ONLY be 0 or 1, I don't need to use !=. I can say 'If X == 1' or 'If X == 0'. Since if I need the number to not be 0, I know it HAS to be 1.

However, if it can be any number between 0 and 5, I could use !=. Because if I need it to not be 3, I can't say 'If X == something', because it can equal 5 other numbers. So I would say 'If X != 3'.

Hopefully that makes sense. You only need to use != where the value you are trying to get can equal more than 2 things. Of course, you can use it anyway (If you need it to equal 1 you could say 'If X != 0') but that's messy scripting and bad practice.
User avatar
HARDHEAD
 
Posts: 3499
Joined: Sun Aug 19, 2007 5:49 am

Post » Fri Nov 16, 2012 7:55 pm

Wow 3 replies lol that's great guys thanks for that :) very very helpful.

If I'm checking more than 1 guest is complete, I can just add another line below the if quest complete line can't I? So

If quest 1 complete
If quest 2 complete
Enable object.

(I'd actually copy and paste the above code but I'm on my iPhone and it's annoying just typing lol.)
User avatar
Kerri Lee
 
Posts: 3404
Joined: Sun Feb 25, 2007 9:37 pm

Post » Fri Nov 16, 2012 10:46 pm

If SomeObject.IsDisabled()
	If !Quest1.IsCompleted()	ElseIf Quest2.IsCompleted()		SomeObject.Enable()	EndIf
	If Quest1.IsCompleted()		If Quest2.IsCompleted()			SomeObject.Enable()		EndIf	EndIf
	If Quest1.IsCompleted() && Quest2.IsCompleted() ; && is more expensive than the above		SomeObject.Enable()	EndIf
EndIf
User avatar
Angela Woods
 
Posts: 3336
Joined: Fri Feb 09, 2007 2:15 pm

Post » Fri Nov 16, 2012 8:34 pm

If SomeObject.IsDisabled()
	If !Quest1.IsCompleted()	ElseIf Quest2.IsCompleted()		SomeObject.Enable()	EndIf
	If Quest1.IsCompleted()		If Quest2.IsCompleted()			SomeObject.Enable()		EndIf	EndIf
	If Quest1.IsCompleted() && Quest2.IsCompleted() ; && is more expensive than the above		SomeObject.Enable()	EndIf
EndIf

I swear you guys on here are great, really helpful thank you :smile:

Now I'm assuming I can stick that at the end of a final quest stage script, just because that's where I put my single Enable.Object scripts to enable something after finishing a quest.

So it would go...

SetObjectiveCompleted(40)
;Then the script you pasted Justin, well, one of those 3 :smile:
User avatar
Jason King
 
Posts: 3382
Joined: Tue Jul 17, 2007 2:05 pm

Post » Sat Nov 17, 2012 3:38 am

I swear you guys on here are great, really helpful thank you :smile:

Now I'm assuming I can stick that at the end of a final quest stage script, just because that's where I put my single Enable.Object scripts to enable something after finishing a quest.

So it would go...

SetObjectiveCompleted(40)
;Then the script you pasted Justin, well, one of those 3 :smile:

Ok so it definitely doesn't go where I thought (I don't think) lol.

I have 2 simple quests set up now, just get an apple, quest complete when the apple is collected.

Now for testing I'm trying to enable a shrine once both quests are complete. I have it initially disabled, with quest 1 and 2 set as quest properties on the item. This is the script on the object in the world:

Scriptname aaaShrineEnable1 extends ObjectReference  Quest Property aaaQuest1  Auto  Quest Property aaaQuest2  Auto  If !aaaQuest1.IsCompleted()		ElseIf aaaQuest2.IsCompleted()				aaaShrine1.Enable()		EndIf

I'm getting this error:

Spoiler


Starting 1 compile threads for 1 files...
Compiling "aaaShrineEnable1"...
c:\games\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\aaaShrineEnable1.psc(7,1): missing EOF at 'If'
No output generated for aaaShrineEnable1, compilation failed.

Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on aaaShrineEnable1

Is it because I have to create a reference to the object aaaShrine1 in the quests somewhere? The quests work by the way, I'm getting good at that part :wink:

I'm probably doing this script completely backwards :confused:

Edit: Sorry for hijacking the thread OP.
User avatar
Harry Hearing
 
Posts: 3366
Joined: Sun Jul 22, 2007 6:19 am

Post » Sat Nov 17, 2012 3:51 am

I think you're going about it the other way around. Instead of attaching a script to the object you want to enable, instead attach a papyrus fragment to the quest stage itself and when the appropriate stage is set for complete, have it enable the objectref in question.

As for why you're getting that particular error, I don't know, because I've never put code outside of an event, state, or function. That might have something to do with it.
User avatar
steve brewin
 
Posts: 3411
Joined: Thu Jun 21, 2007 7:17 am

Post » Sat Nov 17, 2012 3:30 am

Thanks Chesko.

So I need to tell the quests about the shrine. Make it an object property? And then add an event to the quest script (after adding the object property) with the code in trying to use, to say if that quest is done and quest 2 is done, enable object?
User avatar
Anthony Rand
 
Posts: 3439
Joined: Wed May 09, 2007 5:02 am

Post » Fri Nov 16, 2012 10:25 pm

So I need to tell the quests about the shrine. Make it an object property? And then add an event to the quest script (after adding the object property) with the code in trying to use, to say if that quest is done and quest 2 is done, enable object?

Yes, you'll need to make a property for the shrine object - to pass it to the script or script fragment.

As far as adding an event, probably not. (At least not a Papyrus "event".) From what I've read above, it sounds like you have a quest and as they complete stages of the quest, you are checking for conditions? (That's normally how I would handle the quest anyway.) If you were working with just one quest and multiple stages, this would be a simple addition to a script fragment tied to the stage. But since you are working with two different quests, is there a logical order to things? Or can they finish either quest in either order? What's the base criteria for the shrine to be enabled?

These answers will help determine where you need to place the code. If either quest can be completed in any order at anjy time, you might just have use the same code at the completion of both quests. Not a big deal, just a few lines of code. (The real drawback is maintaining your code - you'd have to remember to make code changes in both places if you ever want to change how it works.)
User avatar
sally coker
 
Posts: 3349
Joined: Wed Jul 26, 2006 7:51 pm

Post » Sat Nov 17, 2012 2:47 am

Thank you Sollar that's helpful.

The quests don't have to be completed in any particular order mate no. I'm actually wondering now if there's a better way to achieve what I want. This is what I actually want to do:

Have 4 notes, that when read, each starts a quest to go kill a creature. They can be finished in any order, and those 4 notes are there all at the same time.

Now I want another 4 notes with 4 more quest's, in basically the same position in the CK, but disabled. When the PC completes all 4 of the first quests, the new 4 notes become enabled.

I'm wondering if this will be a better way, purely just to make things simpler - also something I actually can do, I can do some things you see ;)

4 notes on table. When note/quest 1 is done, it enables a note with a quest on the table to take its place. Repeat for all the other notes.

Enabling 1 object after completing 1 quest is piece of cake like you said. Maybe that's the better option.
User avatar
Chica Cheve
 
Posts: 3411
Joined: Sun Aug 27, 2006 10:42 pm

Post » Sat Nov 17, 2012 4:45 am

Have 4 notes, that when read, each starts a quest to go kill a creature. They can be finished in any order, and those 4 notes are there all at the same time.

Now I want another 4 notes with 4 more quest's, in basically the same position in the CK, but disabled. When the PC completes all 4 of the first quests, the new 4 notes become enabled.

I'm wondering if this will be a better way, purely just to make things simpler - also something I actually can do, I can do some things you see :wink:

It sounds like you will need to have seperate quests for each note as I don't think quests can have multiple stages active at the same time. Just have all the quests call the same script in the quest complete fragment. In that script fragment, call something like a FinishedQuest() function that checks if all the quests are complete and then enable the next set of objects. All four quests should be able to call the same script, but I don't know if that makes four seperate objects in memory or not. (I'm sure JustinOther can answer that!) I wouldn't store any information in that script, so it won't matter if there are 4 seperate scripts running (each with their own variables). Just have that script call all four quests to see if they are complete. Then, you'll only need to maintain all this logic in one place.

So, big picture:
Make one script with properties for all the quests
Make a function to check if all the quests are completed
When it meets your criteria, enable the next set of objects (obviously, you will need properties for those too)

Tip: I try to make my property names identical to both the name and type of the object in the CK, this will allow the AutoFill to to the tedious work. This will be especially handy as you will have to fill all these properties in all the quests!

Last thing, I would suggest a new thread since we've hijacked this one ;)
User avatar
Assumptah George
 
Posts: 3373
Joined: Wed Sep 13, 2006 9:43 am

Post » Sat Nov 17, 2012 1:30 am

Thanks Sollar :)

The notes all have their own quest. Just think Note 1 = Quest 1, Note 2 = Quest 2 etc.

Also, carry on here to stop the hijack ;)

http://www.gamesas.com/topic/1387419-enable-objects-from-multiple-quest-completions/page__gopid__21140629#entry21140629
User avatar
x a million...
 
Posts: 3464
Joined: Tue Jun 13, 2006 2:59 pm

Post » Fri Nov 16, 2012 5:23 pm

Seeing as how the majority of people who've helped me posted here, just wanted to say a big thank you for all your help :) I've added a thank you to the bottom of my mod description, to show the world and his sandwich what jolly smashingly good chaps you are!

http://skyrim.nexusmods.com/mods/18866
User avatar
Penny Wills
 
Posts: 3474
Joined: Wed Sep 27, 2006 6:16 pm


Return to V - Skyrim