StealthDick Posted March 30, 2018 Share Posted March 30, 2018 is it okay if i use the same blocktype multiple times? I've been trying to keep runing on with the same gamemode block and stuff just ends up not working. example 1begin Gamemode ; some scriptendifendbegin Gamemode ; some scriptendifendbegin Gamemode ; some scriptendifend Is this okay or should I try to do: example 2begin Gamemode ; some scriptendif ; some scriptendif ; some scriptendif ; some scriptendif ; some scriptendifend I've been trying to do something like example 2 but its a hit or miss most of the time. Link to comment Share on other sites More sharing options...
EPDGaffney Posted March 30, 2018 Share Posted March 30, 2018 Post your script and I'll fix it up for you. It's easier to read and put back into the GECK if you use the code format, which is the blue < > symbols on the toolbar just above your comment text box. But it's not a problem to use the same blocktype multiple times in a script. I've had to do it more than a few times, as some things just don't work in this engine the way they're supposed to do, and 'staggering' the code a bit sometimes helps. Usually, however, there are a number of reasons that practise is best avoided, so let's have a look at your script to make sure we know what we're doing. If you use GECK PowerUp, it will proofread your script and catch a lot of stuff for you. Link to comment Share on other sites More sharing options...
StealthDick Posted March 30, 2018 Author Share Posted March 30, 2018 (edited) Heres my script: Begin Gamemode If (bNCRLeaderDead == 1 && bDoOnce01 == 0) set fFinaleState to 6 ZekeREF.addscriptpackage aaaPowderGangerAmbush PowderGangerSpawnREF.enable ZekeREF.evp set bDoOnce01 to 1 else endif endif END the script above works perfect alone. But once I add this under it: Begin Gamemode if (NCRBrahmin01REF.getdead 1) && (NCRBrahmin01REF.getdead 1) && bDoOnce02 == 0 rewardxp 1000 set bNCRLoot to 1 set bDoOnce02 to 1 endif END It wont work even though they are in separate blocksthe rewardxp 1000 is there so I know if the script works, however it hasnt Edited March 30, 2018 by StealthDick Link to comment Share on other sites More sharing options...
StealthDick Posted March 30, 2018 Author Share Posted March 30, 2018 (edited) Its 7:42PM for me right now and I've been trying to get these to work for the past 5 hours.I haven't even added anything either. It makes me want to die. Edited March 30, 2018 by StealthDick Link to comment Share on other sites More sharing options...
EPDGaffney Posted March 30, 2018 Share Posted March 30, 2018 (edited) I know how you feel. It will get easier, but you will probably continue to run into stuff like this. I have to recommend PowerUp again if you're spending hours at a time on one script not knowing what's wrong. Give me your whole script, and I'll make it nice and neat, but your major problem appears to be that that GetDead line should be written with an operator: if (NCRBrahmin01REF.getdead == 1) && (NCRBrahmin01REF.getdead == 1) && bDoOnce02 == 0or even with nothing: if (NCRBrahmin01REF.getdead) && (NCRBrahmin01REF.getdead) && bDoOnce02 == 0and if there's a difference between the two Brahmin references, my eye is not catching it, so: if (NCRBrahmin01REF.getdead) && bDoOnce02 == 0and finally, I avoid && and || expressions as a rule, because they're buggy in certain situations, but your script should have compiled; still: if (NCRBrahmin01REF.getdead) if bDoOnce02 == 0Correctly indented and all together, it looks like: Begin Gamemode if (NCRBrahmin01REF.getdead) if bDoOnce02 == 0 rewardxp 1000 set bNCRLoot to 1 set bDoOnce02 to 1 endif endif ENDIndenting correctly can help you to see your mistakes much more easily with nested conditions like this. If you didn't catch it, I had to add another endif. Also, unless you have a good reason, I don't see why you want this to be a GameMode script. I avoid those where I can as well. But again, your script should still compile, so that was not your problem. Edit: Again, without the whole script, I'm forced to assume certain things, like all your variables are declared in this script, in the right place, and you have them all typed correctly. If they are from a different script, you need to include the name of the reference they're attached to if it's a reference, or the quest it's attached to if it's a quest. Also, is that Brahmin a persistent reference? That could have been your problem as well. Edited March 30, 2018 by EPDGaffney Link to comment Share on other sites More sharing options...
StealthDick Posted March 30, 2018 Author Share Posted March 30, 2018 (edited) removed to avoid spoilersif (NCRBrahmin01REF.getdead == 1) && (NCRBrahmin01REF.getdead == 1) && bDoOnce02 == 0^^^^^^^^^^this helped me, it was all because I was writing it as NCRBrahmin01REF.getdead 1 opposed to NCRBrahmin01REF.getdead == 1 thanks for all the help man. When I finish my mod I'll send you a file to test if you want. Edited March 30, 2018 by StealthDick Link to comment Share on other sites More sharing options...
EPDGaffney Posted March 30, 2018 Share Posted March 30, 2018 (edited) Actually, most of that looks really organised, so well done there. Here's the whole script: scn aaaToledoDialogueScript short bQuestState ; 0 = quest hasnt started, 1 = has caravan schedule, 2 = returning to toledo (1st), 3= going to caravan, 4= returning to toledo [2nd], 5 short bDiscount; 0 = no discount, 1 = yes discount short bPlayerNo short cPlayerhasHE; 0 = player doesnt, 1 = player does short cKillBronald; 0 = toledo doesnt know about spy, 1= toledo wants him dead, 2= bronald is dead short bHEChoice; 0 = player hasn't gave the HE to anyone, 1 = toledo, 2 = bronald short bDoOnce01 short bDoOnce02 ; Finale Shorts short fFinaleState; 0 = Not finale yet, 1 = finale quest start, 2 = set charges, 3 = charges set, 4 = player goes to sleep short fZekeAmbushSpot short bMinesPlaced; 0 = not placed, 1 = 7 placed, 2 = 3 placed short bNCRLeaderDead; 0 = alive, 1 = dead short bNCRLoot; 0 = no loot, 1 = loot brahmin ; Bronald's shorts short cBronaldTalkedPlayer short cBronaldTruth; 0 = player doesnt know, 1 = player knows short cBronaldBarter; 0 = player didnt barter, 1 = player bartered short cBronaldTrust; 0 = player didnt spill, 1 = still hasnt spilled but ended dialogue, 2+ = player talked ; -=Finale Script=- Begin Gamemode If (bNCRLeaderDead) If (bDoOnce01 == 0) set fFinaleState to 6 ZekeREF.addscriptpackage aaaPowderGangerAmbush PowderGangerSpawnREF.enable ZekeREF.evp set bDoOnce01 to 1 ; else -- I've commented out this line and would delete it if you aren't using it. endif endif ; Brahmin Stuff. if (NCRBrahmin01REF.getdead) if (NCRBrahmin02REF.getdead) if bDoOnce02 == 0 rewardxp 1000 set bNCRLoot to 1 set bDoOnce02 to 1 endif endif endif END Does the second one not work or what? Edited March 30, 2018 by EPDGaffney Link to comment Share on other sites More sharing options...
EPDGaffney Posted March 30, 2018 Share Posted March 30, 2018 So, I forgot to ask you what are the variable names about. These lowercase letters that go before a capitalised variable name, these letters denote a specific programming use for that variable. b - A bool is a variable that can be only true (set to 1) or false (set to 0). We don't have true bools in this programming language, but variables that a programmer knows will only ever be set to true or false can be referred to as a bool and its name can be chosen accordingly for organisational purposes. They are technically the short/integer variety.Example: short bFoundJohn int bFoundJohnf - a float is a variable that can store numbers that are in between integers. Essentially, numbers that can have decimals. Some functions will return a number that is in between two integers, and if you want to store that value as a variable for use in your script, it generally must be declared as a float variable. A popular one is GetSecondsPassed, so for example: float fTimeri - an int variable is the same as a short variable, but we only use the 'i' prefix so that we can use the 's' prefix to denote a string variable, which we'll talk about in a minute. Int/short variables can only be integers, or whole numbers. If you try to use one to store a value that should be a float, it may round down to the nearest whole number or it may just not work. These are the most common variables for our use.Example: int DoOnce int iDoOnce int bDoOnce short DoOnce short iRaidersKilled ; (probably the number of raiders player killed) int bRaidersKilled ; (probably if the player's killed all the designated raiders, or if they've killed at least one, depending on what you want)s - a string variable is a weird one. It's text, and requires special treatment. It tends to be stuff the scripting language doesn't really understand and just takes on faith that you do. You probably won't work with these for a while.Example: string_var sDogName ; whatever the player typed for a dog's name at some point in your quest, so that it can appear in notes string_var sBone ; whatever bone/node in the .nif model is relevant to the script for whatever reasona - array variables are incredible, and I will probably try to get you to use them sooner than you'll feel comfortable doing if you keep asking questions in this forum. It's a steep learning curve but they're easy once you've passed that. They are basically like form lists, but they are made dynamically at run-time via script.Example: array_var aNCR ; maybe every actor in the area that is in an NCR faction, or maybe every NCR actor in the entire game, including all loaded mods array_var aEntry ; this is a standard array variable that could be called anything and still work, ; but it's typically the name given to a short-lived variable that is used during ; any number of operations carried out on the larger array that contains all the ; stuff in the group you're working onr - reference variables store a reference. This is often an actor or a specific object that you'll need to refer to later in your script.Example: ref rSelf ; often used in GetSelf operations for functions that may require it, like some uses of PushActorAway or KillActor ref rTarget ; often the choice for functions like GetOwnerLastTarget ref rBrahmin ; probably whatever Brahmin that happened to be in the wrong place at the wrong time when your script found her (are they all ; female? have to google that...)Hope that's useful for you. Link to comment Share on other sites More sharing options...
StealthDick Posted March 31, 2018 Author Share Posted March 31, 2018 this is all really helpful thank you Link to comment Share on other sites More sharing options...
dubiousintent Posted March 31, 2018 Share Posted March 31, 2018 Everything EPDGaffney has been telling you is right on the money. But I didn't see him address your original "title" question or correct the mistake I saw in your original script example. For the benefit of others I would like to address that. Your original example "pseudo-code" was: example 1 begin Gamemode ; some script endif end begin Gamemode ; some script endif end begin Gamemode ; some script endif end The "block etiquette" in question is that each "Begin" statement must have a corresponding "End" statement. Similarly each "If" statement must have an "EndIf" statement. (Case doesn't matter except for "readability". "EndIf" and "endif" are equivalent.) There are similar rules for other sorts of "code-blocks" such as "While ... Do" loops, etc. A clear "beginning statement" and matching clear "terminating statement" are what defines a "code-block". Indenting nested "code-blocks" so the beginning and ending block statements of each block are in the same column makes it much easier to determine that there is a matching terminator for each beginning statement. (Mismatched "statement pairs", such as missing the "closing parens" to match the "opening parens", are the most common coding errors. Consider mixing case styles to help identify pairs of deeply nested or widely separated blocks.) So the "Begin" block was properly terminated in your example. But you have extraneous "EndIf" lines without their beginning "If" lines. This creates an unbalanced conditional "If ... EndIf" block, and an error. This might not have been the actual case in the situation of the "; some script" pseudo-code lines, but their presence suggests a lack of understanding of their role and needs to be corrected. The appearance is that every "; some script" pseudo-code block began with an "If" statement. While this is the most common sort of code-block, it's not the only possibility and not a good idea to assume such. A better example of "pseudo-code" would have been: ; If (condition) ; (indented) condition=true processing ; Else (which like "ElseIf" is optional, but should always be considered) ; (indented) condition=false processing ; EndIf or simply: ; some code blockHope this clarification is of some help. [Edits for clarity.] -Dubious- Link to comment Share on other sites More sharing options...
Recommended Posts