Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

  • *Users: 1
  • *Guests: 45
  • *Total: 46

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

Offline Stinger2k2

  • CockpitBuilder
  • *
  • Posts: 12
  • 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
  • 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,263
    • 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

Descent into NZQN (Queenstown NZ)
by Nlgravity
[Today at 12:02:22 AM]
PoKeys and Potentiometer Jitters
by ifeliciano
[October 19, 2017, 03:30:52 PM]
Correct Amber LEDs for 737 Overhead?
by MistyBlue
[October 19, 2017, 10:19:10 AM]
Greetings from Memphis TN
by XOrionFE
[October 18, 2017, 10:59:19 PM]
Worldflight 2017 Donations!
by Trevor Hale
[October 18, 2017, 07:01:34 PM]
737-800 Arduino X-Plane Build
by kurt-olsson
[October 18, 2017, 03:45:12 PM]
Prepar3D Version 4.0 Announced
by Trevor Hale
[October 18, 2017, 12:23:20 PM]
PFC Jetliner Column Yoke USB
by AngeloC
[October 18, 2017, 10:22:18 AM]
Minor Sim Milestone: I-1 on PilotEdge...
by Ed
[October 18, 2017, 07:09:43 AM]
New supplier for your sim
by Fcoq
[October 18, 2017, 01:42:47 AM]
Rob's 733 Sim
by 737NGer
[October 17, 2017, 12:41:53 PM]
727-200 sim for sale
by blueskydriver
[October 17, 2017, 01:33:47 AM]
Post Your Pit!!!! 1000 Member Show and Tell
by Nlgravity
[October 17, 2017, 01:10:33 AM]
For Sale B737 Circuit Breaker Panels Kit...
by jackpilot
[October 16, 2017, 09:16:13 PM]
P3D v4 and WideTraffic crashing
by Trevor Hale
[October 16, 2017, 04:11:26 PM]
Boeing 737-800 Next Generation Simulator
by jackpilot
[October 16, 2017, 08:13:26 AM]
Cockpits for Sale...mine?
by blueskydriver
[October 15, 2017, 11:48:20 PM]
Bezels and Panels For Sale - B738
by hillbilly20
[October 14, 2017, 04:54:37 AM]
Side views
by Bob Reed
[October 13, 2017, 05:51:07 PM]
Cockpit Seats for Sale $700 or obo.
by blueskydriver
[October 13, 2017, 02:40:48 PM]
full working huds for sale
by navymustang
[October 13, 2017, 09:44:08 AM]
Auto Brake Panel for 30 degree rotary switches
by ifeliciano
[October 12, 2017, 01:49:50 PM]
Hi guys - new here with a question
by Blackhawk
[October 12, 2017, 01:30:29 PM]
Backlit Knobs Source?
by ifeliciano
[October 12, 2017, 10:34:12 AM]
Rotary Switch with Encoder
by Coco737
[October 12, 2017, 09:50:48 AM]
737 Landing Light Bar - Anyone know where to get one?
by XOrionFE
[October 11, 2017, 08:30:05 PM]
Lego Sets for Cockpit Items...trading?
by blueskydriver
[October 11, 2017, 03:18:29 PM]
I'm now using EUR & USD in my shop
by Bob Reed
[October 11, 2017, 11:26:53 AM]
That Annoying 400Hz Tone
by 727737Nut
[October 11, 2017, 11:02:56 AM]
Jorge from NAVCOM
by navcom
[October 11, 2017, 09:44:31 AM]