Jump to content

How do i begin making an armorstand?


psrfreddyz06

Recommended Posts

You need to declare the rLinkedRef variable at the top of your script and you have an extraneous endif statement in your OnLoad block. Fixing these should allow your script to compile and save.

 

Next, it'd be best to move the linkedref code outside the reset health conditional. Otherwise that'll only work if the NPC happens to have lost health for some reason.

 

Lastly, just as general cleanup, the SetAV line is kind of redundant. Just set the base health on the NPC form instead.

 

This revised script have dealth with all of this.

scriptname 0npctest
ref rLinkedRef

begin OnLoad
    SetActorsAI 0
end

begin GameMode
    if (GetAV Health < GetBaseAV Health)
        ResetHealth
    endif
    if (rLinkedRef)
        if (GetDistance rLinkedRef > 32)
            MoveTo rLinkedRef
        endif
    else
        set rLinkedRef to GetLinkedRef
    endif
end

begin OnActivate
    OpenTeammateContainer 1
end

Also, I noticed that you prefixed the script name with a number. Prefixes are fine if it lets you find stuff quicker in the GECK, but using numbers is a bad habit to get into as scripts won't compile if you name a reference this way. There's nothing wrong with this example, though. Just consider this a heads up to make you aware of potential future problems. :smile:

Link to comment
Share on other sites

You need to declare the rLinkedRef variable at the top of your script and you have an extraneous endif statement in your OnLoad block. Fixing these should allow your script to compile and save.

 

Next, it'd be best to move the linkedref code outside the reset health conditional. Otherwise that'll only work if the NPC happens to have lost health for some reason.

 

Lastly, just as general cleanup, the SetAV line is kind of redundant. Just set the base health on the NPC form instead.

 

This revised script have dealth with all of this.

scriptname 0npctest
ref rLinkedRef

begin OnLoad
    SetActorsAI 0
end

begin GameMode
    if (GetAV Health < GetBaseAV Health)
        ResetHealth
    endif
    if (rLinkedRef)
        if (GetDistance rLinkedRef > 32)
            MoveTo rLinkedRef
        endif
    else
        set rLinkedRef to GetLinkedRef
    endif
end

begin OnActivate
    OpenTeammateContainer 1
end

Also, I noticed that you prefixed the script name with a number. Prefixes are fine if it lets you find stuff quicker in the GECK, but using numbers is a bad habit to get into as scripts won't compile if you name a reference this way. There's nothing wrong with this example, though. Just consider this a heads up to make you aware of potential future problems. :smile:

Thank you very much! Now everything is working fine, In the end i would like a "real" armor stand and not to dress up an NPC, but i do this for learning and it's so easy with all the help i get here on the forum! The only reason i named it with a number is because it's easier to find like you said, but i will stop that now to be safe in the future when making references haha!

 

I also have a hard time to understand when (and why) to use the "ENDIF" and "END", and also where to put everything. I have read the beginners guide on the GECK wiki and it doesn't really explain when to use endif. I understand the conept i think, but for example

        set rLinkedRef to GetLinkedRef
    endif
end

begin OnActivate
    OpenTeammateContainer 1
end

Why do i need the endif there and not just a normal end? since it IS the end of that function right? Cheers.

@ Jokerine Thanks to you too!!

Edited by psrfreddyz06
Link to comment
Share on other sites

Every "If" statement requires an "EndIf". You should (at least mentally) also include an "Else" between the two as well, because when an "If" statement is false, the "Else" condition will apply. If there isn't one defined, then the logic "falls thru" to the "EndIf" statement, ending the logic block. I suggest you at least put a commented "Else" (i.e. "// Else ; do nothing") there so when you look at it 6 months later you know that you at least thought about what would happen. Comments are ignored by the script compiler as they are just for the human.

 

Indenting each level of nesting "If" blocks is the way to keep track of the matching "EndIf" blocks. It's an excellent practice to (when you create an "If" line), immediately follow it with an "Else" line, and then an "EndIf" line, and then go back and insert the code in the appropriate portion. Many editors designed specifically for programmers will do this automatically.

 

In a similar way every "Begin" block requires an "End" to terminate the logic block. Without it, the script parser doesn't know where the end of that block terminates. The two forms of "End/EndIf" are not interchangeable. They mark the end of specific types of logic blocks.

 

-Dubious-

Edited by dubiousintent
Link to comment
Share on other sites

Every "If" statement requires an "EndIf". You should (at least mentally) also include an "Else" between the two as well, because when an "If" statement is false, the "Else" condition will apply. If there isn't one defined, then the logic "falls thru" to the "EndIf" statement, ending the logic block. I suggest you at least put a commented "Else" (i.e. "// Else ; do nothing") there so when you look at it 6 months later you know that you at least thought about what would happen. Comments are ignored by the script compiler as they are just for the human.

 

Indenting each level of nesting "If" blocks is the way to keep track of the matching "EndIf" blocks. It's an excellent practice to (when you create an "If" line), immediately follow it with an "Else" line, and then an "EndIf" line, and then go back and insert the code in the appropriate portion. Many editors designed specifically for programmers will do this automatically.

 

In a similar way every "Begin" block requires an "End" to terminate the logic block. Without it, the script parser doesn't know where the end of that block terminates. The two forms of "End/EndIf" are not interchangeable. They mark the end of specific types of logic blocks.

 

-Dubious-

Thank you very much!! I will keep all of that in mind when scripting, btw do you recommend any good editor that "support" fallouts scripting language? The one i use right now is notepad++ with some plugins, But I'm not really sure if it's supporting this language.. Cheers!

 

 

I suggest to have a look at this tutorial:

http://www.cipscis.com/fallout/tutorials/beginners.aspx

I will check that out thanks!

Edited by psrfreddyz06
Link to comment
Share on other sites

Notepad++ is a good choice. There is the recently released NotepadPlusPlus Syntax Highlighter "Language" Plugin for GECK editor syntax.

 

I also suggest the Top 15 Best Practices for Writing Super Readable Code HTML article. While some of those tips are for specific languages (like SQL), most apply across the board to all languages.

 

-Dubious-

Edited by dubiousintent
Link to comment
Share on other sites

  • 2 weeks later...

Notepad++ is a good choice. There is the recently released NotepadPlusPlus Syntax Highlighter "Language" Plugin for GECK editor syntax.

 

I also suggest the Top 15 Best Practices for Writing Super Readable Code HTML article. While some of those tips are for specific languages (like SQL), most apply across the board to all languages.

 

-Dubious-

thanks... I dream of one day, being able to write scripts with out my brain leaking out of my ears.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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