Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

  • *Users: 2
  • *Guests: 50
  • *Total: 52

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

Offline Stinger2k2

  • CockpitBuilder
  • *
  • Posts: 12
  • 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

  • CockpitBuilder
  • *
  • Posts: 12
  • 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,246
    • 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

 

Recent Posts

Projector screens changing brightness
by blueskydriver
[Today at 12:03:32 AM]
Solenoid Engines Start Switch Installation
by zeineddine
[Today at 12:01:21 AM]
Back to School SALE event - 50% discount
by luisgordo
[August 16, 2017, 10:09:23 PM]
New here
by 737NGer
[August 16, 2017, 10:23:47 AM]
Telex 750 Headset 4 sale
by jackpilot
[August 15, 2017, 03:16:42 PM]
Boeing 737 Homecockpit parts
by mellox90
[August 14, 2017, 09:02:27 AM]
Hello from New US Based Supplier!
by navcom
[August 14, 2017, 05:44:37 AM]
737-800 Arduino X-Plane Build
by kurt-olsson
[August 13, 2017, 05:36:15 AM]
MH-60 Helicopter (retired Navy simulator) for sale
by navymustang
[August 11, 2017, 08:58:38 PM]
Oasis 737 Project
by 737NGer
[August 11, 2017, 05:11:40 PM]
Project Magenta sounds and PM Systems
by jr2mey
[August 11, 2017, 09:41:58 AM]
In search of this panel...
by XOrionFE
[August 09, 2017, 03:07:23 PM]
Mickey's Flightdeck - A Boeing 737-800 Cockpit on Youtube
by bernard S
[August 09, 2017, 08:21:22 AM]
Upgrade advice and final items clarification
by N606DL
[August 09, 2017, 06:19:22 AM]
XPlane and Avionics softwares.
by Ridgenj
[August 08, 2017, 08:59:32 PM]
Source for Color 5.7" LCD Flat Panels
by gjha97
[August 08, 2017, 12:38:20 PM]
back lite Lamps help needed
by jackpilot
[August 08, 2017, 11:19:56 AM]
CP flight, CDU, throttle
by Orphee
[August 06, 2017, 06:34:10 AM]
Extremely Close Call!
by Joe Lavery
[August 06, 2017, 02:34:29 AM]
P3D v4 Multi Channel
by Ed
[August 05, 2017, 10:38:44 PM]
German B738NG Homecockpit-Projekt
by kurt-olsson
[August 05, 2017, 09:12:08 AM]
mycockpit.org Gone?
by Bob Reed
[August 05, 2017, 08:05:51 AM]
Backlit Knobs Source?
by mickc
[August 04, 2017, 06:33:31 PM]
ActiveSky - across networked PCs anyone
by tennyson
[August 04, 2017, 08:46:21 AM]
Orlando Approach 17L - Working on Atmospheric Conditions & 3rd Party Airports
by Michael_B737_ATP
[August 04, 2017, 08:14:05 AM]
Go home Boeing, you're drunk....
by RayS
[August 03, 2017, 05:53:08 PM]
GoFlight Radio RMK (SOLD)
by jackpilot
[August 03, 2017, 08:38:35 AM]
767 ACE Yoke Aileron potentiometer replacement help !
by B747-400
[August 02, 2017, 04:17:26 PM]
Help me repair ACE yoke
by raam123
[August 02, 2017, 03:54:51 PM]
FDS OH Panels
by gufau
[August 01, 2017, 04:23:37 PM]