Jump to content
The simFlight Network Forums

Georgy

Members
  • Posts

    15
  • Joined

  • Last visited

Posts posted by Georgy

  1. On 5/31/2023 at 1:05 AM, Georgy said:
    time1 = ipc.elapsedtime()
    	time2 = 0
    
    	if timebutton(false) then
    		-- First press / release counts: see if there's another
    		if timebutton(true) then
    			-- got another press in time, look for release
    			if timebutton(false) then
    				-- this was a double press, send VIEW RIGHT
    				ipc.control()
                    ignorepress = true --  ignore the next press we receive, i.e. the 2nd in a double-press 
    			end
    		else	
    			-- This was a single press, send VIEW LEFT 
    			ipc.control(67279)
    			ignorepress = false
    		end
    	else
    		-- This was a longer press, send VIEW FORWARD
    		ipc.control(65861)
    	end

    What strings (lines) can I delete?

    I'm sorry. Can You help me? I don't know which lines I can delete, if i need one action (hold press), or 2 actions (hold press and single press) only.

  2. On 5/31/2023 at 12:58 AM, Georgy said:

    I'm sorry... I used a translator

    I would like to do this:

    1. In a Boeing 737, I do gear up.

    2. Wheels retract

    3. After 10 seconds, the gear lever automatically switches to off mode.

    I was able to do it.
    Assigned "gear up" to physical lever without lua script.
    In tripleuse.lua assigned only one action (hold press): move virtual lever to position "gear off" after 10 seconds when the physical lever is up.

  3. 7 hours ago, John Dowson said:

    Or, better still, remove the code that handles a double-press completely if not using this.

    time1 = ipc.elapsedtime()
    	time2 = 0
    
    	if timebutton(false) then
    		-- First press / release counts: see if there's another
    		if timebutton(true) then
    			-- got another press in time, look for release
    			if timebutton(false) then
    				-- this was a double press, send VIEW RIGHT
    				ipc.control()
                    ignorepress = true --  ignore the next press we receive, i.e. the 2nd in a double-press 
    			end
    		else	
    			-- This was a single press, send VIEW LEFT 
    			ipc.control(67279)
    			ignorepress = false
    		end
    	else
    		-- This was a longer press, send VIEW FORWARD
    		ipc.control(65861)
    	end

    What strings (lines) can I delete?

  4. 4 minutes ago, John Dowson said:

    Why? The preset is a name, and the documentation for this function is:

    The only number needed is the parameter, if the preset uses one (most don't).

    John

    Thank You!

    Tell me please how to implement such a function: I raise the chassis crane in 737 (Thrustmaster Boeing), the lever presses the button all the time. After 10 seconds, the second action is activated: the lever itself is transferred to the off position. Sorry for my bad English)

  5. 16 minutes ago, John Dowson said:

    Вы не можете сделать это сами? Почему бы вам просто не попробовать запустить его и использовать предоставленные средства отладки, если у вас возникнут какие-либо проблемы.

     

    I meant, did I enter the action correctly in brackets and quotes? Shouldn't there be numbers?

  6. 4 minutes ago, John Dowson said:

    No, that won't work, as you are changing the variable value. You can use one script if you know what you are doing (I am not going to explain this to you...!), but it is probably easier to use a separate script for each button.

    What don't you understand? Your script contains the following lines to execute the control/event:
              ipc.control(67279)
    So that sends the control AUTO_THROTTLE_DISCONNECT. To send a preset instead, change that to:
             ipc.execPreset("presetName")
    where presetName is the name of the preset. Or add the parameter if the preset uses one, e.g. ipc.execPreset("presetName", param)

    John

    Please, check this code):

    joy = 3
    btn = 8
    interval = 100 -- 1/2 second press, gap, press limits
    ignorepress = false
    
    -- Function to time the button being pressed or left released
    -- Allow only up to "interval" till decide no change
    local function timebutton(test)
      while true do
    		time2 = ipc.elapsedtime()
    		if (time2 - time1) > interval then
    			ignorepress = false
    			return false
    		end
    	 	if ipc.testbutton(joy, btn) == test then
    			time1 = time2
    			return true
    		end
    	 	ipc.sleep(20)
    	end
    end
    
    function buttonpress(j, b, du)
    	if ignorepress then
    		ignorepress = false
    		return
    	end
      
    	-- Note time button was pressed
    	time1 = ipc.elapsedtime()
    	time2 = 0
    
    	if timebutton(false) then
    		-- First press / release counts: see if there's another
    		if timebutton(true) then
    			-- got another press in time, look for release
    			if timebutton(false) then
    				-- this was a double press, send VIEW RIGHT
    				ipc.control()
                    ignorepress = true --  ignore the next press we receive, i.e. the 2nd in a double-press 
    			end
    		else	
    			-- This was a single press, send VIEW LEFT 
    			ipc.execPreset("PMDG_B737-7_FUEL_CUT_OFF_LEVER1_UP")
    			ignorepress = false
    		end
    	else
    		-- This was a longer press, send VIEW FORWARD
    		ipc.execPreset("PMDG_B737-7_FUEL_CUT_OFF_LEVER1_DN")
    	end
    end
    
    -- Enable event on button being pressed (only)
    event.button(joy, btn, 1, "buttonpress")

     

  7. Thank You, John! I thought maybe you did another way)
    AT Disengage (67279) and TOGA (65861) I did! Thank you! Code:

    joy = 3
    btn = 2
    interval = 100 -- 1/2 second press, gap, press limits
    ignorepress = false
    
    -- Function to time the button being pressed or left released
    -- Allow only up to "interval" till decide no change
    local function timebutton(test)
      while true do
    		time2 = ipc.elapsedtime()
    		if (time2 - time1) > interval then
    			ignorepress = false
    			return false
    		end
    	 	if ipc.testbutton(joy, btn) == test then
    			time1 = time2
    			return true
    		end
    	 	ipc.sleep(20)
    	end
    end
    
    function buttonpress(j, b, du)
    	if ignorepress then
    		ignorepress = false
    		return
    	end
      
    	-- Note time button was pressed
    	time1 = ipc.elapsedtime()
    	time2 = 0
    
    	if timebutton(false) then
    		-- First press / release counts: see if there's another
    		if timebutton(true) then
    			-- got another press in time, look for release
    			if timebutton(false) then
    				-- this was a double press, send VIEW RIGHT
    				ipc.control()
                    ignorepress = true --  ignore the next press we receive, i.e. the 2nd in a double-press 
    			end
    		else	
    			-- This was a single press, send VIEW LEFT 
    			ipc.control(67279)
    			ignorepress = false
    		end
    	else
    		-- This was a longer press, send VIEW FORWARD
    		ipc.control(65861)
    	end
    end
    
    -- Enable event on button being pressed (only)
    event.button(joy, btn, 1, "buttonpress")


    How do I manage the cut off valves? They work as presets. I don't know what code to enter.

     

    Unfortunately, the github page https://github.com/joeherwig/msfs-fsuipc-lua-scripts is not working.

×
×
  • 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.