Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

  • *Users: 1
  • *Guests: 13
  • *Total: 14

Our Discord

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

Offline Stinger2k2

  • Forum GURU
  • *
  • Posts: 15
  • 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

  • Forum GURU
  • *
  • Posts: 15
  • 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,824
    • 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:

 

FlightSimExpo 2019

FsExpo

Recent Posts

Complete 200 degree curved visual system with projectors
by fsaviator
[Today at 04:25:12 PM]
Bernard...info
by Garys
[Today at 12:12:02 PM]
For Sale GoFlight Jet Console, 2 Private Pilot Racks all with GoFlight Modules.
by blueskydriver
[Today at 11:26:43 AM]
Old Projector(s)
by fsaviator
[Today at 10:53:59 AM]
OEM 737NG project - Long overdue update
by Karl737
[April 19, 2019, 09:56:23 PM]
CPFlight 737 NG MCP Pro and Efis Pro
by patiju
[April 19, 2019, 06:14:33 PM]
Goflight Airliners collection stuff for sale
by Steenos
[April 19, 2019, 03:22:12 PM]
German B738NG Homecockpit-Projekt
by Joe Lavery
[April 19, 2019, 04:59:21 AM]
Teensy LC Throttle Quadrant
by RayS
[April 18, 2019, 03:38:14 PM]
FSDream Team Couatl crashes when shutting down computers - any ideas
by navymustang
[April 18, 2019, 08:25:11 AM]
FLIGHTSIMEXPO RELEASES 2019 SPEAKER SCHEDULE, ANNOUNCES NEW PARTNERSHIP WITH EAA
by 757Simulator
[April 18, 2019, 04:20:53 AM]
737-800 Arduino X-Plane Build
by kurt-olsson
[April 17, 2019, 05:10:03 AM]
Teensy as Joystick
by kurt-olsson
[April 16, 2019, 01:54:29 PM]
Which Processor i7 - 8700K or i7 - 9700K
by Joe Lavery
[April 15, 2019, 04:00:33 PM]
Computer / Projector Combo
by blueskydriver
[April 15, 2019, 02:50:24 PM]
Flyengravity desktop MIP
by Steenos
[April 15, 2019, 02:22:39 PM]
TV Screen Position
by Trevor Hale
[April 15, 2019, 07:17:07 AM]
Join me on Vatsim Tonight
by Trevor Hale
[April 14, 2019, 05:07:50 PM]
Interfacing real instruments in p3d
by Steve Mount
[April 14, 2019, 04:56:08 PM]
Flight Sim Visual System on Public Surplus...
by bernard S
[April 14, 2019, 12:53:56 PM]
Aerosoft Australia 747 MCP
by 737simAdelaide
[April 14, 2019, 05:16:58 AM]
CPFlight 737 EL MCP For Sale
by 737simAdelaide
[April 14, 2019, 05:12:54 AM]
CPflight radios B737.
by avan1001
[April 14, 2019, 04:12:07 AM]
Anyone can recognize this material?
by 757Simulator
[April 14, 2019, 03:21:26 AM]
F18 military trainer cockpit for sale
by navymustang
[April 13, 2019, 10:19:06 PM]
FLIGHT ILLUSION gauges
by patiju
[April 13, 2019, 12:58:25 PM]
wanted FDS CDU
by 757Simulator
[April 13, 2019, 03:35:00 AM]
CAD assistance
by Timothy Denner
[April 12, 2019, 11:30:41 PM]
737 MAX
by mickc
[April 12, 2019, 07:20:35 PM]
Cpflight MCP737PRO
by Trevor Hale
[April 12, 2019, 09:12:36 AM]