Chemist18 Posted March 29, 2009 Share Posted March 29, 2009 I'm new to scripting in Fallout 3, I never played Oblivion or FO1 or FO2. I have however programmed in VBA, FORTRAN, and COBOL (giving up my age). The script I'm working on is for the player house I built. I always accumulate lots of crap as I play. I thought it would be great to have a bin I could throw all the stuff in and make that obnoxious robot sort everything into separate containers. I created a number of uniquely named containers. As an example of the script: Container named 'PlayerJunkDump' with a container named "ContDetergent" Script: Set ItemCount to PlayerJunkDump.GetItemCount BoxDetergentContDetergent.Additem BoxDetergent ItemCountPlayerJunkDump.RemoveItem BoxDetergent ItemCount Set ItemCount to PlayerJunkDump.GetItemCount PilotLightContShishkabab.Additem PilotLight ItemCountPlayerJunkDump.RemoveItem PilotLight ItemCount .... Well this worked great when all the boxes were empty. BUT if I put stuff in the box, run the script, everything is fine, then add a second batch of stuff to the junk box, run the script, the only items in the boxes are those from the second batch. So I edited the script to look something like this Script: Set ItemCount to PlayerJunkDump.GetItemCount BoxDetergentSet ExistingCount to ContDetergent.GetItemCount BoxDetergentSet TotalCount to ExistingCount + ItemCountContDetergent.Additem BoxDetergent TotalCountPlayerJunkDump.RemoveItem BoxDetergent ItemCount Set ItemCount to PlayerJunkDump.GetItemCount PilotLightSet ExistingCount to ContShishkabab.GetItemCount PilotLightSet TotalCount to ExistingCount + ItemCountContShishkabab.Additem PilotLight TotalCountPlayerJunkDump.RemoveItem PilotLight ItemCount Now the stuff just dissappears from the junk box. Will someone help me out with my logic please? Link to comment Share on other sites More sharing options...
Interfer0 Posted March 29, 2009 Share Posted March 29, 2009 If you use the codebox tags located on the side of the page it will make your code indentable, and much easier to read. Link to comment Share on other sites More sharing options...
Chemist18 Posted March 29, 2009 Author Share Posted March 29, 2009 Those lines would all be indented in groups of 5 as I typed them, however, if these's a style that will enable you to help me more I'll be happy to try it. I usually set up like this Begin GameMode Set Variable1 to Container.GetItemCount ComponentX Set... Set Variable1 to Container.GetItemCount ComponentY Return End However, essentially my reasoning was this: 1) find out how many of an item is in the junk container then add that many to the specific container I had assumed that .Additem would work the same in scrip as it does in the console, that it would literally add that many MORE items, but it appears to delete the contents then add the new amount. 2) so I set up three variable, 1 for number of items in junk box, 1 for the number of items in the specific container, and third to hold the total of the two, then .additem to the container I'm sure it's something very simple that I don't know about scripting for FO3... Link to comment Share on other sites More sharing options...
TGBlank Posted March 29, 2009 Share Posted March 29, 2009 For visibility's sake, code is better seen inside code tags, like this:Set ItemCount to PlayerJunkDump.GetItemCount BoxDetergent Set ExistingCount to ContDetergent.GetItemCount BoxDetergent Set TotalCount to ExistingCount + ItemCount If it's a full code or otherwise contains nesting, then it should also be idented.Now, as suggestion, strip the code to only 1 item (say, detergent boxes), and use messages to show just how many is it trying to add. If you're using FOSE, printc would make this debug part a lot easier. Link to comment Share on other sites More sharing options...
Chemist18 Posted March 29, 2009 Author Share Posted March 29, 2009 I'm used to a language where I can loop my way through stuff so readability is a lot easier to accomplish. Not using FOSE. I will take your advice and use messages to track the routine's activities. Thanks :) Link to comment Share on other sites More sharing options...
Chemist18 Posted March 29, 2009 Author Share Posted March 29, 2009 Well I have the script working now and as usual it was something silly and obvious (I think) I had put the script inside 'Begin GameMode' rather than 'OnActivate'. I guess the script shouldn't run 100 times a second. DOH! Not sure why the numbers would change regardless of how frequently the script checks them. Perhaps it was tired and wanted to get back at me for my carelessness? :) Thanks. Link to comment Share on other sites More sharing options...
John Woods Posted March 30, 2009 Share Posted March 30, 2009 Chemist - yep you dated yourself there with Cobol and Fortran.. This house mod you are working on are you going to release it or is it personal only? Reason I ask is I cannot find a suitable house mod not in Megaton that includes a SORTER. I hate sorting manually takes way too long.. Thanks JW Link to comment Share on other sites More sharing options...
Chemist18 Posted March 30, 2009 Author Share Posted March 30, 2009 Chemist - yep you dated yourself there with Cobol and Fortran.. This house mod you are working on are you going to release it or is it personal only? Reason I ask is I cannot find a suitable house mod not in Megaton that includes a SORTER. I hate sorting manually takes way too long.. Thanks JW I currently have a house mod on Nexus, MegatonSuburbHome. Once I'm confident the sorter is fairly robust I can add it to that listing. Right now it's my plan to make the obnoxious robot trigger the script but I may just stick a switch on the wall instead :). It seems to be working okay so far. I'm adding more items to what it will sort. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.