Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

  • *Users: 0
  • *Guests: 12
  • *Total: 12

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

Offline Stinger2k2

  • CockpitBuilder
  • *
  • Posts: 9
  • 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: 9
  • 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,179
    • 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

Fresh out of the Paint Booth....... aaaaand there goes an engine.
by RayS
[Today at 02:54:14 AM]
Immersive Calibration Pro........HELP.
by tennyson
[March 25, 2017, 04:19:50 PM]
737 MIP and best monitor layout
by jackpilot
[March 25, 2017, 11:48:22 AM]
New Low cost Company in Canada
by Flying_Fox
[March 24, 2017, 03:56:47 PM]
Jetmax 777SK $2800
by fly747s
[March 23, 2017, 07:41:58 PM]
Hello from Oakville Canada
by JayJay
[March 23, 2017, 03:23:49 PM]
German B738NG Homecockpit-Projekt
by MjTom
[March 23, 2017, 12:11:00 PM]
Cleaning OEM panels
by jackpilot
[March 23, 2017, 09:01:38 AM]
220 FOV screen
by blueskydriver
[March 23, 2017, 08:16:18 AM]
Need FS Panel Studio and FSUIPC
by Goodenough
[March 23, 2017, 07:14:40 AM]
Custom panels for your sim
by Fcoq
[March 22, 2017, 07:12:21 PM]
More (or similar) 836x overheat issues
by iwik
[March 22, 2017, 07:04:17 PM]
Using GF radio "guts" for 737 radio?
by mynamismatt
[March 22, 2017, 03:37:17 PM]
Cockpitbuilders EULA UPDATE MARCH 22nd, 2017
by Trevor Hale
[March 22, 2017, 09:34:35 AM]
APU won't stay lit
by airupthere
[March 21, 2017, 01:15:49 PM]
AFT OVH for sale (SOLD)
by jackpilot
[March 21, 2017, 10:47:17 AM]
New AFT OVH
by jackpilot
[March 21, 2017, 10:43:53 AM]
EVAC and Flight recorder panels
by jackpilot
[March 20, 2017, 09:41:57 PM]
fs2004
by Goodenough
[March 20, 2017, 08:14:21 PM]
WANTED: J Rails for Weber seats
by MjTom
[March 20, 2017, 06:32:23 AM]
The Beech 99 to KA350i Project!
by Trevor Hale
[March 19, 2017, 05:28:20 PM]
Install a servo in OEM gauge
by kurt-olsson
[March 18, 2017, 06:18:01 AM]
Opencockpits 737 gear lever
by pierclav
[March 18, 2017, 02:11:04 AM]
How's the smartest builders in the world?
by fsaviator
[March 18, 2017, 12:05:15 AM]
Picked up the keys for her today...
by RayS
[March 17, 2017, 11:20:23 PM]
Wanted...B727 Second Officer Seat and Rails...
by AVIATor-Olav
[March 17, 2017, 02:02:34 PM]
B747-400
by Goodenough
[March 16, 2017, 08:36:15 PM]
A must have on Ebay for the MOST SERIOUS of builders
by simlady/ Karen
[March 16, 2017, 08:13:23 PM]
Phidget 64 Led
by Ed
[March 16, 2017, 10:04:31 AM]