Best practices for a "RunOnce" type of CUE?

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Post Reply
user1679
Posts: 761
Joined: Fri, 20. Jul 18, 23:20

Best practices for a "RunOnce" type of CUE?

Post by user1679 » Thu, 2. Jun 22, 12:51

I just finished a rewrite of what appears to be an abandoned mod that automatically adds player prefix/suffix tags to
deployed/built objects. All the code has been reworked to utilize libraries and it is commented for users to understand.

There is an option called $runAtStartup that allows the player to force all owned objects to be renamed at startup
after installation. The problem is, they have to remember to set it to FALSE or it will run at every startup.

It isn't necessary to run it repeatedly at startup because new objects are automatically renamed. This is just a feature
to allow the mod to apply to existing empires when the mod is initially installed.

What is the best way to implement a "RunOnce" cue but also give the player the option to force it to "RunOnce" at
any time, if they want?


https://i.imgur.com/Lw1WlSI.jpeg
Last edited by Terre on Thu, 2. Jun 22, 19:08, edited 1 time in total.
Reason: Images posted directly to the forums should not be greater than 640x480 or 100kb, oversize image now linked

DeadAirRT
Posts: 1008
Joined: Fri, 25. Jan 19, 03:26
x4

Re: Best practices for a "RunOnce" type of CUE?

Post by DeadAirRT » Sat, 4. Jun 22, 15:44

I haven't personally made any run once cues that i specifically want the user to be able to reset. The best method i know of would be to use sirnukes mod support api to create a little ui menu that allows the user to trigger a cue with the actions being in a library or something.

Barring that it basically is up to what you think the user is least likely to mess up. Maybe a condition of
<check_value value="false"/>
Then the user can change false to true to make it run.

user1679
Posts: 761
Joined: Fri, 20. Jul 18, 23:20

Re: Best practices for a "RunOnce" type of CUE?

Post by user1679 » Sun, 5. Jun 22, 03:03

DeadAirRT wrote:
Sat, 4. Jun 22, 15:44
I haven't personally made any run once cues that i specifically want the user to be able to reset. The best method i know of would be to use sirnukes mod support api to create a little ui menu that allows the user to trigger a cue with the actions being in a library or something.

Barring that it basically is up to what you think the user is least likely to mess up. Maybe a condition of
<check_value value="false"/>
Then the user can change false to true to make it run.
Thanks. I hadn't considered sirnukes because I didn't want to take on too much of a learning curve than I have with the XML libraries. But your value check is how I do it right now,
my problem is I wanted a fail-safe if the user forgets to switch it back.

I thougth of something like this:

<do_if value="runonce == 1">
</do_if>

<set_value name="runonce" exact="0">

But I'm not sure how to force the value to be saved and loaded on the next startup without declaring it prior to use and thereby wiping out the loaded value.

DeadAirRT
Posts: 1008
Joined: Fri, 25. Jan 19, 03:26
x4

Re: Best practices for a "RunOnce" type of CUE?

Post by DeadAirRT » Sun, 5. Jun 22, 03:44

user1679 wrote:
Sun, 5. Jun 22, 03:03
DeadAirRT wrote:
Sat, 4. Jun 22, 15:44
I haven't personally made any run once cues that i specifically want the user to be able to reset. The best method i know of would be to use sirnukes mod support api to create a little ui menu that allows the user to trigger a cue with the actions being in a library or something.

Barring that it basically is up to what you think the user is least likely to mess up. Maybe a condition of
<check_value value="false"/>
Then the user can change false to true to make it run.
Thanks. I hadn't considered sirnukes because I didn't want to take on too much of a learning curve than I have with the XML libraries. But your value check is how I do it right now,
my problem is I wanted a fail-safe if the user forgets to switch it back.

I thougth of something like this:

<do_if value="runonce == 1">
</do_if>

<set_value name="runonce" exact="0">

But I'm not sure how to force the value to be saved and loaded on the next startup without declaring it prior to use and thereby wiping out the loaded value.
If you think users are smart enough you could have them uncomment something.

Sirnukes stuff is done in xml and has really good documentation. It would likely be easier than most projects.

Post Reply

Return to “X4: Foundations - Scripts and Modding”