Need help, script seems correct, but won't compile

Post » Tue Jun 19, 2012 7:40 am

You can simplify your script by removing variables, these ...
int Recall   ;The return question box(offered when the spell has already been used once before.)int Mainbox   ;The main question box, containing all the cities to choose fromint Whiterun   ;The Whiterun locations question boxint Solitude   ;The Solitude locations question boxint Dawnstar   ;The Dawnstar locations question box
seem redundant, a single variable, maybe named dialogResult might help to iron out the logic -- less code to think about is usually a good thing.

Edit: This
function Notification...
should be a comment. I'm surprised this even compiles, since we can't add native extensions.
User avatar
Stacey Mason
 
Posts: 3350
Joined: Wed Nov 08, 2006 6:18 am

Post » Tue Jun 19, 2012 1:48 pm

I'll look into it, right now I'm trying to figure out what's causing the above issue, any ideas? I'm kinda stuck.
User avatar
Marguerite Dabrin
 
Posts: 3546
Joined: Tue Mar 20, 2007 11:33 am

Post » Tue Jun 19, 2012 10:18 am

Ok, I did it, and it works good! Ha awesome, thanks guys. But now, I gotta solve this. Basically, teleporting to Whiterun works. And I can teleport back to where I was. But when I try to teleport to ANY Solitude location, I get teleported to Whiterun == 0 location, which is WhiterunBreezehome.

Spoiler
Scriptname zSpellTomeTeleport extends activemagiceffect{Teleport to a city of your choice and then back to where you were}ObjectReference property WhiterunBreezehome autoObjectReference property WhiterunMarketplace autoObjectReference property WhiterunJorrvaskr autoObjectReference property WhiterunSkyforge autoObjectReference property WhiterunDragonsreach autoObjectReference property SolitudeMainGate autoObjectReference property SolitudeCourtyard autoObjectReference property SolitudeProudspire autoObjectReference property SolitdueBluePalace autoObjectReference property TeleTarget auto   ;The XMarkerHeading that gets recalled to players locationMessage property QuestionMSGR auto   ;Points to RecallMessage property QuestionMSGM auto   ;Points to Mainbox, containing all the cities the player is able to choose fromMessage property QuestionMSGWR auto   ;Points to Whiterun locations question boxMessage property QuestionMSGS auto   ;Points to Solitude locations question boxMessage property QuestionMSGD auto   ;Points to Dawnstar locations question boxGlobalVariable property SpellSwitch autoFunction Notification(string asNotificationText) native global   ;Used for debugging the script in gameFunction Teleport(Actor source, ObjectReference destination)			TeleTarget.MoveTo(source)		Utility.Wait(0.2)		casterRef.MoveTo(destination)		SpellSwitch.SetValueInt(1)endfunctionActor casterObjectReference casterRef  int Recall   ;The return question box(offered when the spell has already been used once before.)int Mainbox   ;The main question box, containing all the cities to choose fromint Whiterun   ;The Whiterun locations question boxint Solitude   ;The Solitude locations question boxint Dawnstar   ;The Dawnstar locations question boxint mySpellSwitchEvent OnEffectStart(Actor akTarget, Actor akCaster)  Debug.Notification("Event Begin")	caster = akCaster		casterRef = (caster as ObjectReference)mySpellSwitch = SpellSwitch.GetValueInt()if mySpellSwitch == 1	Utility.Wait(0.3)  	SpellSwitch.SetValueInt(0)	 Debug.Notification("SpellSwitch Check")	Recall = QuestionMSGR.Show()	if Recall == 0	 casterRef.MoveTo(TeleTarget)endifelse  Debug.Notification("Mainbox Appeared")Utility.Wait(0.5)Mainbox = QuestionMSGM.Show()   ;Shows the main question box containing all the cities you can choose to teleport to  Debug.Notification("Mainbox Closed");Start of locations message box partif Mainbox == 0  		 Debug.Notification("Whiterun Message Box Appeared")	Whiterun = QuestionMSGWR.Show()   ;Shows Whiterun locations question box		 Debug.Notification("Whiterun Message Box Closed")	Utility.Wait(0.2)   ;Waits 0.2 secondselseif Mainbox == 1		 Debug.Notification("Solitude Message Box Appeared")	Solitude = QuestionMSGS.Show()   ;Shows Solitude locations question box		 Debug.Notification("Solitdue Message Box Closed")	Utility.Wait(0.2)   ;Waits 0.2 secondselseif Mainbox == 2		Debug.Notification("Dawnstar Message Box Appeared")   Dawnstar = QuestionMSGD.Show()   ;Shows Dawnstar locations question box		 Debug.Notification("Dawnstar Message Box Closed")   Utility.Wait(0.2)   ;Waits 0.2 secondsendif;End of locations message box part;Start of Whiterun Locations script partif Whiterun == 0Teleport(caster, WhiterunBreezehome)elseif Whiterun == 1Teleport(caster, WhiterunMarketplace)elseif Whiterun == 2Teleport(caster, WhiterunJorrvaskr)elseif Whiterun == 3Teleport(caster, WhiterunSkyforge)elseif Whiterun == 4Teleport(caster, WhiterunDragonsreach);End of Whiterun locations script part;Start of Solitude locations script partif Solitude == 0Teleport(caster, SolitudeMainGate)elseif Solitude == 1Teleport(caster, SolitudeCourtyard)elseif Solitude == 2Teleport(caster, SolitudeProudspire)elseif Solitude == 3Teleport(caster, SolitdueBluePalace);End of Solitude locations script part	endif  endifendifEndEvent
Must have missed this post eh? XD
You need the part where you check for whiterun or solitude values to be inside the corresponding mainbox conditionals. What you're doing right now is checking the mainbox, and then disregarding that and teleporting to the first matching location out of any of them. If you select solitude, whiterun is going to still return 0. So when you check for whiterun == 0, it's going to return true.

Alternatively you could set Whiterun, etc. to invalid values when you create them.
int Whiterun  = -1 ;The Whiterun locations question box
User avatar
Amy Siebenhaar
 
Posts: 3426
Joined: Fri Aug 10, 2007 1:51 am

Post » Tue Jun 19, 2012 8:39 am

Wow, how the heck did I miss that :o Damn... All this scripting must've made me tired lol. Sorry about that. I'll try that now and see if it works, cheers mate!
User avatar
Marquis deVille
 
Posts: 3409
Joined: Thu Jul 26, 2007 8:24 am

Previous

Return to V - Skyrim