I hate to be THAT guy but, I have a basic scripting issue.

Post » Wed Jun 20, 2012 6:24 am

Event OnUpdate()If (MOD1QPart1.GetStage() <= 32)	self.SetAllowFlying(false)	groundcount = groundcount + 1		if (groundcount >= 7)			MOD1QPart1.SetStage(33)		endif	debug.Notification("Code Executed"); #2	debug.Notification(groundcount); #1	;More Irrelevant Code Down Here

Ok, so I added the debug functions to help me isolate the problem. According to #1 groundcount is incrementing properly, and to #2, the code is being executed. However, something is wrong with my

if (groundcount >= 7)	  MOD1QPart1.SetStage(33)  endif
section, because when groundcount == 7, it just continues incrementing, and MOD1QPart1 (Which is a quest Property) is never set to stage 33.



Can someone else see what I'm missing and tell me what is wrong with this code?

Appreciate any help.

Upon further reading I think this may have something to do with threading, but I'm not sure.
User avatar
Kit Marsden
 
Posts: 3467
Joined: Thu Jul 19, 2007 2:19 pm

Post » Tue Jun 19, 2012 3:17 pm

Try this....

Event OnUpdate()If (MOD1QPart1.GetStage() <= 32)	  self.SetAllowFlying(false)	  if (groundcount <= 6)  groundcount += 1			  else  MOD1QPart1.SetStage(33)endif  debug.Notification("Code Executed"); #2		debug.Notification(groundcount); #1		;More Irrelevant Code Down Here
User avatar
Laura Elizabeth
 
Posts: 3454
Joined: Wed Oct 11, 2006 7:34 pm

Post » Wed Jun 20, 2012 3:45 am

Yep... Didn't fix anything.
I've also tried "if (groundcount == 7 || groundcount > 7)

Thanks for the idea though
User avatar
Nick Swan
 
Posts: 3511
Joined: Sat Dec 01, 2007 1:34 pm

Post » Tue Jun 19, 2012 10:50 pm

Just had a thought - try making a Quest property and putting your debugs inside the if block.

 Event OnUpdate()If (GetStage() <= 32) self.SetAllowFlying(false) if (groundcount <= 6)  groundcount += 1 debug.Notification(groundcount); #1 else  SetStage(33)  debug.Notification("Code Executed"); #2 endif  ;More Irrelevant Code Down Here
User avatar
ImmaTakeYour
 
Posts: 3383
Joined: Mon Sep 03, 2007 12:45 pm

Post » Tue Jun 19, 2012 5:45 pm

You could try a "for loop". I don't really know what else to suggest.
User avatar
Madeleine Rose Walsh
 
Posts: 3425
Joined: Wed Oct 04, 2006 2:07 am

Post » Wed Jun 20, 2012 6:39 am

Just had a thought - try making a Quest property and putting your debugs inside the if block.

Event OnUpdate()If (GetStage() <= 32)self.SetAllowFlying(false)if (groundcount <= 6)  groundcount += 1debug.Notification(groundcount); #1else  SetStage(33)  debug.Notification("Code Executed"); #2endif;More Irrelevant Code Down Here

Oh true! The way you had it set up before, it would display 'code executed' even if the stage was not set to 33.
User avatar
luke trodden
 
Posts: 3445
Joined: Sun Jun 24, 2007 12:48 am

Post » Wed Jun 20, 2012 4:50 am

i'm not a scripting expert but I think you need a loop as the above post said - maybe while, endwhile - you need the script to keep checking what number the groundcount is -- at at the moment I think its only checking once.
User avatar
Jay Baby
 
Posts: 3369
Joined: Sat Sep 15, 2007 12:43 pm

Post » Tue Jun 19, 2012 8:29 pm

To Everyone. The OnUpdate() event is registered for 5 secs. It runs the OnUpdate Code every 5 sec. There should be no reason that is doesn't work. I'm truly stumped.
User avatar
Richus Dude
 
Posts: 3381
Joined: Fri Jun 16, 2006 1:17 am

Post » Tue Jun 19, 2012 2:39 pm

Oh true! The way you had it set up before, it would display 'code executed' even if the stage was not set to 33.

That's what I want. I want it to display "code executed" every time the OnUpdate() function runs (That is, every 5 seconds), while the quest stage is not yet 33 (Ie. <= 23)
User avatar
Lew.p
 
Posts: 3430
Joined: Thu Jun 07, 2007 5:31 pm

Post » Tue Jun 19, 2012 6:20 pm

That's what I want. I want it to display "code executed" every time the OnUpdate() function runs (That is, every 5 seconds), while the quest stage is not yet 33 (Ie. <= 23)

Are you trying to make a countdown timer of sorts? That's what it looks like you're trying to accomplish here... well at least until the PC hits quest stage 33...

Just trying to understand why you want this as well as the how to do it.
User avatar
Trent Theriot
 
