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

Automation: passing script name as command line argument (demoing / testing / debugging) #1582

Closed
lehrax opened this issue Jan 4, 2024 · 1 comment
Labels
Developer Experience Engine's programmer experience Enhancement Modmaker Experience Modmaker experience with OpenXRay

Comments

@lehrax
Copy link

lehrax commented Jan 4, 2024

Is your feature request related to a problem? Please describe.

A. Scripts literally are scenarios that we can schedule for execution. Starting the demo would be as easy as choosing the right script to pass as CLI argument.

B. Mods are buggy. Whether development teams lack time or experience, manual testing always leaves room to unexpected outcomes (a.k.a. "it was never supposed to happen like this!"). What if we could have actual system and integration tests to automate flow and save a bit of time and effort for other tasks?

Approximate possible test structure to confirm expected behaviour in game:
-- load actual gamesave file or create certain preconditions
-- simulate player's actions (activating interactable object, making dialogue choice, triggering quest condition by other means etc)
-- assert expectations to be reached

Very vague theoretical example without code:

  • load location L, turn off spawn to avoid randomness, put actor to position X0,Y0,Z0 with health state H0
  • actor has protection P, has artifact A attached to belt and list of items in inventory composing M kg in total
  • actor sprints through irradiated territory to position X1,Y1,Z1
  • actor survives and has H1 health state

This suggestion could just be borderline madness, but I strongly believe having the capability to automate certain aspects of quality assurance would drive the projects quality sky high.

Describe the solution you'd like

  • Passing test file name reference through CLI arguments would invoke certain scenario after engine initialises full load.
  • Additionally, having --headless flag would start the game without GUI, allowing controlled conditional execution of lua snippets.

Maybe a full fledged test framework is too much to even think about, but loading script on demand could definitely be very handy 😁

Describe alternatives you've considered

Doing the same from tilda menu in the game, although, that would not be 100% same experience.

Additional context

I got original inspiration from the principle how some gamedata extractors work (example: tool by xrLil Batya): lua injection through dll replacement that allows to execute script.

@lehrax lehrax changed the title Passing script name as command line argument (for testing or debugging) Automation: passing script name as command line argument (for testing or debugging) Jan 4, 2024
@lehrax lehrax changed the title Automation: passing script name as command line argument (for testing or debugging) Automation: passing script name as command line argument (demoing / testing / debugging) Jan 4, 2024
@Xottab-DUTY Xottab-DUTY added Enhancement Help wanted Developer Experience Engine's programmer experience Modmaker Experience Modmaker experience with OpenXRay labels Jan 17, 2024
@Xottab-DUTY
Copy link
Member

Xottab-DUTY commented Feb 12, 2024

  1. There is a command line key -$, which allows to run a console command in the end of level loading.
  2. There is run_script console command, which allows runs main function from the selected script file.
  3. There is run_string console command, which allows to run a Lua string directly in the console.

You can use the first two like this:

xrEngine.exe -$ run_script myscriptfile

Since -$ runs the command only at the end of level loading, it makes sense to use -start command line key, to tell the engine to load a level straightforward instead of showing main menu:

xrEngine.exe -start server(all/single/alife/new) client(localhost) -$ run_script myscriptfile

That will start singleplayer game as if you had pressed New game in the main menu.

all is a spawn file name from gamedata/spawns folder or just a level name from gamedata/levels folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Developer Experience Engine's programmer experience Enhancement Modmaker Experience Modmaker experience with OpenXRay
Projects
None yet
Development

No branches or pull requests

2 participants