Jump to content

witchcraft lua console


ArturDCS

Recommended Posts

So I got witchcraft working (I think).

The nodejs part of the witchcraft release at GitHub doesn't work, download the binaries for nodejs and unzip => overwrite nodejs files in the witchcraft folder.

Then get Mist 3.3 and do what is listed in the readme for witchcraft.

 

So I created a mission, nothing but my A-10C flying at high altitude. I can browse the lua console but what then? How can I access the controls of the A-10C?

I tried (A-10C VVI Gauge)

GetDevice(0):get_argument_value(12)

which doesn't work, I am guessing I need to get a hook on the A-10C and then run the above command.

Does anyone have any clue? I am lost.. :(

Link to comment
Share on other sites

Your code snippet has to return a value to be displayed in the Lua console.

 

If the value can be converted to JSON (i.e. it does not contain functions or userdata, and if it is a table, the keys are either only strings or only integers), the Lua console will be able to display it. So for your example:

 

return GetDevice(0):get_argument_value(12)

will work.

If it doesn't, you need to follow the comments in WitchcraftExport.lua to connect to the Export environment instead of the Mission environment.

 

If you get an error that something cannot be converted to JSON, convert it to a string on the Lua side:

return tostring(some_other_value)

You'll probably want to replace tostring() with a function that serializes Lua tables. You can copy the functions from MiST and evaluate them in the Export.lua environment to make it available, then use something like "return mist.utils.tableShow(_G)".

Link to comment
Share on other sites

Excellente!!!

 

I finally got it working.

 

I added WitchcraftExport.lua to Script folder where export.lua is and added

dofile(lfs.writedir()..[[scripts\WitchcraftExport.lua]])

to export.lua.

 

After executing the

return GetDevice(0):get_argument_value(12)

I got the value as shown in the screenshot.

 

Thanks Ian!

asd.png.939ed5b7f474b55c65277c50d490811b.png

asas.png.f9d33930d073197680f5c57d4125afc2.png


Edited by ArturDCS
Link to comment
Share on other sites

  • 3 months later...
Ian;3329486']You'll probably want to replace tostring() with a function that serializes Lua tables. You can copy the functions from MiST and evaluate them in the Export.lua environment to make it available' date=' then use something like "return mist.utils.tableShow(_G)".[/quote']

 

I am trying to figure out the NADIR on the SA243. Can't find where the data is stored for the display.

I have tried to dump the environment, I managed to dump _G using the Mist function as you suggested but that doesn't contain any info about helicopter cockpit controls.

How can I dump everything related to the SA342? I have a mission with only this helicopter and nothing else.

According to devices.lua the NADIR is 23 but there is also a NADIR folder containing more lua for this and there somewhere is what I need. I just don't know what to look for, if I had a dump I might find the argument numbers I need.

Link to comment
Share on other sites

  • 2 months later...
So I got witchcraft working (I think).

The nodejs part of the witchcraft release at GitHub doesn't work, download the binaries for nodejs and unzip => overwrite nodejs files in the witchcraft folder.

Then get Mist 3.3 and do what is listed in the readme for witchcraft.

 

So I created a mission, nothing but my A-10C flying at high altitude. I can browse the lua console but what then? How can I access the controls of the A-10C?

I tried (A-10C VVI Gauge)

GetDevice(0):get_argument_value(12)

which doesn't work, I am guessing I need to get a hook on the A-10C and then run the above command.

Does anyone have any clue? I am lost.. :(

 

I confirm that, the nodejs part on the gibhud doesn't work.

Link to comment
Share on other sites

  • 4 months later...
  • 10 months later...

I know this is a year old but in case anyone else finds this thread trying to get Witchcraft running, you need to delete the contents windows\nodejs folder that's included in the Mod and replace it with a more recent version of node.JS

 

I downloaded LTS 32Bit Windows Binary version from here

https://nodejs.org/en/download/

then extracted all the files and folders into the mode windows\nodejs then ran windows.cmd again and it worked first time.


Edited by Matchstick
corrected folder name
Link to comment
Share on other sites

  • 5 months later...
I know this is a year old but in case anyone else finds this thread trying to get Witchcraft running, you need to delete the contents windows\nodejs folder that's included in the Mod and replace it with a more recent version of node.JS

 

I downloaded LTS 32Bit Windows Binary version from here

https://nodejs.org/en/download/

then extracted all the files and folders into the mode windows\nodejs then ran windows.cmd again and it worked first time.

 

Yes I'm glad I found this thread, i had same issue after following correct install procedure for witchcraft , it also failed to work for me.

 

Once I deleted "nodejs" folder in the install and replaced it with this "Windows Binary (.zip)" (64 bit)

from HERE then it worked. (i guess the 32 and 64 bit versions of nodejs both work)

fyi: My windows ver is 10

 

Hope this helps ppl get it working, be nice is author of witchcraft updated his download with this too.

 

EDIT:

posted this issue and solution on github site for author of witchcraft.

 

Re-posted this topic in appropriate area of forum to allow ppl to find it easier HERE


Edited by Stix_09
Infor about sending author this problem
Link to comment
Share on other sites

Good catch, I did solve this problem a while ago but unfortunately I didn't post.

Point is, there is no need to bundle NodeJS where all the user has to do is install it. So I deleted the Nodejs folder and modified the witchcraft.cmd scripts as follows :

cd src
call npm.cmd --spin=false --loglevel=info install
node backend\server.js
start http://localhost:80/
pause

It works just fine ;)

Zip - VEAF :pilotfly:

 

If you want to learn, talk and fly with french-speaking friends, the Virtual European Air Force is here for you ! Meet us on our Discord and our forum

If you're a mission creator, you may want to check the VEAF Mission Creation Tools (and its GitHub repository) a set of open-source scripts and tools that make creating a dynamic mission a breeze !

Link to comment
Share on other sites

  • 2 years later...

I've tried replacing nodejs with a recent version, and I tried both 64bit and 32bit.  Now I'm getting

found 0 vulnerabilities
npm timing command:install Completed in 478ms
npm timing npm Completed in 637ms
npm info ok
D:\DCS\Dev\github\dcs-witchcraft\src\backend\server.js:4
var io = require('socket.io').listen(app.listen(port, "0.0.0.0"));
                              ^

TypeError: require(...).listen is not a function
    at Object.<anonymous> (D:\DCS\Dev\github\dcs-witchcraft\src\backend\server.js:4:31)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47
Press any key to continue . . .

 


Edited by Rex

Rex's Rig

Intel i9-14900K | Nvidia RTX 4090 | 64GB DDR5 | 3x4TB 990 Pro M2 SSDs | HP Reverb 2 | 49" Samsung 5120x1440 @ 120Mhz

TM Warthog Stick + Throttle | TM Pendulum Pedals | MS Sidewinder 2 FFB | Track IR |  Cougar MFD x 2 

 

Link to comment
Share on other sites

FWIW, this is how I made it work on Windows 10 Pro.

* I did all of the initial stuff in the README.md

* I moved witchcraft.cmd into the root of the dcs-witchcraft repo directory, and changed it to:

 

cd src
call ..\nodejs\npm.cmd --spin=false --loglevel=info install
call ..\nodejs\node  backend\server.js
start http://localhost:3000/
pause

 

* I got rid of the `nodejs` dir, downloaded the latest node, which is version 18.7, 64 bit, unzipped it, and renamed it `nodejs`

* I opened src/backend/server.js and changed

 

var io = require('socket.io').listen(app.listen(port, "0.0.0.0"));

to

var server = require('http').createServer(app);
var io = require('socket.io')(server);
server.listen(process.env.PORT || 3000);

 

And the console finally worked.

 


Edited by Rex

Rex's Rig

Intel i9-14900K | Nvidia RTX 4090 | 64GB DDR5 | 3x4TB 990 Pro M2 SSDs | HP Reverb 2 | 49" Samsung 5120x1440 @ 120Mhz

TM Warthog Stick + Throttle | TM Pendulum Pedals | MS Sidewinder 2 FFB | Track IR |  Cougar MFD x 2 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...