Posts: 3395
Joined: Sat Oct 13, 2007 3:37 am

Post » Tue Jun 19, 2012 7:19 pm

Yea... Been trying to hide it not to give away too much of the MOD, but what the hell.

Scriptname MOD1NODRAGONFLIGHT extends Actor{**********}Function registerforupdatefunction()	registerForUpdate(5)endFunctionint groundcount = 0Event OnInit()	registerforupdatefunction();	self.SetAllowFlying(false);endEventEvent OnUpdate()If (MOD1QPart1.GetStage() <= 32)	self.SetAllowFlying(false)		if (groundcount < 7)			groundcount = groundcount + 1			debug.Notification("IF Code Executed");		else			MOD1QPart1.SetStage(33)			debug.messagebox("ELSE Condition has been run")		endif	debug.Notification(groundcount);	elseif (MOD1QPart1.GetStage() == 33);	self.SetAllowFlying(true);	self.EvaluatePackage();	debug.MessageBox("MOD1QPart1 stage 33. ********* in the air")endifendEventActor Property MOD1Dragon1Aaz  Auto  Quest Property MOD1QPart1 Auto

This is what I have at this point. I am trying to make the actor Run a count (groundcount) while the quest stage is suchandsuch. Then at a specific ground count change the quest stage. By using Debug functions I have found out that the game does succeed in running the "else" statement, but doesn't succeed in Setting the Quest stage to 33 for some reason. I wish I could be more responsive, but I keep having to go to class, so, I can't get immediate results.
User avatar
Mackenzie
 
Posts: 3404
Joined: Tue Jan 23, 2007 9:18 pm

Post » Wed Jun 20, 2012 12:09 am

I don't see anything wrong with the script (although you should put in an UnregisterForUpdate() somewhere) and I guess you've narrowed it down to that SetStage() function...

You could try using SetCurrentStageID(), although I doubt that would make a difference. The wiki says that the functions return true if they were successful in setting the quest stage, so you might want to check for that.

Otherwise, assuming that the functions aren't broken, I think the problem is in the way you've set up the stages of your quest.
User avatar
louise fortin
 
Posts: 3327
Joined: Wed Apr 04, 2007 4:51 am

Post » Tue Jun 19, 2012 11:00 pm

I haven't looked at quests much, but here it goes.
Can't you do the inverse, instead of attaching a script to some dragons, just let the quest-script or quest-fragment-scripts handle it?
Give the quest either some Actor properties or even simpler (and more flexible) a FormList which you populate with Actors, and operate on that.
I don't see any reason why each dragon has to disallow itself every 5 seconds to fly. Especially since it can't fly to begin with - see OnInit.

Also like RandomNoob already mentioned, every RegisterForAnything call should have an corresponding UnregisterForAnything call. I mean do know when the OnUpdate event won't be executed anymore?

Rant-ish: I know that Papyrus is case-insensitive (which I really hate), but registerforupdatefunction, ignoring that this function is completely useless and adds no value at all, its just ugly...
User avatar
Alada Vaginah
 
Posts: 3368
Joined: Sun Jun 25, 2006 8:31 pm

Post » Tue Jun 19, 2012 8:05 pm

I haven't looked at quests much, but here it goes.
Can't you do the inverse, instead of attaching a script to some dragons, just let the quest-script or quest-fragment-scripts handle it?
Give the quest either some Actor properties or even simpler (and more flexible) a FormList which you populate with Actors, and operate on that.
I don't see any reason why each dragon has to disallow itself every 5 seconds to fly. Especially since it can't fly to begin with - see OnInit.

Also like RandomNoob already mentioned, every RegisterForAnything call should have an corresponding UnregisterForAnything call. I mean do know when the OnUpdate event won't be executed anymore?

Rant-ish: I know that Papyrus is case-insensitive (which I really hate), but registerforupdatefunction, ignoring that this function is completely useless and adds no value at all, its just ugly...

Well, about the unregisterforupdate(). This script is still a WIP. I knew I needed to add one, I just havn't done it yet. I just don't understand why a simple If statement isn't working. It's annoying me like crazy.


I tweaked the code... still doesn't work as intended, but so we're on the same page:

Scriptname MOD1NODRAGONFLIGHT extends Actor{Aazahzidbormah}Function registerforupdatefunction()	registerForUpdate(5)endFunctionint groundcount = 0Event OnInit()	registerforupdate(5)	self.SetAllowFlying(false);endEventEvent OnUpdate()If (MOD1QPart1.GetStage() <= 32)		if (groundcount < 7)			groundcount = groundcount + 1;			debug.Notification("IF Code Executed");			debug.Notification(groundcount);		else						MOD1QPart1.SetStage(33)			debug.messagebox("ELSE Condition has been run")					endif		elseif (MOD1QPart1.GetStage() == 33);	self.SetAllowFlying(true);	self.EvaluatePackage();	debug.MessageBox("MOD1QPart1 stage 33. Aazahzidbormah in the air")	unregisterforupdate();endifendEventActor Property MOD1Dragon1Aaz  Auto  Quest Property MOD1QPart1 Auto


