Author Topic: Scripting Repository? (idea)  (Read 495 times)

Offline Tethys

  • -=USF=- Co-Leader
  • Posts: 256
  • Cookies: 89
Scripting Repository? (idea)
« on: July 09, 2019, 08:59:16 PM »
Is there any repository available for scripting descriptions and definitions about the types of commands, clauses, and variables allowed, and how they can be setup in the script? I will try to explain. As I look at the scripts I notice that many things have extended commands, for example
Code: [Select]
pSensors.GetProperty().SetDisabledPercentage(pSensorOff*4) has the pSensor which is the subsystem associated with the properties you wish to grab, .GetProperty() is kinda obvious yeah, this grabs some property for the sensors and .Set*(pSensorOff*4) sets the disabled percentage to a calculated static or dynamic value (pSensorOff) multiplied by 4. I have had success changing some of the commands around, such as .SetCondition or .SetNormalPowerPerSecond but I know that the commands throughout all the scripts are not all the commands that BC can use. Alot of commands I can find in the ships hardpoint, and alot of those .Set* can be interchanged with the .Get* command in a script/mod to grab that property for use later on in the def (or file if the value is setup as a global). Stuff like this should have been done in the earlier life of BC, but even so now I feel it could be a valuable resource to help new scripters educate themselves on what can and can't be done with BC scripts. I know some of you here know alot more than I do, so this would more be a community driven effort, basically a "pick our brain" thing except the brain would be the topic with relevant info. I hope I explained that well enough, hopefully some of you are interested.

Offline Mario

  • Senior Software Developer
  • Administrator
  • Posts: 2186
  • Cookies: 1706
  • Life is life
Re: Scripting Repository? (idea)
« Reply #1 on: July 09, 2019, 09:23:51 PM »
There are 2 repositories:
1. It's called App.py
2. print command in BC console on an object to get its properties (bit of console programming required though)

Aside from that, there is none.
Acta, non verba.
aka USS Sovereign

Offline Tethys

  • -=USF=- Co-Leader
  • Posts: 256
  • Cookies: 89
Re: Scripting Repository? (idea)
« Reply #2 on: July 09, 2019, 09:50:27 PM »
Yeah I thought App may hold quite a bit of info and it did. As for the print command I did not know about that one. Is it related to the print "text" I see randomly throughout the scripts?

Offline Mario

  • Senior Software Developer
  • Administrator
  • Posts: 2186
  • Cookies: 1706
  • Life is life
Re: Scripting Repository? (idea)
« Reply #3 on: July 10, 2019, 12:09:26 PM »
Quote
Is it related to the print "text" I see randomly throughout the scripts?

No. Print text we used is for debug purposes. I'm talking about dumping object information to console.

For example:
Code: [Select]
import math
print(math.__dict__.keys())

Results in the following output:
Code: [Select]
dict_keys(['__name__', '__doc__', '__package__', '__loader__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'hypot', 'isclose', 'isfinite', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log1p', 'log10', 'log2', 'modf', 'pow', 'radians', 'remainder', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc', 'pi', 'e', 'tau', 'inf', 'nan'])

Or more cleaner approach which you can find anywhere (for python related materials):
Code: [Select]
def dump(o):
    for a in dir(o):
        if hasattr(o, a):
            print("object method: " + str(a)+ " attribute: " + str(getattr(o, a)))

import math
dump(math)

Results in the following output:
Code: [Select]
object method: __doc__ attribute: This module is always available.  It provides access to the
mathematical functions defined by the C standard.
object method: __loader__ attribute: <class '_frozen_importlib.BuiltinImporter'>
object method: __name__ attribute: math
object method: __package__ attribute:
object method: __spec__ attribute: ModuleSpec(name='math', loader=<class '_frozen_importlib.BuiltinImporter'>, origin='built-in')
object method: acos attribute: <built-in function acos>
object method: acosh attribute: <built-in function acosh>
object method: asin attribute: <built-in function asin>
object method: asinh attribute: <built-in function asinh>
object method: atan attribute: <built-in function atan>
object method: atan2 attribute: <built-in function atan2>
object method: atanh attribute: <built-in function atanh>
object method: ceil attribute: <built-in function ceil>
object method: copysign attribute: <built-in function copysign>
object method: cos attribute: <built-in function cos>
object method: cosh attribute: <built-in function cosh>
object method: degrees attribute: <built-in function degrees>
object method: e attribute: 2.718281828459045
object method: erf attribute: <built-in function erf>
object method: erfc attribute: <built-in function erfc>
object method: exp attribute: <built-in function exp>
object method: expm1 attribute: <built-in function expm1>
object method: fabs attribute: <built-in function fabs>
object method: factorial attribute: <built-in function factorial>
object method: floor attribute: <built-in function floor>
object method: fmod attribute: <built-in function fmod>
object method: frexp attribute: <built-in function frexp>
object method: fsum attribute: <built-in function fsum>
object method: gamma attribute: <built-in function gamma>
object method: gcd attribute: <built-in function gcd>
object method: hypot attribute: <built-in function hypot>
object method: inf attribute: inf
object method: isclose attribute: <built-in function isclose>
object method: isfinite attribute: <built-in function isfinite>
object method: isinf attribute: <built-in function isinf>
object method: isnan attribute: <built-in function isnan>
object method: ldexp attribute: <built-in function ldexp>
object method: lgamma attribute: <built-in function lgamma>
object method: log attribute: <built-in function log>
object method: log10 attribute: <built-in function log10>
object method: log1p attribute: <built-in function log1p>
object method: log2 attribute: <built-in function log2>
object method: modf attribute: <built-in function modf>
object method: nan attribute: nan
object method: pi attribute: 3.141592653589793
object method: pow attribute: <built-in function pow>
object method: radians attribute: <built-in function radians>
object method: remainder attribute: <built-in function remainder>
object method: sin attribute: <built-in function sin>
object method: sinh attribute: <built-in function sinh>
object method: sqrt attribute: <built-in function sqrt>
object method: tan attribute: <built-in function tan>
object method: tanh attribute: <built-in function tanh>
object method: tau attribute: 6.283185307179586
object method: trunc attribute: <built-in function trunc>
Acta, non verba.
aka USS Sovereign