Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Increase and decrease variables

Featured Replies

Hello, I am trying to work with a cockpit dial that has values of 0, 1, 2, 3, and 4.  I would like to map two buttons on my HOTAS to either increment the variable by 1, or decrease it by one for each press.  So far, I have this code that works to increment the variable correctly with each press, though it does not stop when reaching 4.

0 1 2 3 4 (L:RIO_RADAR_RANGE, Number) 5 seq (>L:RIO_RADAR_RANGE, Number)

I have not found a way to decrease the variable after setting it this way.

I have tried these also to increase and decrease the variable, but wasn't able to get either to work.

(L:RIO_RADAR_RANGE:0, Number) 1 + (>L:RIO_RADAR_RANGE)

(L:RIO_RADAR_RANGE:0, Number) 1 - (>L:RIO_RADAR_RANGE)

I must be missing something but can't figure out out, any suggestions as to what I am missing?

 

 

  • Commercial Member
5 hours ago, MikeWest said:

I must be missing something

1. Your variable assignments are missing the unit. The way your scripts are written now, you are reading from a different variable than writing to.
2. I would add min and max operators to limit the range
3. Are you sure about the ":0" index? It is not present in your first script, which you say is working?

(L:RIO_RADAR_RANGE, Number) ++ 4 min (>L:RIO_RADAR_RANGE, Number)

(L:RIO_RADAR_RANGE, Number) -- 0 max (>L:RIO_RADAR_RANGE, Number)

Edited by Lorby_SI

LORBY-SI

  • Author
19 hours ago, Lorby_SI said:

3. Are you sure about the ":0" index? It is not present in your first script, which you say is working?

You are correct, that was from an earlier attempt that didn't work, without that index the script did work.

But

The suggestion and code including the min and max worked perfectly, thank you very much!  Knowing the correct syntax has helped me add a few more scripts and is greatly appreciated.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.