Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

  • *Users: 1
  • *Guests: 51
  • *Total: 52

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

Offline Stinger2k2

  • CockpitBuilder
  • *
  • Posts: 10
  • 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: 10
  • 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,213
    • 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

Attention All Members and Guests
by Erj145sim
[Today at 03:02:57 PM]
Oasis 737 Project
by Garys
[Today at 02:16:35 PM]
Former RC airplane pilots...need your help!
by Trevor Hale
[Today at 07:22:18 AM]
de Havilland Beaver Sim Pics
by FSAddon_boss
[Today at 04:01:52 AM]
My Hangar
by fsaviator
[April 28, 2017, 10:03:37 AM]
Hello From Malta
by Trevor Hale
[April 28, 2017, 09:48:02 AM]
Help: Interfacing a Prop Sync indicator...
by Trevor Hale
[April 28, 2017, 09:34:31 AM]
New TQ
by Caflyt
[April 28, 2017, 05:05:14 AM]
New AFT OVH
by MLeavy737
[April 27, 2017, 10:59:02 AM]
eBay is making me go broke again...
by RayS
[April 26, 2017, 05:33:03 PM]
Rotary with a button
by Erj145sim
[April 26, 2017, 03:48:02 PM]
Poor Airplane....
by Joe Lavery
[April 26, 2017, 02:19:19 PM]
New supplier for your sim
by jackpilot
[April 26, 2017, 01:57:06 PM]
10.4 LCD Source?
by Erj145sim
[April 26, 2017, 11:49:42 AM]
Flightdeck Solutions still the best IMHO
by Trevor Hale
[April 26, 2017, 04:40:47 AM]
Autoland at Bergen airport (ENBR)
by jackpilot
[April 25, 2017, 11:26:51 PM]
Phidgets Advanced Servo 8-Motor Card
by pierclav
[April 25, 2017, 10:40:23 PM]
737NG Single Seat Trainer "Starter Kit" :-)
by emstar
[April 25, 2017, 03:12:41 PM]
Engravity glarewings set for sale
by scojj
[April 23, 2017, 06:00:01 AM]
CPFlight MIP board
by scojj
[April 23, 2017, 05:57:42 AM]
CPFlight MIP737ICS and project magenta : gauges issue.
by scojj
[April 23, 2017, 05:54:18 AM]
Life of a Veteran Airplane
by iwik
[April 22, 2017, 04:09:57 PM]
Boeing 737NG parts: OVH, MIP and Yoke
by rtopinka
[April 21, 2017, 06:41:23 PM]
SEP/MEP 3DOF motion simulator for sale
by rtopinka
[April 21, 2017, 05:09:36 PM]
Cockpit Parts
by goirishgo1083
[April 20, 2017, 02:52:50 PM]
X-Plane 11 multi-monitor & Fly Elise-ng - tuto
by pierrevw
[April 18, 2017, 05:48:32 PM]
KIng Air yokes
by RayS
[April 18, 2017, 05:40:03 PM]
I Need A Particular Photo.......
by FredK
[April 17, 2017, 03:05:10 PM]
Looking for FDS G2 EFIS Unit
by Trevor Hale
[April 17, 2017, 02:56:23 PM]
737 Overhead frame.
by kurt-olsson
[April 17, 2017, 01:17:07 PM]