Jump to content

Scripting Help


lynxcali

Recommended Posts

Okay so in my house, I have 3 prison cells, each with their owned referenced xmarkers. I have this code:

scn aaPrison

Begin ScriptEffectStart

moveto PrisonCell1

End

But I want to make it so when you cast a spell on a target, a message box will come up asking you which cell you want to send the target to. Can anyone be so kind as to helping me make this? I would appreciate it a lot, thanks guys :)

 

My house mod can be found here:

http://www.tesnexus.com/downloads/file.php?id=37232#fileanchor

 

Finished script here:

scn aaPrisonMessageTest
short controlvar
short button
       
Begin ScriptEffectStart
if ( controlvar == 0 )
      MessageBox "Which cell would you like the prisoner to be sent to?", "Cell 1", "Cell 2", "Cell 3", "Cancel"
set controlvar to 1
endif
end

Begin ScriptEffectUpdate
       if ( controlvar == 1 )
        set button to GetButtonPressed
               if ( button == 0 )
                       moveto PrisonCell1
		  set controlvar to 0
               elseIf ( button == 1 )
                       moveto PrisonCell2
                set controlvar to 0
               elseif ( button == 2 )
                       moveto PrisonCell3
                set controlvar to 0
                             endif
       endif
end 

Edited by lynxcali
Link to comment
Share on other sites

I'm not sure if this will work since I haven't tried making a spell script so I don't know if you need to specify a target reference or not... But here's what I would try:

 

 

scriptname aaPrison


short spellcast
short menushown
short choice


Begin ScriptEffectStart

set spellcast to 1
set choice to -1

End


Begin ScriptEffectUpdate

if spellcast == 1
	if menushown == 0
		set menushown to 1
		messagebox "Which cell do you send the prisoner?" "Cell 1" "Cell 2" "Cell 3" "Cancel"
		Return
	endif
	if menushown == 1
		set choice to GetButtonPressed
		if choice == -1
			Return
		elseif choice == 0
			MoveTo PrisonCell1
		elseif choice == 1
			MoveTo PrisonCell2
		elseif choice == 2
			MoveTo PrisonCell3
		endif
		set choice to -1
		set menushown to 0
		set spellcast to 0
		Return
	endif
endif

End

 

Edited by fg109
Link to comment
Share on other sites

I'm not sure if this will work since I haven't tried making a spell script so I don't know if you need to specify a target reference or not... But here's what I would try:

 

 

scriptname aaPrison


short spellcast
short menushown
short choice


Begin ScriptEffectStart

set spellcast to 1
set choice to -1

End


Begin ScriptEffectUpdate

if spellcast == 1
	if menushown == 0
		set menushown to 1
		messagebox "Which cell do you send the prisoner?" "Cell 1" "Cell 2" "Cell 3" "Cancel"
		Return
	endif
	if menushown == 1
		set choice to GetButtonPressed
		if choice == -1
			Return
		elseif choice == 0
			MoveTo PrisonCell1
		elseif choice == 1
			MoveTo PrisonCell2
		elseif choice == 2
			MoveTo PrisonCell3
		endif
		set choice to -1
		set menushown to 0
		set spellcast to 0
		Return
	endif
endif

End

 

 

Ahh okay im going to try that. I have been trying to get this to work and here is what I have:

scn aaPrisonMessageTest
short controlvar
short button

Begin ScriptEffectStart
if ( controlvar == 0 )
      MessageBox "Which cell would you like the prisoner to be sent to?", "Cell 1", "Cell 2", "Cell 3", "Cancel"
set controlvar to 1
endif
end
Begin GameMode
if ( controlvar == 1 )
 set button to GetButtonPressed
	if ( button == -1 )
		moveto PrisonCell1
	elseIf ( button == 0)
	 	moveto PrisonCell2
	 set controlvar to 2
	elseif ( button == 1)
		moveto PrisonCell3
 	 set controlvar to 2
	elseif ( button == 2 )
		return
 	 set controlvar to 2
	endif
endif
end 

Edited by lynxcali
Link to comment
Share on other sites

Not an expert by any means, but I would think that you'd be better off having a marker in each cell (which you have), then creating a Travel package for each cell marker, then in your script, do something like:

 

target.AddScriptPackage MoveToCell3

target.EvaluatePackage

 

With, of course, "target" being a Ref to whomever is hit by the spell.

 

-Grax

Edited by Graxster
Link to comment
Share on other sites

Not an expert by any means, but I would think that you'd be better off having a marker in each cell (which you have), then creating a Travel package for each cell marker, then in your script, do something like:

 

target.AddScriptPackage MoveToCell3

target.EvaluatePackage

 

With, of course, "target" being a Ref to whomever is hit by the spell.

 

-Grax

 

Well with xmarkers, that are referenced, you can do moveto PrisonCell1, so this means

1. I placed an xmarker in my prison cell

2. I double clicked it in the render window so the menu came up

3. I gave it a reference ID PrisonCell1

So that xmarker is PrisonCell1

So when ever I say "moveto PrisonCell1" it will go to that xmarker

 

Catch what im saying?

Edited by lynxcali
Link to comment
Share on other sites

I edited my post a couple minutes after I posted it because I realized I left out an important line (set choice to GetButtonPressed). So if you used it before I edited it, that might be why it doesn't work. But if that's not the reason, I don't know what's wrong with it. There's a couple extra lines I could probably have done without but it should still have worked. Sorry I couldn't be of much help.

 

The reason why the code you posted wasn't working right was because you set it to send the NPC to prison cell 1 when button is -1. It's always at -1 until you push a button. Clicking on the first choice returns a 0, the second choice is 1, third choice is 2, etc. So with your script, the NPC is sent to prison cell 1 even before you make a decision. Also, at the end you set controlvar to 2. That means that you won't get a message box the next time you use the spell, meaning this is a one time only spell.

 

I'm also not sure you can use a GameMode block in a spell script.

Edited by fg109
Link to comment
Share on other sites

I edited my post a couple minutes after I posted it because I realized I left out an important line (set choice to GetButtonPressed). So if you used it before I edited it, that might be why it doesn't work. But if that's not the reason, I don't know what's wrong with it. There's a couple extra lines I could probably have done without but it should still have worked. Sorry I couldn't be of much help.

 

The reason why the code you posted wasn't working right was because you set it to send the NPC to prison cell 1 when button is -1. It's always at -1 until you push a button. So with your script, the NPC is sent to prison cell 1 even before you make a decision. Also, at the end you set controlvar to 2. That means that you won't get a message box the next time you use the spell, meaning this is a one time only spell.

 

Ahhh okay ill retry your code, and as for my spell I have to make button 1 for choice 1, button 2 for choice 2, button 3 for choice 3, and then button -1 for cancel? then at the end make it controlvar 1 again?

Link to comment
Share on other sites

Sorry, I don't know what's wrong with my code then.

 

For yours, the condition statement should be "if button == 0" for the first choice, "if button == 1" for the second choice, and so on. For cancel, you shouldn't even have to make an if statement. If there's no condition for when you choose cancel, then the script won't do anything, right? Just make sure that all the variables are set back to what they were before you used the spell.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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