How to create and run .ws scripts

+
Hello everyone.


I`m not sure, if there are themes about this in forum, but i didn`t find them.


I need to create sript (for example, .ws), it must run console command in Witcher 3 game (for example, spawn('triss')). and it must be executable from external programm (for now, it`s not important, whis). Is there any abilities to do that ? All i read about it, is to user script merger, or manuals to install mods. Does anybody has some information about that ?
 
Last edited:
1) In order to create a exec function that's fairly straight forward:
- Open your games install folder and open your mods folder (create one if not there)
- Add new mod, e.g: modMyExecFunctionsMod/content/scripts/local
- Create a new .txt file, and change the extension to .ws, and name it.
- Add in your exec function like so:

Code:
exec function myexecfunction()
{
    // Your code goes here...
}
Add in whatever logic you want there.

2) To execute it from an external program:
(I'm going to assume you are going to write this external program yourself)
- You need to connect to the game via it's net protocol, launching the game with -net flag will start it.
- In your program you can connect to the game using 127.0.0.1 (local) and port number 37001
- Open a tcp socket or network stream to that endpoint.
- The bytes you need to send can be found in wolvenkit's github page.

Messages have a header of 0xDEAD and a tail of 0xBEEF, the message bytes are broken down into components each with a header of a Int16.
 
Thanks a lot, my friend.
Post automatically merged:

One more thing, i wanted to ask. Are some kind of access area for the functions, because, when i try to use something like this

exec function printmystring(msg : String)
{
GetWitcherPlayer().DisplayHudMessage(msg);
}

I got message and everithing is ok, but if i do something like that

exec function printmystring(msg : String)
{
spawn(msg);
}

i got message "Cannot call exec function 'spawn' from scripts instead of the console.". At Script compilation stage.
Post automatically merged:

At the end, the goal for me is to have an ability to run console commands (direct console commands) from external programm. For example, i get in those programm some string like (spawn("triss")), i want to send that string to my script and run that command
 
Last edited:
Thanks a lot, my friend.
Post automatically merged:

One more thing, i wanted to ask. Are some kind of access area for the functions, because, when i try to use something like this

exec function printmystring(msg : String)
{
GetWitcherPlayer().DisplayHudMessage(msg);
}

I got message and everithing is ok, but if i do something like that

exec function printmystring(msg : String)
{
spawn(msg);
}

i got message "Cannot call exec function 'spawn' from scripts instead of the console.". At Script compilation stage.
Post automatically merged:

At the end, the goal for me is to have an ability to run console commands (direct console commands) from external programm. For example, i get in those programm some string like (spawn("triss")), i want to send that string to my script and run that command

You cannot call exec functions from inside other script functions, they have to be called via the console.

you could copy paste the vanilla spawn function, rename it and remove the exec, and then you can call it.
 
You cannot call exec functions from inside other script functions, they have to be called via the console.

you could copy paste the vanilla spawn function, rename it and remove the exec, and then you can call it.

Oh, i got it. Thanks a lot for your help
 
One last question. I can`t see the file within game directory (.ws file or other), where those vanilla console functions are declarated. Are there in the files ?
 
One last question. I can`t see the file within game directory (.ws file or other), where those vanilla console functions are declarated. Are there in the files ?
 

Attachments

  • exec functions.txt
    41.8 KB · Views: 522

Guest 2364765

Guest
Thanks a lot, my friend.
Post automatically merged:

One more thing, i wanted to ask. Are some kind of access area for the functions, because, when i try to use something like this

exec function printmystring(msg : String)
{
GetWitcherPlayer().DisplayHudMessage(msg);
}

I got message and everithing is ok, but if i do something like that

exec function printmystring(msg : String)
{
spawn(msg);
}

i got message "Cannot call exec function 'spawn' from scripts instead of the console.". At Script compilation stage.
Post automatically merged:

At the end, the goal for me is to have an ability to run console commands (direct console commands) from external programm. For example, i get in those programm some string like (spawn("triss")), i want to send that string to my script and run that command

Spawn is an entity function.

WS is logically close to LUA, however NO script exists by itself.
Only exec functions can be invoked by the user manually, every other use case of wscript is as an entity class which needs to be spawned/existing in game world in order to run it's logic.

If you're unfamiliar with basic OOP or any game engine then it'll be hard to explain how it works but for TL;DR anything more involved will either require you to create your own entity class and then spawn it or have your logic nested in entity that already exists like player or playerwitcher.

For most modders it created bothersome chain of events where you either need user to manually instance new stuff to have it running or place it in player script (which in turn causes mod conflicts).
There's also 3rd solution of creating new layer files to automatically place your custom entity in game world, however it's somewhat tedious and doesn't always work.
 
Spawn is an entity function.

WS is logically close to LUA, however NO script exists by itself.
Only exec functions can be invoked by the user manually, every other use case of wscript is as an entity class which needs to be spawned/existing in game world in order to run it's logic.

If you're unfamiliar with basic OOP or any game engine then it'll be hard to explain how it works but for TL;DR anything more involved will either require you to create your own entity class and then spawn it or have your logic nested in entity that already exists like player or playerwitcher.

For most modders it created bothersome chain of events where you either need user to manually instance new stuff to have it running or place it in player script (which in turn causes mod conflicts).
There's also 3rd solution of creating new layer files to automatically place your custom entity in game world, however it's somewhat tedious and doesn't always work.

Thanks. i`m familiar to OOP, and i already created custom ws script with redeclaration of vanilla spawn function (just called it cust_spawn) and from my custom function those func works fine

I don`t need to create a whole mod, just to execute console commands from external functions/files. As i can see, this can be done with vanilla function redeclaration and changing their names
 
Last edited:
Sorry to drag this one back up. I am wanting to do a similar thing. I want to use the debug protocol to trigger a command from a python script external to the game.

I am struggling to figure out how to send the command over. I can see above Lim3zer0 linked to the wolvenkit's github page for details on how to format the request but am out of my depth trying to figure it out.

Would anyone be able to point me in the right direction?

Thanks
 
Code:
exec function myexecfunction()
{
    // Your code goes here...
}

you ave many example in this file : temp.ws

edit files with notepad ++
 
Last edited:
Top Bottom