Cockpitbuilders.com

sign up .

December 05, 2019, 09:53:19 pm

Login with username, password and session length
23 Guests, 2 Users
Members
Stats
  • Total Posts: 53571
  • Total Topics: 7170
  • Online Today: 162
  • Online Ever: 427
  • (December 01, 2019, 09:15:11 am)
Users Online
Users: 2
Guests: 23
Total: 25

COUNTDOWN TO WF2020


WORLDFLIGHT TEAM USA

Will Depart in...

Recent

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

February 11, 2017, 06:41:26 am Last Edit: February 13, 2017, 12:41:05 am by 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