Jump to content
  • Announcements

    • AndalayBay

      Orphan Attachments   07/31/2018

      I have been doing some housekeeping lately and I've noticed that I had a lot of orphaned attachments. Attachments get orphaned when the PM or post is deleted without removing the attachment first. Deleting a PM or post does not delete the attachment and the file or image remain on the server. I'd like to ask all members to go through their attachments and delete any attachments you don't need anymore or those that have been orphaned. Where can I get a list of my attachments? Click on your display name in the upper right corner of the forums and pick "My Attachments" from the drop-down list. How can I tell an attachment is orphaned? If the PM has been deleted, you'll see a message like this in your attachment list: Unfortunately there is no message if the post has been deleted, so please check your old posts. We do purge old birthday threads every once in a while. Also some hosted projects have been shut down, so you may have orphaned attachments on one of those locations. Thanks!
Sign in to follow this  

Coda, this time with something to download...

Recommended Posts

OK, since I re-invented the wheel last time dammit, let's try again. Well, I don't actually regret that, it turned out to be a very productive thread (thanks, Vorians!), and I can think of other uses for that map code too. But wouldn't it be nice if we could actually see a result sometimes?

So this time, I've taken an older piece of batch editing, which in turn was inspired by AB's floater-detect code, and used it to make all the Unique Landscapes logs into Qarl's Harvest activators that give you fungal ingredients.

The result is here: Qarl's Harvest for Unique Landscapes

And here's the code (yes, it does need more comments, but I'm losing the will to live right now :). Need a beer, soonest.):


CODA(ULLogsToQarls01, "5.0")

;Substitutes new forms for old

var cellUsage
var cellCounter
var baseObject
var baseToSub
var instance
var arCells
var cell
var arRefs
var objectRef
var newRef
var objCount
var cellCount
var cellX
var cellY
var cellCoords
var formInt

var currX
var currY
var currZ
var currRotX
var currRotY
var currRotZ
var currScale

var newRotX
var newRotY
var newRotZ

var arOldForm
var arNewForm
var formCount

var n1

    cellCoords = arcreate(2)

    arOldForm = ArrayCreate (20)
     arNewForm = ArrayCreate (20)
     n1 = 0
    while (n1 < 20)
        arinsert(arOldForm, "", -1)
        arinsert(arNewForm, "", -1)
          n1 = 0
    while (n1 < 13)
            baseObject = getFormByEditorID(arOldForm[n1])
             baseToSub = getFormByEditorID(arNewForm[n1])

        cellUsage = GetCellUseList(baseObject)

        foreach instance <- cellUsage

            arRefs = GetCellObjects(cell)
            formInt=GetCellWorldspace(cell)    ;Exteriors only
            if (formInt!=0)

                forEach objectRef <- arRefs

                    if (GetRefBaseform(objectRef) == baseObject)

                        if (objectRef > 0x1000000 && GetRefDisabled(objectRef)==0)    ;Plug-in selection. Hex value is set to pick out 3rd (+) plug-in loaded.
                                printC("("//$cellX//","//$cellY//") "//$objectRef//" - "//arOldForm[n1])
                            ;OK, change this one.
                                  currX = getRefPosition(objectRef, "X")
                            currY = getRefPosition(objectRef, "Y")
                            currZ = getRefPosition(objectRef, "Z")

                            currRotX = getRefRotation(objectRef, "X")
                            currRotY = getRefRotation(objectRef, "Y")
                            currRotZ = getRefRotation(objectRef, "Z")

                            currScale = GetRefScale(objectRef)
                            ;convert to radians

                            ;WARNING!!! From v8.0, CreateRef will take degrees, so delete the conversions and
                            ;replace the CreateRef line with:

                            newRef=CreateRef(baseToSub, currX, currY, currZ, currRotX, currRotY, currRotZ, cell, GetCellWorldSpace(cell))

                            SetRefScale(newRef, currScale)

                            ;newRotX=currRotX*0.0174532925         ;pre CSE v8.0
                            ;newRotY=currRotY*0.0174532925         ;pre CSE v8.0
                            ;newRotZ=currRotZ*0.0174532925         ;pre CSE v8.0

                            ;newRef=CreateRef(baseToSub, currX, currY, currZ, newRotX, newRotY, newRotZ, cell, GetCellWorldSpace(cell))    ;pre CSE v8.0

                            SetRefDisabled(objectRef,1)    ;Disable old ref
                            SetRefPosition(objectRef, "Z", currZ - 10000)    ;And sink it
                            markAsModified(objectRef, 1)





       printC("Object Count: "//$objCount//" logs have been altered. Bye bye.")    

Edited by tegeusCromis
Replacing older, messier version of code. Hope I don't crash the server this time...

Share this post

Link to post
Share on other sites

I really needed it, cheers AB. Thing is, I was worrying because I thought I'd crashed the server. It seemed to go down just as I entered the edit I just made again now. Wondered if I'd accidentally achieved (using Coda, heh) the equivalent of an injected SQL attack...

Edited by tegeusCromis

Share this post

Link to post
Share on other sites

That was probably me. I've been working with IPS to sort the issues and they released a new version. I couldn't tell who was online at the time, so I went ahead with the upgrade. Sorry about that. :)

Share this post

Link to post
Share on other sites

Well, some things can get tedious.  If 20 minutes to write a script saves you an hour to do something manually, it's worth it to me.  Plus scripting is fun...

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this