Closed relax81 closed 4 years ago
At this time I have not had luck writing to Simulation Variables. Only Event IDs seem to take input.
I am new so excuse me, but what use is it to set the Propeller rpm anyway?
For throttle you could use event THROTTLE[1-4]_SET to Set throttles exactly range is (0- 16383) where 0 is 0% throttle and 16383 is 100%
sample code:
# Create Request to read the throttle 1 lever position as Percent
THROTTLERequest = sm.newRequest(time=5000) # set auto data collection time @ 5s
THROTTLERequest.add('THROTTLE', (b'GENERAL ENG THROTTLE LEVER POSITION:1', b'Percent'))
# Create Event to write the throttle 1 lever position as integer form 0 - 16383
THROTTLE1_SET = sm.MapToSimEvent(b'THROTTLE1_SET')
sm.SendData(THROTTLE1_SET,DWORD(0)) #0%
sm.SendData(THROTTLE1_SET,DWORD(16383)) #100%
# check for data from THROTTLERequest
data = sm.GetData(THROTTLERequest )
if data is not None:
print("THROTTLE: %f" % (
data.THROTTLE
))
`
Thank you very much for the help.
Throttle and RPM was just an example because they seem to work right now. I would like to use it later to randomly add cargo to the planes, but that Variable seems to have a bug at the moment so i mentioned something that works.
Thanks for the feedback
Are you referring to Simulation Variable "EXIT TYPE "? seems to be the only reference I can find to "cargo". If so, that seem to be a read only variable as there is a N in Settable column. If not do you have a list of ones that you would like to test all see if I can get them working proper. Maybe I can workout why I cant set Simulation Variables yet.
FYI you may want to try the Simvars form the SDK, its under samples. It has working get/set Simulation Variables. Might help with what is working vs is bugged, as yes not everything is supported/working.
Thanks again for the reply, your example above works great.
My guess would be that the variables to add cargo should be
PAYLOAD STATION WEIGHT:index and PAYLOAD STATION OBJECT:index
In the "SimConnect_Status_of_Simulation_Variables" of the SDK they mention that it's "Settable". There is also a read only PAYLOAD STATION COUNT which might be used to get the amound of payload slots? But i'm not sure.
I'll try it during the weekend, but even big Add-Ons like OnAir have currently a problem with adding cargo via SimConnect. They can adjust the fuel, but not the cargo at the moment.
should add support for Settable Simulation Variables. I will close this for now feel free to reopen.
Thank you for this nice project. Im a beginner at programming, so this helped me a lot to build something that can control my desk / room lights based on ingame events.
Would it be possible to add an example how i can write back values to things like
PROP RPM:index or GENERAL ENG THROTTLE LEVER POSITION:index
?
Similar to your example with the toggle event for the Gear which helped me a lot. I tried to figure it out through the SDK Examples but that was a bit too overwhemling for my beginner level.