Jump to content

Help, NVSE giving invalid begin/end block error.


haretz

Recommended Posts

I'm trying to recompile scripts, but NVSE gave me an invalid begin/end block error on line 15, here it is. Any help as to what it means or how to fix it? Thanks for any help in advance.

scn aaaV101FactionScript

Begin OnStartCombat
	if IsCombatTarget Player
		Player.removeFromFaction aaaVault101Friend
		SetEnemy aaaVault101Faction PlayerFaction
	endif
End

; <comment>Begin GameMode
; <comment>   if (IsInCombat) && (isCombatTarget player)
; <comment>      player.removeFromFaction aaaVault101Friend
; <comment>      SetEnemy aaaVault101Faction PlayerFaction
; <comment>   endif
; <comment>End
Edited by haretz
Link to comment
Share on other sites

Actually, line 15 seems to be that very last ;End. Is it safe to just remove?

I also came across a new error in the following, it says "Invalid variable name posioned"

scn aaaVtDOTScript

short aaaVtpoisoned
float timer

Begin GameMode
	if aaaVtpoisoned == 1
		if timer > 0
			set timer to timer - GetSecondsPassed
		else
			Player.DamageActorValue Health 20
			set timer to 1
		endif
	endif
End
Edited by haretz
Link to comment
Share on other sites

First: please learn to indent your code and use the blue "<>" icon to post code in the forum. That will preserve your indentations, making it much easier for us to tell what you intend your code to be doing. More complex code can quickly become unreadable otherwise. Use at least two spaces for indentation if you don't use "tab" characters.

 

Second: your first posted code did not have anything obviously wrong with it. Which is why no one answered as they had no suggestions to make. However, it now appears you did not realize that the semi-colon (";") signals that everything following it is a "comment" which is ignored by the compiler. Personally i make it a habit to use a "; <comment>" with all mine for readability, but have no reason to believe that is required. Your problem suggests it might be. The line parser generally treats whitespace characters as separators.

 

Third: Just guessing but as you have declared the variable "poisoned", it should work unless the error is because that variable name is "reserved" by the game engine. It's often helpful to use a prefix to variable names that reminds you as to the correct "type" of variable, such as "ipoisoned" (i = Integer, aka short type), "ftimer" (f = float type), "sMsg" (s = string type), etc, and that should be enough to differentiate it from the reserved word. You can also prefix them with the initials of your mod (e.g. "aaaVtpoisoned") or similar.

 

Fourth: What do you intend to happen if NOT "poisoned == 1"? You should at least consider placing a comment where an "else" line would be whenever you have an "If" block so you know that you considered that circumstance and what you intend should happen. Six months from now you will be wondering what you were thinking and if it is still a valid assumption.

 

-Dubious-

Link to comment
Share on other sites

1: Got it. I'll make sure to include that in any further queries

2: Noted, it recompiled successfully after doing that.

3. Prefixed the variable both times it appeared, hope that's right.

4: I've actually been trying to convert this as a mod for another, larger, mod called "Tale of Two Wastelands," which combines Fallout New Vegas and Fallout 3, so it's actually a Fallout 3 mod that's I'm converting with FNVEdit and Geck. After making the second post, I realized that there's a forum for Tale of Two Wastelands and posting it here was probably pretty stupid of me. Quite honestly, I have pretty little knowledge of making complex scripts in GECK, even after following the tutorial, so I'm not quite sure what the original mod author really had in mind to happen if not poison==1. Thanks once again for assisting me with my complete cluelessness with GECK though!

Link to comment
Share on other sites

Re: prefixes. Yes, you need to use the same prefix everywhere that word appears or they are treated as separate words. Technically "words" are a string of "display/printing characters" (including mixed alphanumerics and punctuation marks) immediately adjacent to each other until separated by a "whitespace character". A "whitespace character" is one which displays the same as one or more "spaces", and can include any "non-printing" character such as a "Tab" (<Tab>), "Carriage Return" (<CR>), "Line Feed" (<LF>), or "End Of Line" (<EOL>) hex character.

 

Re: Converting scripts. If the original author didn't comment their code well, it can be quite difficult to interpret. New programmers in business are usually started off "maintaining/fixing" older code so they gain an appreciation for the value of comments. Especially when up against deadlines.

 

In the case of an IF ...(ELSEIF) ... (ELSE) ... ENDIF" block, the code under the "IF" is only processed when all the "IF" conditional tests are "true". If they are not, the script engine drops down looking for either an (optional) "ELSEIF" or (optional) "ELSE" line, or treats the first (remaining, not previously encountered) required "ENDIF" as the end of the block. Lining up the beginning and end lines of code blocks to tell which belongs with which is the primary reason for indentation. Otherwise it becomes difficult to tell when you are missing one. Which was essentially your problem in your first post: it thought it had the beginning of a block without an ending, when they were intended to be ignored completely.

 

Consequently that code simply "drops out" if "poisoned" is not equal to 1, and does nothing. Sort of obvious what the effect is, but not necessarily the "why" of it. When converting, don't be afraid to add comments as you work things out. It's not uncommon for the number of lines of comments to exceed the number of lines of actual code. You might want to take a look at the "Tips" in the "Scripting" section of the wiki "Getting started creating mods using GECK" article.

 

Everyone has to start somewhere. Keep plugging away at it. We're here to help.

 

-Dubious-

Link to comment
Share on other sites

  • Recently Browsing   0 members

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