Jokerine Posted January 23, 2017 Share Posted January 23, 2017 You gotta write something like "ref rLinkedRef" at the beginning of your script, after the name. This way the script will know that it's dealing with a new reference. Link to comment Share on other sites More sharing options...
Ladez Posted January 23, 2017 Share Posted January 23, 2017 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 More sharing options...
psrfreddyz06 Posted January 23, 2017 Author Share Posted January 23, 2017 (edited) 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 January 23, 2017 by psrfreddyz06 Link to comment Share on other sites More sharing options...
dubiousintent Posted January 23, 2017 Share Posted January 23, 2017 (edited) 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 January 23, 2017 by dubiousintent Link to comment Share on other sites More sharing options...
Deleted1205226User Posted January 23, 2017 Share Posted January 23, 2017 I suggest to have a look at this tutorial:http://www.cipscis.com/fallout/tutorials/beginners.aspx Link to comment Share on other sites More sharing options...
dubiousintent Posted January 23, 2017 Share Posted January 23, 2017 I suggest to have a look at this tutorial:http://www.cipscis.com/fallout/tutorials/beginners.aspxNice. Added to the list of tutorials. -Dubious- Link to comment Share on other sites More sharing options...
psrfreddyz06 Posted January 25, 2017 Author Share Posted January 25, 2017 (edited) 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.aspxI will check that out thanks! Edited January 25, 2017 by psrfreddyz06 Link to comment Share on other sites More sharing options...
dubiousintent Posted January 25, 2017 Share Posted January 25, 2017 (edited) 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 January 25, 2017 by dubiousintent Link to comment Share on other sites More sharing options...
JoKelly Posted February 3, 2017 Share Posted February 3, 2017 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 More sharing options...
Recommended Posts