Jump to content
The simFlight Network Forums

How to make aircraft moving?


Recommended Posts

Hello!

I'd like to create gauge which would work as WheelTUG - electrical engine in nose gear, which allows aircraft to taxi without jet engines. For steering I'd use tiller or rudder, but I need to simulate electrical engine.

 

I found, that it is almost impossible in XML gauge, because I can't write into velocity and acceleration variables. I try to combine XML with LUA and FSUIPC. LUA can read/write those variables (offsets).

 

LUA script looks like this:

 

1: ipc.writeDBL(0x3070, 10)
2: x = ipc.readDBL(0x3070)
3: ipc.writeLvar("WT_ACCEL", x)

 

line 1 - should set acceleration (I tried also with velocity 3190), but it doesn't or is immediately overwritten

line 2 and 3 - take offset and send via L:variable to XML script which shows actual acceleration value.

 

Reading works ok. But I can't write into this offset. I know, there are problems with it in FSX, but I use old good FS9, in which this should work.

 

Could you hint how to make aircraft moving without engines?

 

Regards,

Slawek

Link to comment
Share on other sites

I'd like to create gauge which would work as WheelTUG - electrical engine in nose gear, which allows aircraft to taxi without jet engines.

 

I think that's mostly done by actually moving the aircraft using the latitude/longitude values, or, easier, by using slewing.

 

LUA script looks like this:

 

1: ipc.writeDBL(0x3070, 10)

2: x = ipc.readDBL(0x3070)

3: ipc.writeLvar("WT_ACCEL", x)

 

line 1 - should set acceleration (I tried also with velocity 3190), but it doesn't or is immediately overwritten

line 2 and 3 - take offset and send via L:variable to XML script which shows actual acceleration value.

 

 

Why are you reading 3070 when you've just written it? If the write succeeds you should read back 10. If it doesn't there's no point. so why read it anyway?

 

I don't think you can have any significant affect on these things unless you keep writing them very fast -- because the Simulation engine will overwrite them on the next frame with its next computed value based on things like thrust. Moving things by magic means the magic needs to continuously override reality.

 

Reading works ok. But I can't write into this offset. I know, there are problems with it in FSX, but I use old good FS9, in which this should work.

 

I don't know if it "should" work or not. At the very least I would have thought you'd have to loop on that every, say, 20 or 30 mSecs, at least fast enough to beat the simulation rate. One person I do think would know is Herve Sors.

 

Regards

Pete

Link to comment
Share on other sites

Thanks for answer. As usual it was very helpful. I made progress. This loop works nice:

 

while ipc.readLvar("WHEELTUG_POWER") == 1 do  --> this is the power button
if ipc.readLvar("WT_FASTER") == 1 then  --> this checks the speed (speed can be changed during taxi)
    ipc.writeDBL(0x3070, 50)
else
    ipc.writeDBL(0x3070, -10)
end
    ipc.sleep(10)
    x = ipc.readDBL(0x3070)
    ipc.writeLvar("WT_ACCEL", x)
end

 

However, there is one problem: this works only if the speed of the aircraft is >0 at the beginning. In that case script keeps choosen speed. But the script is unable to move aircraft when speed at the beginning is 0. How to overcome this?

 

Another question: is it possible to start LUA script using L:variable? Is it possible through FSUIPC? (the idea is: I click the button in my XML gauge and then LUA is loaded).

 

WT_ACCEL variable is for better knowledge whether script actually works. Just for tests. It does nothing more.

Link to comment
Share on other sites

I found solution :-)

 

    if ipc.readLvar("WT_START_SPEED") > 0 then
        ipc.writeDBL(0x3090, ipc.readLvar("WT_START_SPEED"))
    end
 

This (added after first line) checks in XML whether GROUND SPEED is zero. If so, this will set some small speed, just to move aircraft. Then acceleration 0x3070 can handle it.

Link to comment
Share on other sites

Another question: is it possible to start LUA script using L:variable? Is it possible through FSUIPC? (the idea is: I click the button in my XML gauge and then LUA is loaded).

 

No, because only Lua plug-ins can read L:vars.

 

The thing to do is get your Lua loaded using an [Auto] section in the FSUIPC4.INI file, but wrap everything you've done in a function which is called by an event.Lvar call.

 

Regards

Pete

Link to comment
Share on other sites

Almost everything works ok*. My friend, who tests gauge for me found strange information in FSUIPC.log regarding to this LUA script:

  • attempt to call field 'readLvar' (a nil value)

I looks like LUA can't read L:Vars. Switches and buttons in gauge work properly, but LUA can't see this. What can be the cause of this? We both have FS9.1 and registered FSUIPC.

 

* - I have to deal with moving back - wheels turn, but aircraft doesn't. :-( No problem while moving forward.

 

Regards,

Slawek.

Link to comment
Share on other sites

Almost everything works ok*. My friend, who tests gauge for me found strange information in FSUIPC.log regarding to this LUA script:

  • attempt to call field 'readLvar' (a nil value)

I looks like LUA can't read L:Vars. Switches and buttons in gauge work properly, but LUA can't see this. What can be the cause of this? We both have FS9.1 and registered FSUIPC.

 

The current Lua library facilities most certainly can read and write LVars. The facilities are in widespread use.

 

If your call is "ipc.readLvar" then the error indicates that your version of FSUIPC is out of date -- you must always keep up to date. Facilities are added over a period, they didn't come into existence all at once.

 

The function readLvar only exists in the ipc library, and it is one of those not implemented in WideClient..

 

Regards

Pete

Link to comment
Share on other sites

Thanks, I'll ask friend about FSUIPC version.

I finished the gauge, however it will need some work.

I publish my LUA script. Maybe someone would be interested. I solved quite easily problem of turning while moving back.

 

local i = 1
while i == 1 do  --repeat forever
    while ipc.readLvar("WHEELTUG_POWER") == 1 do  --power on
        if ipc.readLvar("WT_START_SPEED") > 0 then  --we need a kick to start
            ipc.writeDBL(0x3090, ipc.readLvar("WT_START_SPEED"))
        end
        if ipc.readLvar("WT_START_SPEED") < 0 then   --the same to move back
            ipc.writeDBL(0x3090, ipc.readLvar("WT_START_SPEED"))
        end
    
        if ipc.readLvar("WT_FASTER") == 1 then   --this controls the speed
            ipc.writeDBL(0x3070, 20)
        else
            ipc.writeDBL(0x3070, -20)
        end
        
        if ipc.readLvar("WT_KNOB") == 1 then  --if knob is set to BACK, we need alternate steering (using rudder/tiller)
            if ipc.readUW(0x0BBC) < 20000 then
                turn = - ipc.readUW(0x0BBC) / 16383 * 10  
            elseif ipc.readUW(0x0BBC) > 20000 then
                turn = - ( ipc.readUW(0x0BBC) - 65532 ) / 16383 * 10  
            end
            ipc.writeDBL(0x3088, turn)
        end
        
        ipc.sleep(50)
    end

end

 

Thanks again for your help.

Regards,

Slawek.

Link to comment
Share on other sites

I finished the gauge, however it will need some work.

I publish my LUA script. Maybe someone would be interested. I solved quite easily problem of turning while moving back.

 

Could you re-work it as a User Contribution, in that subforum please? It will be available to others more easily then. Just explain what it is for, too. If you leave it here it will gradually scroll way out of sight forever ...

 

Thanks!

Pete

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.