Welcome to Cockpitbuilders.com. Please login or sign up.

April 18, 2024, 10:17:42 PM

Login with username, password and session length

PROUDLY ENDORSING


Fly Elise-ng
190 Guests, 0 Users
Members
  • Total Members: 4,154
  • Latest: xyligo
Stats
  • Total Posts: 59,640
  • Total Topics: 7,853
  • Online today: 203
  • Online ever: 582
  • (January 22, 2020, 08:44:01 AM)
Users Online
Users: 0
Guests: 190
Total: 190

COUNTDOWN TO WF2022


WORLDFLIGHT TEAM USA

Will Depart in...

Recent

Welcome

How to increase an Lvar value by 6 or -6 ? - ANSWERED

Started by Stinger2k2, February 11, 2017, 06:41:26 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Stinger2k2

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

Stinger2k2

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

Trevor Hale

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:

Like the Website ?
Support Cockpitbuilders.com and Click Below to Donate