Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
birsoyo opened this issue Feb 13, 2024 · 0 comments
Open

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

birsoyo opened this issue Feb 13, 2024 · 0 comments

Comments

@birsoyo
Copy link

birsoyo commented Feb 13, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant