Announcement

Collapse
No announcement yet.

Tutorial: Introduction to Lua scripting

Collapse
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Not sure how to contact the authors of the scripting guide on Hoggit, but there is a typo on this page: https://wiki.hoggitworld.com/view/DC...etectedTargets
    It should be Controller.Detection instead of Conroller.Detection. For people who copy stuff from that site, it may save some time.

    Comment


      Hello, I am trying to get something to work in the ME.

      function getFuel ()
      local number = Unit.getFuel("test")
      if number < 0.4 then
      trigger.action.outText("returning true", 10)
      return true
      else
      trigger.action.outText("returning false", 10)
      return false
      end
      end
      I have this code in a Switch waypoint command Condition (LUA PREDICATE)

      It doesnt give an error but doesnt do anything else


      My modules:
      Spoiler:

      JF-17 | F-16C | FW190 A-8 | I-16 | MiG-19P | CE II | F-14 | YAK-52 | F/A-18C | AV-8B | AJS-37 | SPITFIRE LF MK. IX | F-5E | M-2000C | L-39 | MiG-15bis | C-101 | BF 109 K-4 | MiG-21BIS | FW 190 D-9 | F-86F | P-51D | A-10C | FC3 | SUPER CARRIER | SA342 | UH-1H | Mi-8MTV2 | KA-50 | PERSIAN GULF | NORMANDY | NEVADA | COMBINED ARMS | NS430 | CHANNEL MAP | P47

      Comment


        DCS does not return errors any more for some strange reasons (or only on special occasions). So your code might be faulty even when you have no errors in DCS.
        First of all make sure that you define a unit table correctly. E.g.
        Code:
        pUnit = Group.getByName( "Aircraft Group #001" ):getUnit( 1 )
        or
        Code:
        pUnit = Unit.getByName( "Test Unit #001" )
        In addition you should write
        Code:
        pUnit:getFuel()
        instead of
        Code:
        Unit.getFuel("test")

        Comment


          Are there any lib files or something like that in DCS folder that I can import to my project in LDT so I can use autocomplete functions and all that good stuff? Just starting on scripting simple stuff before trying out MOOSE. Have been using hoggit for reference, but if there's something like that in DCS it would be much better.

          Comment


            Suggest you pose your question in Moose Discord channel where you will find help aplenty. AFAIK (and I am a scripting novice) DCS has no such libraries. I believe the more proficient Moose script writers have developed script modules for creating tables of airfields, aircraft types, etc. that run at mission start.

            Comment


              Thank you, I'll take a look at that.

              Comment


                Originally posted by hu16flier
                ...
                Please open a new thread in the Mission Editor Discussion and Questions forum.

                Comment


                  Originally posted by Tanuki44
                  ...
                  Please open a new thread in the Input and Output section of the forum.

                  Comment

                  Working...
                  X