112th_Rossi Posted November 1, 2015 Posted November 1, 2015 I am creating a peace-keeping campaign. In one of my missions I want to fly the Mi8 to pick up some stranded civilians. I am using the airshow crowd static object to represent the civilians. In my script, I can't get Unit.getByName to return the civilian object. Are static objects accessible via getByName? It always returns nil. Any ideas? I just put this test script together, it never seems to find the objects. Does it matter that they are static? Civilians[0] = "Civ_1" Civilians[1] = "Civ_2" Civilians[2] = "Civ_3" Civilians[3] = "Civ_4" Civilians[4] = "Civ_5" Civilians[5] = "Civ_6" Civilians[6] = "Civ_7" Civilians[7] = "Civ_8" Civilians[8] = "Civ_9" Civilians[9] = "Civ_10" Civilians[10] = "Civ_11" Civilians[11] = "Civ_12" Civilians[12] = "Civ_13" Civilians[13] = "Civ_14" for index = 0, maxCivilians, 1 do unitname = Civilians[index] trigger.action.outText(string.format("Looking for %s",unitname),2) civilian = Unit.getByName(unitname) if civilian == nil then trigger.action.outText("Civilian not found!", 2) break else trigger.action.outText(string.format("Civilian found: %f", index) , 2) end end
112th_Rossi Posted November 2, 2015 Author Posted November 2, 2015 I worked this out, I had to use StaticObject.getByName instead
Recommended Posts