Jump to content

[MOOSE] Help with Moose Error - GetRandomVec2


Go to solution Solved by Death Merchant,

Recommended Posts

Posted (edited)

Can someone help me with this error?

2023-07-19 11:06:35.385 ERROR   SCRIPTING (Main): Mission script error: [string "C:\Users\James\AppData\Local\Temp\DCS.openbeta\/~mis00001939.lua"]:19167: attempt to call method 'GetRandomVec2' (a nil value)
stack traceback:
    [C]: in function 'GetRandomVec2'
    [string "C:\Users\James\AppData\Local\Temp\DCS.openbeta\/~mis00001939.lua"]:19167: in function 'SpawnInZone'
    [string "C:\Users\James\AppData\Local\Temp\DCS.openbeta\/~mis0000581A.lua"]:336: in function 'LoadRandomSAMs'
    [string "C:\Users\James\AppData\Local\Temp\DCS.openbeta\/~mis0000581A.lua"]:426: in main chunk
 

I'm trying to spawn a unit at a random location in a zone.

        local randSpawn = math.random(5)
        BASE:E("Tunguska if 3 or less.")
        BASE:E(randSpawn)
        if    randSpawn <= 3 then
              SA19Spawn:SpawnInZone(samZone, true) -- Add Tunguska to SAM Zone
              BASE:E("Spawning SA-19")
        end
 

The other units are spawning properly, but I get an error when MOOSE tries to call the GetRandomVec2 function.

Any thoughts?

Thanks,
DM

Edited by Death Merchant

[PC] ASUS X570E - Ryzen 9  5950X - RX 6900 XT - 32GB 3600Mhz

Hornet, A-4E-C, Huey, Ka-50, Mi-8, F-15E, F-14

Join us on Death Dealers PvE server.

  • Death Merchant changed the title to [MOOSE] Help with Moose Error - GetRandomVec2
  • Solution
Posted
24 minutes ago, HC_Official said:

samZone , where is this defined

Yep, bad definition. I forgot I was pulling names from a table, and not the zone object. This fixed it:

SA19Spawn:SpawnInZone(ZONE:FindByName(samZone["Zone"]), true) -- Add Tunguska to SAM Zone

Thanks for the help,
DM

[PC] ASUS X570E - Ryzen 9  5950X - RX 6900 XT - 32GB 3600Mhz

Hornet, A-4E-C, Huey, Ka-50, Mi-8, F-15E, F-14

Join us on Death Dealers PvE server.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...