Import VS Module

Post Reply
Iceblade
Just a tourist with a frag'd nav console
Just a tourist with a frag'd nav console
Posts: 3
Joined: Wed Oct 23, 2013 11:53 pm

Import VS Module

Post by Iceblade »

In several modules, I see the line "import VS".

What exactly is this referring to? I'm trying to get the list of functions/classes/definitions contained within so that I can reference a player's currently owned ship list.
TBeholder
Elite Venturer
Elite Venturer
Posts: 753
Joined: Sat Apr 15, 2006 2:40 am
Location: chthonic safety

Re: Import VS Module

Post by TBeholder »

What it's really about is binding hardcoded functions into Python, so looking for identifiers - it's called in Python modules as

Code: Select all

plist=VS.musicAddList('industrial.m3u')
VS.musicPlayList(plist)
It's actually done in vegastrike/src/cmd/script/script_callbacks.cpp, in void Mission::initCallbackMaps() - there's stuff like

Code: Select all

    module_briefing_map["addShip"]           = CMT_BRIEFING_addShip;
    module_briefing_map["removeShip"]        = CMT_BRIEFING_removeShip;
    module_briefing_map["enqueueOrder"]      = CMT_BRIEFING_enqueueOrder;
...
    module_unit_map["getUnit"]                  = CMT_UNIT_getUnit;
    module_unit_map["getTurret"]                = CMT_UNIT_getTurret;
    module_unit_map["getCredits"]               = CMT_UNIT_getCredits;
    module_unit_map["getRandCargo"]             = CMT_UNIT_getRandCargo;
...
    module_std_map["terminateMission"]          = CMT_STD_terminateMission;
    module_std_map["playAnimation"]             = CMT_STD_playAnimation;
    module_std_map["musicAddList"]              = CMT_STD_musicAddList;
    module_std_map["musicPlaySong"]             = CMT_STD_musicPlaySong;
    module_std_map["musicPlayList"]             = CMT_STD_musicPlayList;
"Two Eyes Good, Eleven Eyes Better." -Michele Carter
Iceblade
Just a tourist with a frag'd nav console
Just a tourist with a frag'd nav console
Posts: 3
Joined: Wed Oct 23, 2013 11:53 pm

Re: Import VS Module

Post by Iceblade »

Thanks. Actually I did manage to finally find it - stupid windows search finally managed to browse file contents correctly.

Unfortunately, it would appear that there is no way of actually referencing a player's alternate ships for conditionals or switching. I'll have to devise some other more complicated method.
loki1950
The Shepherd
Posts: 5841
Joined: Fri May 13, 2005 8:37 pm
Location: Ottawa
Contact:

Re: Import VS Module

Post by loki1950 »

RE: those alternate ships can be viewed using one of the base screens It's listed as "My Fleet" so troll though the GUI modules and you should come across a method to access them that you can adapt for your use.

Enjoy the Choice :)
my box::HP Envy i5-6400 @2Q70GHzx4 8 Gb ram/1 Tb(Win10 64)/3 Tb Mint 19.2/GTX745 4Gb acer S243HL K222HQL
Q8200/Asus P5QDLX/8 Gb ram/WD 2Tb 2-500 G HD/GF GT640 2Gb Mint 17.3 64 bit Win 10 32 bit acer and Lenovo ideapad 320-15ARB Win 10/Mint 19.2
Iceblade
Just a tourist with a frag'd nav console
Just a tourist with a frag'd nav console
Posts: 3
Joined: Wed Oct 23, 2013 11:53 pm

Re: Import VS Module

Post by Iceblade »

I've been trying to locate the code section that deals with the fleet portion of base computers, but I have had no luck locating anything about it within the python modules (within vanilla Vegastrike not Gemini Gold). I've also been digging through the source files for the appropriate build of Vega and still no 'nuggets', just 'rocks'. Maybe I'm looking in the wrong 'quarry'.

Terminology differences between the front and back end portions of the game certainly isn't making things easier. Clearly nothing in the modules or engine refers to the player's list of ships as a fleet or even as ships - they are all units.
loki1950
The Shepherd
Posts: 5841
Joined: Fri May 13, 2005 8:37 pm
Location: Ottawa
Contact:

Re: Import VS Module

Post by loki1950 »

There is some documentation on the API in GUI.py including how to invoke each of the special rooms then I think that each room has various classes and methods so you will need to backtrace them which will no doubt be tedious,klauss is the one who is most familiar with it but he's busy with R/L ATM :(

Enjoy the Choice :)
my box::HP Envy i5-6400 @2Q70GHzx4 8 Gb ram/1 Tb(Win10 64)/3 Tb Mint 19.2/GTX745 4Gb acer S243HL K222HQL
Q8200/Asus P5QDLX/8 Gb ram/WD 2Tb 2-500 G HD/GF GT640 2Gb Mint 17.3 64 bit Win 10 32 bit acer and Lenovo ideapad 320-15ARB Win 10/Mint 19.2
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Import VS Module

Post by klauss »

Iceblade wrote:I've been trying to locate the code section that deals with the fleet portion of base computers, but I have had no luck locating anything about it within the python modules (within vanilla Vegastrike not Gemini Gold). I've also been digging through the source files for the appropriate build of Vega and still no 'nuggets', just 'rocks'. Maybe I'm looking in the wrong 'quarry'.
Vega Strike UTCS base computer is written in C. The code there starts in basecomputer.cpp, and you'll have to follow stuff from there because it's spread around a few files.

In any case, there's probably a way to do that in python. It's not script_callbacks, though, since that one's used for a different scripting method used for AI. For python stuff in the VS module, you've got to look into the _exports files in src/python.

What I'd do to figure out the way to invoke that from python, is look how the basecomputer code does it, and look for something similar in src/python.

In general, most function in starsystem/universe/unit_util_generic.cpp files, you can find exported with almost the same signature in the VS module.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
Post Reply