Also, I should probably let you guys know that this script is kinda messy because it's a prototype. I'm trying to figure out exactly what I'm doing before I write the final script in clean fashion.

But alas, the problem remains. I have isolated it though. The "else" in the nested "if" statement works; however, for some reason "MOD1QPart1.SetStage(33)" isn't working, even though I have the property classified properly, and spelled properly.

P.S. With the case-sensitive thing, I understand. I have programmed and scripted MINOR things and a little bit on and off over many years. Sometimes I code very in a very specific form, but when I have a language like papyrus, I get lazy... That's why my C++ compiler hates me. I may get a set form and keep the ; at the end of my lines, so I don't forget 100 of them when I switch back to c++. Also, the reason for the function. I didn't want to have to cancel my register for update in the same event, as I am scripting an entire combat sequence, and I need my canceling timing to be as flexable as possible.

User avatar
Neko Jenny
 
Posts: 3409
Joined: Thu Jun 22, 2006 4:29 am

Post » Wed Jun 20, 2012 12:36 am

I'm not an expert on quests, but do you have a condition on stage 33 that may prevent it from starting?
(Not sure if that matters in this case)
User avatar
natalie mccormick
 
Posts: 3415
Joined: Fri Aug 18, 2006 8:36 am

Post » Tue Jun 19, 2012 7:39 pm

I'm not an expert on quests, but do you have a condition on stage 33 that may prevent it from starting?
(Not sure if that matters in this case)

Thank's for asking, but no.... actually...... God.... I'm so sorry everyone... I'm a stupid noob. XD

I can't believe I didn't check this before now. I forgot to even add stages over 31 *Facepalm.* Thanks for all the help though... and thanks Kreij.

I need to get more organized before I start coding something.

*Facepalm again, followed by facedesk*


EDIT: Worked Like a Charm after that... It's always the simplest things that are easiest to miss. Well everyone... thanks for your help. And Thanks Kreji for making me look at my quest stages.
User avatar
Danii Brown
 
Posts: 3337
Joined: Tue Aug 22, 2006 7:13 am

Post » Tue Jun 19, 2012 4:57 pm

I guess you are "THAT GUY". lol
I was going to ask if you had a stage 33 but I didn't want to offend you with such a basic question. DOH!

Glad you got it figured out.
User avatar
Jose ordaz
 
Posts: 3552
Joined: Mon Aug 27, 2007 10:14 pm

Post » Tue Jun 19, 2012 5:18 pm

I guess you are "THAT GUY". lol
I was going to ask if you had a stage 33 but I didn't want to offend you with such a basic question. DOH!

Glad you got it figured out.

Yea... i got in a hurry and started coding before I even made the quest stages that I was going to use as markers... sigh... I hate when this happens.

At least if it happens again that will be the first thing I check.

Things are a bit weird because I'm on a production schedule, and I'm having to do the coding for the end of the MOD before I have the rest of the quest finished. So... at this point I have a lot of empty stages.
User avatar
lilmissparty
 
Posts: 3469
Joined: Sun Jul 23, 2006 7:51 pm

Post » Wed Jun 20, 2012 4:33 am

I've been coding for many, many years. It happens to all of us. Oh the stories I could tell. rofl
Carry on, my friend, and don't hesitate to ask when you hit a wall. This is really new to a lot of us. Cheers
User avatar
Ronald
 
Posts: 3319
Joined: Sun Aug 05, 2007 12:16 am

Post » Wed Jun 20, 2012 2:25 am

I've been coding for many, many years. It happens to all of us. Oh the stories I could tell. rofl
Carry on, my friend, and don't hesitate to ask when you hit a wall. This is really new to a lot of us. Cheers

Thanks : ) Things are coming nicely.
User avatar
hannah sillery
 
Posts: 3354
Joined: Sun Nov 26, 2006 3:13 pm

Post » Tue Jun 19, 2012 5:24 pm

I got sick of being "THAT GUY".

Better yet, don't be "THAT GUY" that "GIVES UP". ;p
User avatar
A Boy called Marilyn
 
Posts: 3391
Joined: Sat May 26, 2007 7:17 am

Post » Wed Jun 20, 2012 2:58 am

So... Anybody gonna play my MOD when I'm done with it? I promise it will be at least decently cool... just dropping forum posts to get a min of brain destress.


It's a Dungeon + Quest. Fully Voice-Acted with Scenes. And some other goodies.
User avatar
Hairul Hafis
 
Posts: 3516
Joined: Mon Oct 29, 2007 12:22 am


Return to V - Skyrim