Jump to content

Bad script


Recommended Posts

I'm working on kinda simple but kinda hard mod where you can teleport to a few diffent places and i read a tutorial at http://cs.elderscrolls.com/index.php/Scripting_Tutorial:_My_Second_Script#Begin_and_End and the following script is what i thought would work but it keep saying theres errors and i fix one then theres another one to fix, and of course i'm a noob at scripting so any help would be greatly appreciated, and will be reward with a thanks in its credits if or when i upload it.

 

 

 

ScriptName Teleport

 

Begin ScriptEffectStart

if ( controlvar == 0 )

MessageBox "Choose a Destination", "chorrol", "Bruma", "Cheydinhal", "Anvil", "Bravil", "Kvatch", "Skingrad", "Leyawin", "Imperial City Palace", "Home", "Death", "Suprise"

set controlvar to 1

elseif ( controlvar > 1 )

activate

endif

end

 

begin gamemode

if ( controlvar == 0 )

set button to player.MoveTo "achorrolmarker"

elseif ( button == 1 )

set button to player.MoveTo "abrumamarker"

elseif ( button == 2 )

set button to player.MoveTo "aanvilmarker"

else if ( button == 3 )

set button to player.MoveTo "abravilmarker"

else if ( button == 4 )

set button to player.MoveTo "akvatchmarker"

else if ( button == 5 )

set button to player.MoveTo "abskingradmarker"

else if ( button == 6 )

set button to player.MoveTo "ableyawinmarker"

else if ( button == 7 )

set button to player.MoveTo "aicpalacemarker"

else if ( button == 8 )

set button to player.MoveTo "abhomemarker"

else if ( button == 9 )

set button to player.MoveTo "adeathmarker"

else if ( button == 10 )

set button to player.MoveTo "acheydinhalmarker"

else if ( button == 11 )

set button to player.MoveTo "asuprisemarker"

endif

end

 

:psyduck: :wallbash:

o_O :ohdear: :ohdear:

Link to comment
Share on other sites

Well, for starters, so we get the surrounding framework right, is this a Spell (you cast on yourself) or an Activator (like a button or a door)?

 

If it's "not" a Spell script, "ScriptEffectStart" blocks can't exist. If it's an Activator, you do it through an "OnActivate" block, or to limit to the player only via "OnActivate player".

 

The "activate" call inside "ScriptEffectStart" doesn't make much sense. What's to be activated here? It tries to activate the object the spell is affecting, but what object is this? And why should it be activated?

 

You just open the MessageBox when the block starts and via "set controlvar to 1" you initiate the checking for its return value, the button that was pressed.

 

MessageBox results can't be processed in "GameMode". While a MessageBox is open you're in "MenuMode". GameMode blocks won't run.

 

There's a mix-up with "controlvar" and "button" at the start of your result processing block. There needs to be a "if controlvar == 1" block around everything, as these checks shall only run when the MessageBox was opened previously. "Inside" this you then do the checks for the return values.

 

Also you're missing the mandatory "set button to GetButtonPressed" line which parses the button pressed into the "button" variable here. Your script can't evaluate the button pressed from an "empty" variable.

 

According to the WiKi "MoveTo" doesn't have a return value. "set button to player.moveTo ..." doesn't make sense. You simply call "player.MoveTo XYZ". You also don't use quotes around the EditorIDs you're using there. They're just like global variables known by every script.

 

I'm not sure whether it should be "MoveTo" or "MoveToMarker" rather here. I think if it's actually markers you set somewhere in the world, then "MoveToMarker" would be the better choice.

 

So let me see if I can't get this straightened out a little for you. I'll just assume this is a spell, cast on yourself, which will open the MessageBox and send you to the location you choose.

 

ScriptName Teleport

; never forget to declare your variables!
short controlvar
short button

Begin ScriptEffectStart

   if controlvar == 0 ; only do the message box popup when not already open
       MessageBox "Choose a Destination", "chorrol", "Bruma", "Cheydinhal", "Anvil", "Bravil", "Kvatch", "Skingrad", "Leyawin", "Imperial City Palace", "Home", "Death", "Suprise"
       set controlvar to 1 ; enable processing of return value
   endif

End

Begin MenuMode

   if controlvar == 1 ; only process return value when there actually is a message box open
       set button to GetButtonPressed ; obtain last button pressed, if any, starting from 0, -1 means not yet pressed a button
       if button == 0
           set controlvar to 0 ; stop processing
           player.MoveToMarker achorrolmarker ; I trust on this marker to actually exist and have this exact "persistent reference" ID now
       elseif button == 1
           player.MoveToMarker abrumamarker
           set controlvar to 0 ; stop processing
       endif ; 2 for example, add in the other return values yourself
   endif

End

That should work.

If it doesn't, let me know, and give me more information about the surrounding setup, what type of script this is, how it is triggered, whether you created the markers, if the actually are markers, and if they have the proper persistent reference ids placed into the world or not, etc. etc.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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