Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

  • *Users: 1
  • *Guests: 40
  • *Total: 41

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

Offline Stinger2k2

  • CockpitBuilder
  • *
  • Posts: 12
  • Karma: +0/-0
  • 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
  • Karma: +0/-0
  • 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,325
  • Karma: +19/-0
    • 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:

 

Recent Posts

My Simming Year in Review
by Trevor Hale
[Today at 10:58:23 AM]
Shell MIP Move
by jackpilot
[Today at 08:43:09 AM]
Wanted: parts of yoke
by gufau
[Today at 04:36:13 AM]
Upgrading my PC. Will this work?
by Caflyt
[December 15, 2017, 04:23:09 PM]
737-800 Arduino X-Plane Build
by kurt-olsson
[December 15, 2017, 12:45:44 PM]
Weather set problem
by luisgordo
[December 15, 2017, 09:25:08 AM]
737 Document Holder
by GarethH
[December 15, 2017, 06:52:16 AM]
Mickey's Flightdeck - A Boeing 737-800 Cockpit on Youtube
by B747-400
[December 15, 2017, 06:21:29 AM]
Lian Li Purchase?
by ifeliciano
[December 15, 2017, 01:17:30 AM]
WANTED: Real 737 Dual Linked Yokes
by bernard S
[December 14, 2017, 04:23:52 PM]
So this thing is on it's way....
by RayS
[December 13, 2017, 10:42:56 PM]
Older USB CPFlight MCP for sale
by jr2mey
[December 13, 2017, 08:35:25 AM]
RAL 7011 - Paint Options
by GarethH
[December 13, 2017, 08:20:51 AM]
Sismo IRS Panel - Anyone Have One?
by blueskydriver
[December 13, 2017, 08:01:17 AM]
737 control columns Capt & FO
by Joe Lavery
[December 13, 2017, 06:14:31 AM]
Gas strut newton for elevation
by Trevor Hale
[December 11, 2017, 05:11:30 PM]
MIP Dimmer Panels
by ifeliciano
[December 11, 2017, 01:51:13 PM]
New supplier for your sim
by Fcoq
[December 11, 2017, 02:59:18 AM]
Got My Flightdeck Solutions Oxygen Panels...
by blueskydriver
[December 10, 2017, 12:35:54 AM]
737 Aft Overhead EEC Switches - Where do I get one?
by MistyBlue
[December 09, 2017, 01:53:43 PM]
P3D v3 Verus P3D V4 ?
by Bob Reed
[December 09, 2017, 09:39:42 AM]
Boeing 737-800 Next Generation Simulator
by fsaviator
[December 09, 2017, 07:59:51 AM]
PFC Jetliner Column Yoke USB -SOLD-
by blueskydriver
[December 08, 2017, 06:46:26 PM]
Interfacing BENDIX/KING KMD-150 GPS and X-Plane
by RayS
[December 07, 2017, 07:56:39 PM]
CraigSim 737 update
by fsaviator
[December 07, 2017, 07:30:58 PM]
Question for those that have converted real TQs
by kurt-olsson
[December 07, 2017, 04:50:44 PM]
Jorge from NAVCOM
by Bob Reed
[December 07, 2017, 12:12:12 PM]
Cockpitbuilders roofing services llc
by Trevor Hale
[December 07, 2017, 10:39:29 AM]
Shopping at AliExpress or Alibaba - Your experiences
by Sam Llorca
[December 07, 2017, 10:35:12 AM]
PA34 Seneca Wings on VC
by jackpilot
[December 07, 2017, 07:54:51 AM]