FS2004 Local variable

#1
Hi!

I would like to create a relatively complex runway lighting. I'm doing it according this wiki article : http://www.fsdeveloper.com/wiki/index.php?title=Pilot_Activated_Lighting

I would like to "switch on" my lights by different triggers. First trigger is the daytime, than if a some freq-s are tuned (ILS, VOR on NAV1 or NAV2), maybe wind direction and velocity because I want to switch the lights according the active runway.

Normaly this all possible but my problem is we talk about approx. 2000 light sources (2 runways) and lot of them I should repeat due to the different triggers.
I have one idea in my mind. I create a local variable which I would write with the SETWRD command. I would set e.g.:
00 - no lights needed
31 - 31 runway direction
13 - 13 runway direction

I've tried to create a local variable but I can not make it work. COuld you please help? This is what I done so far:

----------START - vertex things ------------------

DRAW_TRI 7, 18, 13 ; poly=291 part=1
DRAW_TRI 0, 3, 9 ; poly=292 part=1
DRAW_TRI 9, 6, 0 ; poly=293 part=1
DRAW_TRI_END
BGL_RETURN


bplights_MasterScale_2 label BGLCODE

lightswitch label word
dw 0
dw 0
dw 0


LOCAL_BASE_32 lightswitch

IFIN1 nolights, 028ch, 2, 4 ; time of day is not daytime

SETWRD lightswitch, 1

nolights label BGLCODE


; Küszöb fények zöld része 31L ---------------------------------------------------------------------------------------------------------------------

SEPARATION_PLANE WrongWay, 24351, 0, -21926, -1953136

IFIN1 RWYlight1, 033bh, 1000, 2000

BGL_LIGHT LIGHT_NAV, -59.605, 0.100, -26.090, 20, 0.60, 0.40, 0ff004c0dh, 0.000000, 0.000000, 1.000000 ; source poly num = 3
BGL_LIGHT LIGHT_NAV, -59.605, 0.100, -20.290, 20, 0.60, 0.40, 0ff004c0dh, 0.000000, 0.000000, 1.000000 ; source poly num = 5

---------- END ------------------------------------------

Thank you!
 
#2
I was further trying to solve the problem above. I just need a last hint :)

The code below is somehow correct, it gets assembled by bglcompiler but it is not working as I want.

What I want to reach is that if it is not daytime than in the lightswitch local variable writes a '1', later this variable is referenced and check wether it is 0 or 1. If it is one than some lights appears. My problem is I do not know how to reference the local variable in the IFIN code.

Thanks for all your help!


lightswitch label word
dw 0
dw 0
dw 0


IFIN1 nolights, 028ch, 2, 4 ; time of day is not daytime
LOCAL_BASE_32 lightswitch
SETWRD 0h, 1
SETWRD 2h, 1
SETWRD 4h, 1

nolights label BGLCODE

LOCAL_BASE_32 lightswitch
IFIN1 kapcsol, 0h, 1, 1

BGL_LIGHT LIGHT_NAV, -0.083, 1.000, 0.083, 20, 0.60, 0.40, 0FFDEFF00h, 0.000000, 0.000000, 1.000000 ; source poly num = 1
BGL_LIGHT LIGHT_NAV, 1.917, 1.000, 0.083, 20, 0.60, 0.40, 0FFDEFF00h, 0.000000, 0.000000, 1.000000 ; source poly num = 14
BGL_LIGHT LIGHT_NAV, 3.917, 1.000, 0.083, 20, 0.60, 0.40, 0FFDEFF00h, 0.000000, 0.000000, 1.000000 ; source poly num = 15
BGL_LIGHT LIGHT_NAV, 5.917, 1.000, 0.083, 20, 0.60, 0.40, 0FFDEFF00h, 0.000000, 0.000000, 1.000000 ; source poly num = 16
BGL_LIGHT LIGHT_NAV, 7.917, 1.000, 0.083, 20, 0.60, 0.40, 0FFDEFF00h, 0.000000, 0.000000, 1.000000 ; source poly num = 17
BGL_LIGHT LIGHT_NAV, -2.083, 1.000, 0.083, 20, 0.60, 0.40, 0FFDEFF00h, 0.000000, 0.000000, 1.000000 ; source poly num = 18
BGL_LIGHT LIGHT_NAV, -4.083, 1.000, 0.083, 20, 0.60, 0.40, 0FFDEFF00h, 0.000000, 0.000000, 1.000000 ; source poly num = 19
BGL_LIGHT LIGHT_NAV, -6.083, 1.000, 0.083, 20, 0.60, 0.40, 0FFDEFF00h, 0.000000, 0.000000, 1.000000 ; source poly num = 20
BGL_LIGHT LIGHT_NAV, -8.083, 1.000, 0.083, 20, 0.60, 0.40, 0FFDEFF00h, 0.000000, 0.000000, 1.000000 ; source poly num = 21


