OpenXRay / xray-16

Improved version of the X-Ray Engine, the game engine used in the world-famous S.T.A.L.K.E.R. game series by GSC Game World. Join OpenXRay! ;)
https://discord.gg/sjRMQwv
Other
3.02k stars 454 forks source link

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

Closed lehrax closed 9 months ago

lehrax commented 10 months ago

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:

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

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.

Xottab-DUTY commented 9 months ago
  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.