crazytechnokid Posted July 14, 2010 Share Posted July 14, 2010 First of all wow, i signed up about a day ago and already i've posted 3 questions haha. But here's my question. I've made this script and within part of it it checks to see if the player has certain items an acts accordingly (it adds that item). Because its checking around 15 item values i have to put in this basically exact same code chunk 15 times. So is there any way to set up a loop? Where i could have a variable and if that variable equals a certain number that corresponds to a reference and then adds that to the players inventory, and then at the end of the loop adds one to that variable and stops the loop when that variable hits lets say 15? Like for example it would be like this:: int counter ref item Do if counter == 0 set item to item1REF endif if counter == 1 set item to item2REF endif etc. player.addItem item 1 set counter to (counter + 1) While (counter < 16) Now i know that's more or less using java code but is there a way to do that same basic process in a GECK script? Thank you in advance for any help. Link to comment Share on other sites More sharing options...
Quetzlsacatanango Posted July 14, 2010 Share Posted July 14, 2010 I don't understand exactly what you're going for, but that thing converted to GECK script would look something like: scn myscriptname int counter ref item Begin GameMode If counter < 16 if counter == 0 set item to item1REF endif if counter == 1 set item to item2REF endif etc. player.addItem item 1 set counter to (counter + 1) endif End You will want to have another variable to set so that the script doesn't cycle over and over again and just keep adding items (that's what it will do as-is). Without the context it's hard to say what that should be.You would probably want to change all the endif/if combos into elseifs as well but I would think it would work the same either way. Link to comment Share on other sites More sharing options...
crazytechnokid Posted July 14, 2010 Author Share Posted July 14, 2010 What i'm basically trying to do is scan a list of items, if any of the items are enabled they are added to the players inventory. But the problem is i'm doing this for multiple items which makes the script unnecessarily long, while i could acomplish the same thing with much less code in a loop. The code im using to scan the items and act accordingly is this :: if WRWChineseAssualtREF.getDisabled != 1 player.addItem weapChineseAssaultRifle 1 WRWChineseAssualtREF.Disable 1 endif if WRW10mmPistol.getDisabled != 1 player.addItem weap10mmPistol 1 WRW10mmPistolREF.Disable 1 endif etc. etc. for each item Now i have to do this for each and every item, Is there a shorter way to do it? Like a loop? I get the code you posted but i don't quite know how to make the script start back at the top of that if statement you posted when it gets to the bottom of that if statement. Link to comment Share on other sites More sharing options...
pkleiss Posted July 14, 2010 Share Posted July 14, 2010 The only true loop function is the 'label/goto' used with FOSE. You would have to install FOSE to get that functionality as the vanilla game does not support true loops. Link to comment Share on other sites More sharing options...
crazytechnokid Posted July 14, 2010 Author Share Posted July 14, 2010 Alright I have FOSE, so would I be able to do something like this? label allLoop If counter < 16 if counter == 0 set item to item1REF elseif counter == 1 set item to item2REF elseif etc. player.addItem item 1 set counter to (counter + 1) goto allLoop endif Link to comment Share on other sites More sharing options...
HugePinball Posted July 15, 2010 Share Posted July 15, 2010 The LabelID must be an integer, but otherwise that looks fine. Check out Cipscis.com - he recently published a new tutorial on loops and how various types of loops would be translated into GECK script. Link to comment Share on other sites More sharing options...
Cipscis Posted July 15, 2010 Share Posted July 15, 2010 Thanks for the mention HugePinball. The tutorial itself isn't new, but the examples that I've included at the end are. In that tutorial I've included code for converting common loop structures, like "do while" loops, into the Fallout 3 equivalent. Cipscis Link to comment Share on other sites More sharing options...
crazytechnokid Posted July 15, 2010 Author Share Posted July 15, 2010 Thanks a lot HugePinball for the link, that is exactly what i've been looking for, and thanks Cipscis for the tutorial and examples. Oh and yea i forgot the label had to be an integer when typing that, i realized after posting that it was like writing a .bat file but was to lazy to change that one thing xD. Again thanks everyone for the help, I finally finished the script =). Link to comment Share on other sites More sharing options...
Recommended Posts