Difference between revisions of "Talk:RemoveAddedForm - FormList"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Chesko
imported>XJDHDR
(→‎Remove None items?: new section)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== RemoveAddedForm() was unreliable ==
In version 1.6 (and earlier) RemoveAddedForm was buggy, but it has been fixed and works in the current version of the game. [[User:Cdcooley|Cdcooley]] ([[User talk:Cdcooley|talk]]) 2015-04-09T21:40:52 (EDT)
As of version 1.6, avoid using RemoveAddedForm() was buggy on some platforms. (See discussion below). AddForm() and Revert() however both work fine. If you are exclusively working with initially empty formlists, you can simulate RemoveAddedForm() as follows:
<source lang="papyrus">
; ** Local FormList wont work. Must be created in CK and injected.
; ** CEIF = Custom Empty Injected FormList
Formlist property CEIF auto
Function RemoveForm(FormList source, Form f)
    int size = source.GetSize()
    if (size > 0)
        CEIF.Revert()
        int i = 0
        bool notFound = true
        Form item
        while (i < size && notFound)
            item = source.GetAt(i)
            if (item != f)
                CEIF.AddForm(item)
            else
                notFound = false
            endif
            i += 1
        endWhile
        if (!notFound)
            while (i < size)
                CEIF.AddForm(source.GetAt(i))
                i += 1
            endWhile
            source.Revert()
            size = CEIF.GetSize()
            if (size > 0)
                i = 0
                while (i < size)
                    source.AddForm(CEIF.GetAt(i))
                    i += 1
                endWhile
            endif
        endIf
    endIf
endFunction
</source>
== RemoveAddedForm bugged? ==
== RemoveAddedForm bugged? ==
I'm currently trying to manipulate a FormList filled with items using a container. The script is very basic but already gets screwed:
I'm currently trying to manipulate a FormList filled with items using a container. The script is very basic but already gets screwed:
Line 18: Line 66:
What am I doing wrong? -- [[User:M3rvin|M3rvin]] 09:31, 15 April 2012 (EDT)
What am I doing wrong? -- [[User:M3rvin|M3rvin]] 09:31, 15 April 2012 (EDT)


This function is indeed potentially bugged. I do not recommend manipulating FormLists at runtime.  See this discussion: http://forums.bethsoft.com/topic/1365445-bug-formlist-functions-seem-to-break-under-certain-conditions/page__fromsearch__1 [[User:Chesko|Chesko]] ([[User talk:Chesko|talk]]) 11:07, 18 July 2012 (EDT)Chesko
This function is indeed potentially bugged. I do not recommend manipulating FormLists at runtime.  See [http://forums.bethsoft.com/topic/1365445-bug-formlist-functions-seem-to-break-under-certain-conditions/page__fromsearch__1 this discussion]. This function is used a total of 1 time in Bethesda's vanilla scripts (MQ206ThroatoftheWorldTriggerScript) and is probably not stable enough for general use.  [[User:Chesko|Chesko]] ([[User talk:Chesko|talk]]) 11:07, 18 July 2012 (EDT)Chesko
 
== Remove None items? ==
 
I'm pretty sure I already know the answer to this question but under the [[Save_File_Notes_(Papyrus)#Missing_Plugin_2|Save file notes]] page, it says that any Forms in a Formlist that belong to a mod that has been uninstalled will be converted into Nones. My question is whether it is possible to use something like "FormList.RemoveAddedForm(None)" to get rid of these or is the "Revert" function the only way it can be done -[[User:XJDHDR|XJDHDR]] ([[User talk:XJDHDR|talk]]) 2020-03-21T12:45:02 (EDT)

Latest revision as of 11:45, 21 March 2020

RemoveAddedForm() was unreliable[edit source]

In version 1.6 (and earlier) RemoveAddedForm was buggy, but it has been fixed and works in the current version of the game. Cdcooley (talk) 2015-04-09T21:40:52 (EDT)


As of version 1.6, avoid using RemoveAddedForm() was buggy on some platforms. (See discussion below). AddForm() and Revert() however both work fine. If you are exclusively working with initially empty formlists, you can simulate RemoveAddedForm() as follows:

; ** Local FormList wont work. Must be created in CK and injected.
; ** CEIF = Custom Empty Injected FormList
Formlist property CEIF auto

Function RemoveForm(FormList source, Form f)
    int size = source.GetSize()
    if (size > 0)
        CEIF.Revert()
        int i = 0
        bool notFound = true
        Form item
        while (i < size && notFound)
            item = source.GetAt(i)
            if (item != f)
                CEIF.AddForm(item)
            else
                notFound = false
            endif
            i += 1
        endWhile
        if (!notFound)
            while (i < size)
                CEIF.AddForm(source.GetAt(i))
                i += 1
            endWhile
            source.Revert()
            size = CEIF.GetSize()
            if (size > 0)
                i = 0
                while (i < size)
                    source.AddForm(CEIF.GetAt(i))
                    i += 1
                endWhile
            endif
        endIf
    endIf
endFunction

RemoveAddedForm bugged?[edit source]

I'm currently trying to manipulate a FormList filled with items using a container. The script is very basic but already gets screwed:

Event OnItemRemoved(Form BaseItem, int iCount, ObjectReference rItem, ObjectReference rContainer)
List.RemoveAddedForm(BaseItem)
EndEvent

Event OnItemAdded(Form BaseItem, int iCount, ObjectReference rItem, ObjectReference rContainer)
List.AddForm(BaseItem)
EndEvent

I used message boxes to track the problem: The items are added to the formlist without problem. The list itself is empty and gets just filled by the OnItemAdded Event, thus every item I want to have removed from the formlist was previously added by this very script to it. RemoveAddedForm just removes the form from the formlist at the very first try in the currently loaded save. That means that the first Item I remove from the container gets removed from the list as well. But then RemoveAddedFrom stops working. It won't even help to open the container again or to refill it completely.

What am I doing wrong? -- M3rvin 09:31, 15 April 2012 (EDT)

This function is indeed potentially bugged. I do not recommend manipulating FormLists at runtime. See this discussion. This function is used a total of 1 time in Bethesda's vanilla scripts (MQ206ThroatoftheWorldTriggerScript) and is probably not stable enough for general use. Chesko (talk) 11:07, 18 July 2012 (EDT)Chesko

Remove None items?[edit source]

I'm pretty sure I already know the answer to this question but under the Save file notes page, it says that any Forms in a Formlist that belong to a mod that has been uninstalled will be converted into Nones. My question is whether it is possible to use something like "FormList.RemoveAddedForm(None)" to get rid of these or is the "Revert" function the only way it can be done -XJDHDR (talk) 2020-03-21T12:45:02 (EDT)