Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

  • *Users: 1
  • *Guests: 23
  • *Total: 24

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

Offline Stinger2k2

  • CockpitBuilder
  • *
  • Posts: 6
  • Aviation Enthusiast
  • First Name: Keith
  • Home Location: Bexhill
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: 6
  • Aviation Enthusiast
  • First Name: Keith
  • Home Location: Bexhill
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,108
    • 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
http://www.cockpitbuilders.com

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

 

Recent Posts

Incident Parts
by mickc
[Today at 06:49:16 PM]
Does anyone sell access to their sim as a business?
by fsaviator
[Today at 10:33:47 AM]
Simionic G1000 app....which ipad?
by Stinger2k2
[Today at 08:56:20 AM]
Go Flight Landing gear panel
by Pilotito84
[February 20, 2017, 10:54:34 PM]
Saitek Radio panel
by Pilotito84
[February 20, 2017, 10:53:24 PM]
B747/767 XPDR, NAV, VHF modules
by Pilotito84
[February 20, 2017, 10:51:51 PM]
Trevor you were right....
by Trevor Hale
[February 20, 2017, 12:54:09 PM]
FSUIPC For Dummies
by Trevor Hale
[February 20, 2017, 12:49:52 PM]
More (or similar) 836x overheat issues
by Mach7
[February 20, 2017, 12:16:16 PM]
Software add on (RAAS)
by Bob Reed
[February 19, 2017, 08:55:32 PM]
NG Korry's Bulbs or LED's?
by mickc
[February 19, 2017, 09:18:40 AM]
This weekend
by jackpilot
[February 19, 2017, 08:49:38 AM]
Shake and rattle Take off
by jackpilot
[February 18, 2017, 02:05:27 PM]
Frustration to the limit!
by Flying_Fox
[February 18, 2017, 12:30:48 PM]
For sale Prosim737 Suite SOLD
by nigel27
[February 18, 2017, 12:15:23 AM]
Hello from NL, C90 sim project
by rvdm
[February 17, 2017, 03:32:22 AM]
F-18 simpit builder
by Trevor Hale
[February 17, 2017, 01:45:33 AM]
Wanted: F-18 parts
by Fcoq
[February 16, 2017, 08:30:50 AM]
My Boeing 737-800 cockpit
by Winstonc
[February 15, 2017, 08:17:02 PM]
SST30I
by ColinB
[February 15, 2017, 03:24:03 PM]
F/A-18C build
by Chain
[February 15, 2017, 08:50:22 AM]
Crash on 3.46 startup
by dalpi
[February 15, 2017, 06:55:27 AM]
http://flightsimcon.com/ ?
by bernard S
[February 14, 2017, 04:19:12 PM]
F-18 cockpit(s) for sale
by navymustang
[February 14, 2017, 03:08:56 PM]
Projector colour Matching & alignment.
by brianwilliamson
[February 14, 2017, 02:29:38 PM]
Hi from Austria
by Bob Reed
[February 13, 2017, 05:03:40 PM]
opencockpits OVH dual brightness annunciators
by airupthere
[February 13, 2017, 04:46:30 PM]
How to increase an Lvar value by 6 or -6 ? - ANSWERED
by Trevor Hale
[February 13, 2017, 07:16:14 AM]
Oxygen Mask Stowage Box - brown
by bernard S
[February 12, 2017, 04:00:54 PM]
"WANTED" IPECO pilot seat bottom cushion
by bernard S
[February 12, 2017, 11:13:57 AM]