kapcsol label BGLCODE



BGL_RETURN
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#3
Hi,

At first sight your code looks ok, the switching to the local variable base seems fine. I am not behind my FS pc now, so can't test the code.

One thought, if you just copy the time of day to the local variable, why not use time of day directly?
 
#4
Thanks Arno

This code is only for learning. I want to have two runways lights together switching on for different things. If i use one variable than I don't have to copy the hundreds of lights several times.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#5
Hi,

Was this your entire code or just a snippet? You need to make sure that you jump over the code that defines the local variable block, FS can't process that as normal scenery.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#7
Try something like this:

Code:
BGL_JUMP_32 skipBlock

lightswitch label word
dw 0
dw 0
dw 0

skipBlock label word

IFIN1 nolights, 028ch, 2, 4 ; time of day is not daytime
LOCAL_BASE_32 lightswitch
SETWRD 0h, 1
SETWRD 2h, 1
SETWRD 4h, 1

nolights label BGLCODE

LOCAL_BASE_32 lightswitch
IFIN1 kapcsol, 0h, 1, 1

BGL_LIGHT LIGHT_NAV, -0.083, 1.000, 0.083, 20, 0.60, 0.40, 0FFDEFF00h, 0.000000, 0.000000, 1.000000 ; source poly num = 1
BGL_LIGHT LIGHT_NAV, 1.917, 1.000, 0.083, 20, 0.60, 0.40, 0FFDEFF00h, 0.000000, 0.000000, 1.000000 ; source poly num = 14
BGL_LIGHT LIGHT_NAV, 3.917, 1.000, 0.083, 20, 0.60, 0.40, 0FFDEFF00h, 0.000000, 0.000000, 1.000000 ; source poly num = 15
BGL_LIGHT LIGHT_NAV, 5.917, 1.000, 0.083, 20, 0.60, 0.40, 0FFDEFF00h, 0.000000, 0.000000, 1.000000 ; source poly num = 16
BGL_LIGHT LIGHT_NAV, 7.917, 1.000, 0.083, 20, 0.60, 0.40, 0FFDEFF00h, 0.000000, 0.000000, 1.000000 ; source poly num = 17
BGL_LIGHT LIGHT_NAV, -2.083, 1.000, 0.083, 20, 0.60, 0.40, 0FFDEFF00h, 0.000000, 0.000000, 1.000000 ; source poly num = 18
BGL_LIGHT LIGHT_NAV, -4.083, 1.000, 0.083, 20, 0.60, 0.40, 0FFDEFF00h, 0.000000, 0.000000, 1.000000 ; source poly num = 19
BGL_LIGHT LIGHT_NAV, -6.083, 1.000, 0.083, 20, 0.60, 0.40, 0FFDEFF00h, 0.000000, 0.000000, 1.000000 ; source poly num = 20
BGL_LIGHT LIGHT_NAV, -8.083, 1.000, 0.083, 20, 0.60, 0.40, 0FFDEFF00h, 0.000000, 0.000000, 1.000000 ; source poly num = 21

kapcsol label BGLCODE

BGL_RETURN
 
#8
Thank you Arno! That made the trick. Another step toward my goal.

So to summarize, at the beginning of the code you have to define the local variable with a skip block, than if I want to read/write to that variable I need to use the LOCAL_BASE_32 "variable name" command.

Thanks!

The next challenge is the sequenced flashing light...
 
#9
Hi Arno,

maybe I'm getting crazy. Yesterday I've checked the result it worked. Today I checked again. Now the lights are always on beside they should not be on during daylight. What can be the problem?
 
Top