Quote:
Btw, is it possible to load TDExplosives into dropships with lua?
Yeah it is. I just tried and this code works:
Code:
Myactor = ActivityMan:GetActivity():GetControlledActor(0); Explosive = CreateTDExplosive("Frag Grenade"); Myactor:AddInventoryItem(Explosive);
Myactor = ActivityMan:GetActivity():GetControlledActor(0); // Gets actor that is currently under player control in team 0 (or use some other way to ID the actor that gets the stuff)
Explosive = CreateTDExplosive("Frag Grenade"); // Assigns the grenade type to variable Explosive
Myactor:AddInventoryItem(Explosive); // Adds stuff from variable to inventory
However you get that error you describe if you try to add stuff into inventory more than 1 time. Each time you add, you must do the assignment to Explosive variable again if you want to add again. For example:
Code:
for I = 1, 5 do Explosive = CreateTDExplosive("Frag Grenade"); Myactor:AddInventoryItem(Explosive); end
I've practically just started experimenting with Lua in Cortex Command so i don't know why you have to do it like this. Maybe because of scope, or garbage collection.
And also, in this case it adds the first instance of Frag Grenade that appears in Tradestar order list. I don't know how to add the Coalition grenades.