Dillenger69 Posted April 22, 2017 Share Posted April 22, 2017 Is it possible to place new references with FO4edit, or just copy and manipulate existing ones? What I'm doing, or trying to do, is place lights at a series of x/y/z coordinates. If it were possible for the script runner to do 2 passes, I could get the existing light and copy it where I need it. But, it doesn't look like there's a way to do muti-pass scripting. I suppose I could write a script that prints out all the variables for each light as code then copy/paste that into script #2 that finds the original light reference to copy ... then see if it lets me replace the cell and x/y/x coords and save the new records. I've looked at scipt sources. It doesn't look like anyone's tried to do what I'm doing, I'm not even sure it's possible with FO4edit. If anyone out there knows, advice is appreciated. Link to comment Share on other sites More sharing options...
VIitS Posted April 23, 2017 Share Posted April 23, 2017 It's definitely possible with FO4Edit, though I don't know of any FO4Edit scripts that would do so. I'm pretty sure it would even be possible to make it pull the base record and location/rotation data from an excel sheet. No idea why you would need to do two passes, even if you want to have it duplicate an existing placed reference rather than the base record, you could have it do so then change the coordinates (you could set a value, or change it by a certain amount). FO4Edit uses a different scripting language (Pascal) than the game though, so keep that in mind. I'd recommend looking at matortheeternal's Automation scripts for learning how to do what you want. It might even have what you need, I haven't looked at everything they can do. What exactly are you trying to do, anyway? Move them all by a certain distance? If that's the case, why do you want to make new records instead of editing the existing ones? In any case, it would be much easier, rather than having a single script that does everything, to select all the lights you want to duplicate, then use the "Copy as New Record" feature*, then have your script just edit the coordinates (and change the cell it is considered to be in). You could also write a script (separate, or have that part run before the editing part, and have it make the same sort of list** as mator's scripts do for bulk modification) that finds all the light records in the selected cell(s), but it would be easier to just sort by name, then select the different light records. Probably less time overall, as well, depending on whether or not you know any scripting languages (i.e. depending on how long it takes you to figure out what you need to do). *Copy as override then change FormID would work too **My formlist script uses the kind of thing I mean, though it generates the same sort of list (array might be a better term, not sure) based on what you have selected. If you wanted it to find the lights for you, you'd just need to have it build the list differently, but I believe that is the kind of list you would want. Then just have it modify the coordinates as needed Link to comment Share on other sites More sharing options...
Dillenger69 Posted April 23, 2017 Author Share Posted April 23, 2017 I've got a script to find forms, that's not a problem. I also have a script to do bulk operations. Essentially I want to add lighting to my mod. There's one particular light 'DefaultLightWaterGlowingSea01NSCaustics [LIGH:00204273]' from the glowing sea that I want to populate the landscape with, placing them where the trees used to be (I've already removed those and successfully redone the world LOD, that's whole other saga). I've been programming in various languages since 1979 ... Pascal hasn't been that tough to pick up. I'm only sorry the scrips can't take full advantage of what pascal can do.How do I copy a form without the main Process loop needing to hit it and get passed in? If I could get that one record or make one from scratch(tried that and failed, not sure why yet), I could use the main process loop to get the x/y/z/cell and place all the lights. Link to comment Share on other sites More sharing options...
zilav Posted April 23, 2017 Share Posted April 23, 2017 It is unclear what do you want exactly. if to duplicate some existing refs as new records and change their data, then what VIits said would work. If to create a plugin from scratch using spreadsheet data, then you'll need to create new refs and set their fields according to spreadsheet. There are example scripts on how to read csv files saved from Excel or similar apps, as for creating a new ref (was made for Skyrim, but it's the same in FO4) unit userscript; function Initialize: integer; var p, cell, ref: IInterface; begin // KilkreathRuins03 "Kilkreath Catacombs" [CELL:00027D1C] cell := RecordByFormID(FileByIndex(0), $00027D1C, False); p := AddNewFile; // copy cell as override AddRequiredElementMasters(cell, p, False); cell := wbCopyElementToFile(cell, p, False, True); // new temporary ref ref := Add(cell, 'REFR', True); AddMessage(Name(ref)); Result := 1; end; end. Link to comment Share on other sites More sharing options...
Dillenger69 Posted April 23, 2017 Author Share Posted April 23, 2017 Thanks, the code snippet helps more than anything yet. What I'm doing is trying to place a light at the site of each item I've removed from the world using one of two methods ... 1) copy a light reference for the light type and just modify it's position and cell. RecordByFormID seems to be the key to this. I didn't know exactly what it did and couldn't find good examples of it. My google-fu for xedit scipts is lacking.or2) create a light reference record with the properties I need and place it. I've tried this and it fails when I get to the cell that start's nuka world(I've got all 3 world ESMs as masters). So, I've got some troubleshooting to do. I suspect it has something to do with form IDs and load order. And that it would happen even if I were copying the light. the kicker is that this script takes for-ever to run so troubleshooting is a b&@*$. Even on an [email protected] it takes a few hours to scan the whole world, interior and exterior. And my exception doesn't happen until an hour and half in. Link to comment Share on other sites More sharing options...
VIitS Posted April 23, 2017 Share Posted April 23, 2017 If you want to place the same base light record where every single removed record used to be, there's a fairly easy way to do it: 1) Copy all the records you want to remove into your mod*2) Edit one of the Records so it has only the "Doesn't Light Water" flag3) Select all the references, making sure to select the one you edited last4) Right click in the Record flags (the part next to Record Flags, to get the whole entry) -> Copy to selected records -> OK5) Then use unit GlowingSeaLightConvert; function Process(e: IInterface): Integer; begin if Signature(e) <> 'REFR' then Exit; RemoveElement(e, 'XLYR'); RemoveElement(e, 'XSCL'); SetElementEditValues(e, 'NAME', '00204273'); SetElementEditValues(e, 'XRDS', '1062.248169'); SetElementNativeValues(e, 'Record Header\Record Flags', $101); Add(e,'XLIG', True); SetElementNativeValues(e, 'XLIG\Fade 1.0+/-', -0.693785); SetElementNativeValues(e, 'XLIG\Shadow Depth Bias', 1); end; end. This will remove the "Layer" (useless outside the CK) and "Scale" data from the selected placed references, set the base record to the light you mentioned, set the "Doesn't Light Water" flag, set the radius to one of the more common radii for that record, and sets the Light Data to a mid-range setting. To remove other more things, just add additional RemoveElement lines with the relevant field identifier. You might end up needing to increase/decrease the radius and fade values, depending on the spacing of the things you are removing. *I'd guess they are already in your mod edits to remove them in some manner, so you can use this: unit Record_Reset; function Process(e: IInterface): Integer; begin SetElementNativeValues(e, 'Record Header\Record Flags', $20); SetElementNativeValues(e, 'Record Header\Record Flags', $0); end; end. to reset them to vanilla (for the coordinate data, assuming it's not still in the records). Also, it might be better to do this in a separate plugin, then copy everything into your main plugin once you are done Link to comment Share on other sites More sharing options...
Dillenger69 Posted April 23, 2017 Author Share Posted April 23, 2017 (edited) Thanks again, all very helpful stuff. Here's the script I have so far. I'd paste the source in here but it's well over 1000 lines. Other than the hiccup around where nuka world and the commonwealth overlap, it seems to work. can you see any glaring errors in it ... perhaps a more efficient way to do what I'm doing? Any constructive criticism is welcome. edit: It also throws around where far harbor and the commonwealth overlap with "Invalid Argument". For now I just catch, swallow, and don't place a light.edit 2: After running for 8 hours ... it didn't place a single light. grumble. I guess I'll try the copy instead of trying to create a new light.edit 3: After much revision and error trapping, Copying the light into place seems to do the trick. I've also figured out how to properly exit scripts rather than throwing an unhandled exception. Edited April 24, 2017 by Dillenger69 Link to comment Share on other sites More sharing options...
Recommended Posts