Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

  • *Users: 3
  • *Guests: 70
  • *Total: 73

Our Discord

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

Offline Stinger2k2

  • CockpitBuilder
  • *
  • Posts: 14
  • 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: 14
  • 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,727
    • 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

Wrong hiegth above ground when landing and P3D set for Panel Only
by navymustang
[Today at 08:30:23 AM]
12v power supply for map light
by Joe Lavery
[Today at 07:45:52 AM]
Windscreen/windshield Wipers
by blueskydriver
[Today at 03:32:37 AM]
B767 MIP
by Goodenough
[January 16, 2019, 09:13:23 PM]
STEERING AND YOKE 737 PROMO
by blueskydriver
[January 16, 2019, 06:07:16 PM]
Join me on Vatsim Tonight
by Trevor Hale
[January 16, 2019, 05:53:50 PM]
YOU CAN HELP SHAPE FLIGHTSIMEXPO: 2020
by Trevor Hale
[January 16, 2019, 01:10:08 PM]
Streaming with Elgato tools.
by RayS
[January 15, 2019, 03:43:59 PM]
Help in building a GTN 650/750 for Reality XP
by redman
[January 14, 2019, 01:02:57 PM]
What have you done for your simulator today?
by bernard S
[January 14, 2019, 12:05:01 PM]
Complete 737-800 cockpit - moving sale
by navymustang
[January 14, 2019, 11:07:28 AM]
Wanted: B737 Linked Yoke,
by dvst8r
[January 14, 2019, 10:55:31 AM]
Replace display Flyengravity CDU
by flymo
[January 13, 2019, 01:10:55 PM]
It's been a while. a new picture of my baby!
by Trevor Hale
[January 13, 2019, 09:21:19 AM]
Mickey's Flightdeck - A Boeing 737-800 Cockpit on Youtube
by blueskydriver
[January 13, 2019, 08:25:21 AM]
Three Projector 210 degree with P3D4
by blueskydriver
[January 10, 2019, 04:12:26 AM]
Aircraft Registration Placard
by jackpilot
[January 07, 2019, 10:19:13 AM]
How do you manage power amperage for your sim
by kurt-olsson
[January 07, 2019, 10:12:23 AM]
Trim Wheels
by Joe Lavery
[January 07, 2019, 04:18:15 AM]
ActiveSky - across networked PCs anyone
by FredK
[January 06, 2019, 10:54:28 PM]
ACE 737 Pro Yoke stab trim switch issue help needed
by dornier
[January 06, 2019, 08:23:42 PM]
Help In wiring LED and Fan
by GyverX
[January 06, 2019, 03:54:28 PM]
737-800 Arduino X-Plane Build
by kurt-olsson
[January 06, 2019, 11:38:46 AM]
B737 OEM Throttle Quadrant and more to come
by archen
[January 05, 2019, 06:27:11 PM]
Wanted: 737 FMC/CDU
by blueskydriver
[January 04, 2019, 07:35:04 PM]
Other forums ?
by navymustang
[January 03, 2019, 05:51:20 PM]
FLIGHTSIMEXPO LAUNCHES DISCOUNTED ADVANCE REGISTRATION FOR ORLANDO 2019 EVENT
by Slacker
[January 03, 2019, 09:52:14 AM]