Jump to content

Struggling with arrays


shonuv

Recommended Posts

I'm trying to make a simple crypt mod for storing corpses(thralls)

Some goog searches lead me to the notion that I should add the corpses to some aliases in an array to make sure they don't get deleted when the engine does cleanup.

 

My problem is that I have a hard time wrapping my head around arrays.

 

So far I've managed to add a corpse to the first alias in the array and then move the corpse to my crypt cell, but I have no idea how to fill out subsequent elements in the array, or how to hand pick elements to remove when better thrall options come along. This line worked CorpseAlias[0].forceRefTo(deadBody) but I know I'm missing a bunch of .Length and i >= and stuff. I just don't know what I'm looking at when I see other peoples scripts dealing with arrays.

 

I did look at the wiki, but for some reason when I see examples that use any form of "hello" and or "world", my brain just shuts it out (practical application?)

 

Any guidance would be greatly appreciated.

 

And on a different note, is there a way to place ragdolls with any degree of precision?

 

 

Link to comment
Share on other sites

Disclaimer: I have absolutely no experience whatsoever with Papyrus, but I do have some with the scripting thing used for Oblivion, but that is useless with Papyrus. So I am just a random passer-by who tries to be of help. :tongue:

 

In the scripting thing used for Oblivion (with OBSE), there was the ar_Append command, but I did not find any similar one in the Creation Kit Wiki. Something like that might be handy for adding new elements at the end of an array. But I doubt there is something like that. Especially when it seems the size needs to be set when writing the script. Now that is odd. :smile:

 

Perhaps it would be possible to somehow find the first empty "slot" in the array and then use the number of the empty slot when adding a new element. Or something like that. So that first, the array would need to be scanned for the first empty or unfilled or whatever slot and then the new thing would be added to that one. There was an example of doing something to all elements in an array on the wiki that could be of help.

 

Maybe it would be possible to use it to find the first empty slot in the array by checking if the current element is defined somehow? So that it would go backwards through the whole array and return the number of the first empty slot (the last one it finds)? I have no idea how Papyrus works, but maybe it could be something like this:

 

[your CorpseAlias array defined somewhere somehow]

Int iElement = CorpseAlias.Length
Int iFirstEmpty = 0

While iElement
    iElement -= 1
    If CorpseAlias[iElement]
        ; This one is not empty? Can it be checked like that?
    Else
        ; This one is free
        iFirstEmpty = iElement
    EndIf
EndWhile
And then, if an ampty one is found, somehow fill it with your thing.
If iFirstEmpty
    CorpseAlias[iFirstEmpty].ForceRefTo(DeadBody)
EndIf
And perhaps the removal could work by finding the number of the element to be removed or emptied or something like it and then using that number with some sort of emptying command (if there is one).
But there is this one that has an integer used when checking elements. Is it possible to use one? I have no idea. http://www.creationkit.com/Arrays_%28Papyrus%29#Warnings

 

But, like I said, I have not written any Papyrus scripts, so do not use those, please. :D And anyone who actually knows how Papyrus works, please, do correct me.

Edited by PhilippePetain
Link to comment
Share on other sites

Well that is definitely easier for me to read. I'll give her a shot and see what happens. Thanks for the reply

 

edit: For closure.

 

I didn't use any of that .length i += stuff, I just filled out the array with the ck property drop-down thing and manually pointed to each individual element in my script.

It went something like

 

If conditions().blablabla.

myArray[0].dothis

 

elseIf other.stuff().blablabla

myArray[1].dothis

 

What evs :confused: Working is working right?

Edited by shonuv
Link to comment
Share on other sites

I have no idea. If it works, it works. But it would probably be polite to check it thoroughly before releasing your mod. So that the script runs smoothly and does not generate a heap of errors and such in the log. And also that it is written in a proper way - which I cannot do, as I am only learning how to work with Papyrus myself. :tongue:

 

It just sounds like more work to do it all manually. I hope the array is a small one. :D

Edited by PhilippePetain
Link to comment
Share on other sites

More work? Definitely, but I live by the motto, "Why work smarter when you can work harder?" :laugh: I was planning on having about 20 open tombs for this crypt (yes I'm that morbid), but now I'm thinking maybe 5-10.

I knew I could hack together something that would work, but I was hoping to keep my scripts nice and short with those arrays. :cool: Too bad I failed.

I will test extensively before I release though.

 

So far my modding experience has been designing interiors as well as re-texturing, but then I realized that my mod would be "just another simple player home" Just like the thousands of basic player home mods on the Nexus.

So I decided I should add some "features". And thus my journey into Papyrus began.

 

Thanks for reading Philippe, and good luck with your own papyrus learning. Cheers

Link to comment
Share on other sites

Thank you. Some have said Papyrus is easier than the scripting launguage used in, for example, Oblivion, but I find Papyrus more complicated. Or perhaps it is just the different syntax and having scripts sort of 'separate' from everything else and having to use properties and everything. I have no experience in any actual scripting, so this journey of mine in the... interesting world of Papyrus has turned out to be quite an experience. :smile:

 

Good luck to you, as well. Some may indeed find the idea interesting an useful. Leaving the emperor's body at The Katariah does feel odd, come to think of it. And the body of Ulfric Stormcloak at Palace of the Kings. Need to have a place to stuff all the 'trophies'. If one is into that sort of thing. The place has to have good air conditioning or be located somewhere cold. :D

Edited by PhilippePetain
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...