Jump to content

Scripting Error


Funstuff of Doom

Recommended Posts

In ther process of creating mod, I've written a script that adds spells to players based on their level. Thisa is all well and good, and no errors are given when I try to save, attempting to exit the script-writing program gives me an error and asks me if I want to save 'current script ='. AS I'm unable to proceed without this script written, you can imagine how distressing this might be to me. Anyhow, the script's pasted below, I'd appreciate anyone giving a helpful pointer here or there/correcting above mentioned problem.

 

Script

 

Scriptname aafireabilityscript2

 

Begin ScriptEffectStart

 

if

(player.getlevel =< 1)

player.addspell aafirespell1

elseif

(player.getlevel =< 3)

player.addspell aafirespell1

player.addspell aafirespell2

elseif

(player.getlevel =< 5)

player.addspell aafirespell1

player.addspell aafirespell2

player.addspell aafirespell3

elseif

(player.getlevel =< 7)

player.addspell aafirespell1

player.addspell aafirespell2

player.addspell aafirespell3

player.addspell aafirespell4

elseif

(player.getlevel =< 9)

player.addspell aafirespell1

player.addspell aafirespell2

player.addspell aafirespell3

player.addspell aafirespell4

player.addspell aafirespell5

elseif

(player.getlevel =< 11)

player.addspell aafirespell1

player.addspell aafirespell2

player.addspell aafirespell3

player.addspell aafirespell4

player.addspell aafirespell5

elseif

(player.getlevel =< 13)

player.addspell aafirespell1

player.addspell aafirespell2

player.addspell aafirespell3

player.addspell aafirespell4

player.addspell aafirespell5

player.addspell aafirespell6

elseif

(player.getlevel =< 15)

player.addspell aafirespell1

player.addspell aafirespell2

player.addspell aafirespell3

player.addspell aafirespell4

player.addspell aafirespell5

player.addspell aafirespell6

player.addspell aafirespell7

elseif

player.removespell aafirespell1

player.removespell aafirespell2

player.removespell aafirespell3

player.removespell aafirespell4

player.removespell aafirespell5

player.removespell aafirespell6

player.removespell aafirespell7

endif

endif

end

Link to comment
Share on other sites

Scriptname aafireabilityscript2

 

Begin ScriptEffectStart

 

if

(player.getlevel =< 1)

player.addspell aafirespell1

elseif

(player.getlevel =< 3)

player.addspell aafirespell1

player.addspell aafirespell2

elseif

(player.getlevel =< 5)

player.addspell aafirespell1

player.addspell aafirespell2

player.addspell aafirespell3

elseif

(player.getlevel =< 7)

player.addspell aafirespell1

player.addspell aafirespell2

player.addspell aafirespell3

player.addspell aafirespell4

elseif

(player.getlevel =< 9)

player.addspell aafirespell1

player.addspell aafirespell2

player.addspell aafirespell3

player.addspell aafirespell4

player.addspell aafirespell5

elseif

(player.getlevel =< 11)

player.addspell aafirespell1

player.addspell aafirespell2

player.addspell aafirespell3

player.addspell aafirespell4

player.addspell aafirespell5

elseif

(player.getlevel =< 13)

player.addspell aafirespell1

player.addspell aafirespell2

player.addspell aafirespell3

player.addspell aafirespell4

player.addspell aafirespell5

player.addspell aafirespell6

elseif

(player.getlevel =< 15)

player.addspell aafirespell1

player.addspell aafirespell2

player.addspell aafirespell3

player.addspell aafirespell4

player.addspell aafirespell5

player.addspell aafirespell6

player.addspell aafirespell7

elseif

player.removespell aafirespell1

player.removespell aafirespell2

player.removespell aafirespell3

player.removespell aafirespell4

player.removespell aafirespell5

player.removespell aafirespell6

player.removespell aafirespell7

endif

endif

end

 

well, I see two problems:

1) (in red), you added an extra, unneeded endif.

2) (in blue), you didn't put a condition on your elseif.

Link to comment
Share on other sites

The unnamed elseif is what is giving you the error. Either add a condition or change it to "Else." Anything within the else block will run whenever none of the other if's/elseif's were triggered. Sort of like a "catch-all." The extra endif will not cause you saving errors, but it is likely that it may cause errors in the script's execution. Even if it won't, leaving it in is bad scripting form and laziness.
Link to comment
Share on other sites

The suggested fixes were applied, but the problem remains. Said problem is, attempting to exit the window used to write scripts give me a popup asking if I want to save, Current script =. Clicking yes takes me back to the window, looping the problem. Saying no exits the window, but the script is unsaved. Now, my supicion, since this has to do with saving, is that there is a naming error somewhere, but as I'm fairly inexperienced, I wouldn't know otherwise.
Link to comment
Share on other sites

The suggested fixes were applied, but the problem remains. Said problem is, attempting to exit the window used to write scripts give me a popup asking if I want to save, Current script =. Clicking yes takes me back to the window, looping the problem. Saying no exits the window, but the script is unsaved. Now, my supicion, since this has to do with saving, is that there is a naming error somewhere, but as I'm fairly inexperienced, I wouldn't know otherwise.

 

the elseif statement with no clause would definitely cause the script to not save but not give a compile error (I had this bug myself). Also it looks like your =< should actually be <=.

Link to comment
Share on other sites

  • 2 months later...
Over a month old... Yet, you just helped me. Had a fairly long script that I couldn't get to save because of an elseif on it. Someone should probably sticky this since this annoying problem is bound to come up for others.
Link to comment
Share on other sites

How often is this script run?

 

(player.getlevel =< 1)

player.addspell aafirespell1

// Yay! I'm level 1! I got this cool fire spell!

// If it's run on every lvl up, when I reach lvl 2, I would be getting the

// new firespell2 as well:

(player.getlevel =< 3)

player.addspell aafirespell1

player.addspell aafirespell2

elseif

and at lvl 3, too.

 

So, now I have:

aafirespell1

aafirespell1

aafirespell1

aafirespell2

aafirespell2

 

Is it just my too-logical-sense-and-lack-of-scripting-knowledge, or is this ... messy?

 

Why are all spells removed when the player gets above lvl 15?

Link to comment
Share on other sites

How often is this script run?

 

(player.getlevel =< 1)

player.addspell aafirespell1

// Yay! I'm level 1! I got this cool fire spell!

// If it's run on every lvl up, when I reach lvl 2, I would be getting the

// new firespell2 as well:

(player.getlevel =< 3)

player.addspell aafirespell1

player.addspell aafirespell2

elseif

and at lvl 3, too.

 

So, now I have:

aafirespell1

aafirespell1

aafirespell1

aafirespell2

aafirespell2

 

Is it just my too-logical-sense-and-lack-of-scripting-knowledge, or is this ... messy?

 

Why are all spells removed when the player gets above lvl 15?

 

The script itself is a mess, it adds fewer spells as the player levels, doubling up on them at lower levels, only removing them all after level 15. So a level 1 character would have the exact same spells as a level 15 character... I'm not sure what their intention was really. What I was referring to the reasons why it wouldn't save. Had a script that didn't want to save, spent 3 hours looking on the CS wiki, official forums, and staring at the script itself trying to figure out why. Did a search here, got the answer, I was happy.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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