Skip to content

Order of trigger actions changes after a load and save #369

Description

@birsoyo

I am trying to write a script that modifies a mission. I don't know how the original mission is created.
But I suspect some custom "scripts" are used to create the mission in addition to the ME.

In the original mission the "actions" section looks like this.

['actions']=
{
    [3]=
    {
        ['predicate']="a_do_script_file",
        ['file']="init",
    },
    [1]=
    {
        ['predicate']="a_do_script_file",
        ['file']="mist",
    },
    [2]=
    {
        ['predicate']="a_do_script_file",
        ['file']="main",
    },
}, -- end of ["actions"]

When I open this original mission in ME, it presents the "correct" order i.e. 1 mist, 2 main, 3 init.

But after I load and save this mission using pydcs, ME shows 1 init, 2 mist, 3 main. Note that it matches the order of appearance in the original file instead of their indices.

from the file saved with pydcs:

	["actions"]=
	{
		[1]=
		{
			["file"]="init",
			["predicate"]="a_do_script_file"
		},
		[2]=
		{
			["file"]="mist",
			["predicate"]="a_do_script_file"
		},
		[3]=
		{
			["file"]="main",
			["predicate"]="a_do_script_file"
		}
	},

I solved this issue by changing the loop in TriggerRule.create_from_dict : from for a in actions: to for a in range(1, len(actions)+1): in my local copy of pydcs.

Judging from how it is saved in TriggerRule.dict, I suspect similar change is also necessary for the "rules" loop as well.

I can create a PR, if my approach above is a correct one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions