Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

  • *Users: 0
  • *Guests: 15
  • *Total: 15

Our Discord

Author Topic: How to increase an Lvar value by 6 or -6 ? - ANSWERED  (Read 1252 times)

Offline Stinger2k2

  • Forum GURU
  • *
  • Posts: 15
  • Aviation Enthusiast
  • First Name: Keith
  • Home Location: Bexhill , England
How to increase an Lvar value by 6 or -6 ? - ANSWERED
« on: February 11, 2017, 10:41:26 AM »
Hi,

I am trying to increase the value of my Lvar in increments of 6 from 0-354.

Whats the LUA code for this as my existing code results in
an error saying that I am trying to perform arithmetic on a string.

Heres what I wrote....

function AltPlusSlow
if ipc.readLvar("name") == 354 then
ipc.writeLvar("name", 0) else
ipc.writeLvar("name" +6)
end
end

thanks for looking!

cheers
Stinger
« Last Edit: February 13, 2017, 04:41:05 AM by Stinger2k2 »

Offline Stinger2k2

  • Forum GURU
  • *
  • Posts: 15
  • Aviation Enthusiast
  • First Name: Keith
  • Home Location: Bexhill , England
Re: How to increase an Lvar value by 6 or -6 ?
« Reply #1 on: February 13, 2017, 04:40:22 AM »
Okay now,
A kind fellow on another forum helped me sort it out.
It just needed me to write in a local var.
The code now looks something like this....

function AltPlusSlow
local var = ipc.readLvar("name")
   if var = 354 then
ipc.writeLvar("name", 0)
else
var = var +6
ipc.writeLvar("name", var)
end
end

Sorry for sounding like a coding newbie but
that's exactly what I am !! lol.
cheers
Stinger

Offline Trevor Hale

  • Administrator
  • I am chained to this website!
  • *
  • Posts: 3,832
    • Cockpitbuilders.com
  • First Name: Trevor
  • Home Location: New Liskeard, Ontario
Re: How to increase an Lvar value by 6 or -6 ? - ANSWERED
« Reply #2 on: February 13, 2017, 07:16:14 AM »
Don't be sorry. We all appreciate you posting your answers here.


Thank you.
Trevor Hale

Owner
http://www.cockpitbuilders.com

Director of Operations
Worldflight Team USA
http://www.worldflightusa.com

VATSIM:

 

FlightSimExpo 2019

FsExpo

Recent Posts

What have you done for your simulator today?
by blueskydriver
[Today at 07:28:19 PM]
GSX across networked client visual computers
by zillmer
[Today at 05:38:53 PM]
Jetmax TQ - motorized it?
by FredK
[Today at 07:58:36 AM]
Mickey's Flightdeck - A Boeing 737-800 Cockpit on Youtube
by Extraterra
[Today at 02:47:37 AM]
FDS CDU old
by kattz
[May 19, 2019, 01:13:46 PM]
Serial Key
by hiflight1
[May 19, 2019, 05:10:00 AM]
Join me on Vatsim Tonight
by Trevor Hale
[May 15, 2019, 01:58:50 PM]
Gauge circuit
by jackpilot
[May 15, 2019, 01:56:51 PM]
Prosim and RSP TQ interfacing
by jfuenmayor
[May 15, 2019, 08:53:22 AM]
Arduino Mega question Newbie
by Yair1956
[May 15, 2019, 02:23:57 AM]
f18 mfd
by bernard S
[May 14, 2019, 11:15:44 PM]
Multi-Projector color calibration
by fsaviator
[May 13, 2019, 04:32:23 PM]
Immersive Calibration Pro help?
by jskibo
[May 13, 2019, 09:22:00 AM]
X-Plane 737-800 Build
by kenrosefire
[May 12, 2019, 08:37:05 PM]
KBD03 Keyboard Emulator
by Yair1956
[May 12, 2019, 03:52:05 PM]
5 Position Rotary Spring return Switch
by Yair1956
[May 12, 2019, 03:09:25 PM]
Flyengravity desktop MIP
by patiju
[May 11, 2019, 05:11:05 PM]
Pfd display.
by Patt737
[May 08, 2019, 12:48:32 PM]
Mini Sim
by jskibo
[May 08, 2019, 08:36:28 AM]
F16 Simulator For Sale
by blueskydriver
[May 08, 2019, 12:14:40 AM]
Wanted: Collins Style radios
by jkbarr30
[May 07, 2019, 08:23:32 PM]
Crap! 26V on 5V backlight!
by Steenos
[May 07, 2019, 05:33:46 PM]
Complete 737-800 cockpit - moving sale
by Ed
[May 07, 2019, 08:01:22 AM]
Prosim 737 iOS help
by Aztrucker
[May 06, 2019, 11:56:30 PM]
Fly Elise Warping
by jskibo
[May 06, 2019, 11:14:31 AM]
CPFlight 737 NG MCP Pro and Efis Pro (SOLD)
by patiju
[May 05, 2019, 10:52:46 AM]
Operating System Blues
by 727737Nut
[May 03, 2019, 11:54:35 AM]
FOR SALE - 737 Sim items
by flymo
[May 02, 2019, 07:43:53 AM]
Cpflight MCP737PRO (SOLD)
by archen
[April 30, 2019, 02:07:33 PM]
737-800 Arduino X-Plane Build
by Trevor Hale
[April 29, 2019, 07:29:12 PM]