Page 1 of 1
Attaching weapon model(s) to parent unit
Posted: 06 Sep 2007, 02:42
by MadRat
If someone wants to use a mounted weapon, like a missile on the rail, its pretty straight forward how to display the weapon model. My question is, how do you get the model to reappear only when its reached the set reload time? I know I can set this value up manually in a cob. I would rather have the cob automatically figure out the timing so that when balancing weapons and reseting the time to reload on the weapon it does this automatically, too, so I don't have to recompile the cob files each time. Is there a simple way to do this?
Posted: 06 Sep 2007, 04:04
by rattle
Yeah, by using Cob->Lua, Lua->Cob.
I'd call a LUA function from within the script in the Create() function. The LUA function then calls a COB function for n times.
Code: Select all
for (n=0; n < unit->weapons.size(); n++) {
COB_GetReloadTimes(n, unit->weapons[n]->reload);
}
(imagine this was in LUA :P)
Posted: 06 Sep 2007, 05:22
by MadRat
Thanks for the reply. I'll have to read up more on lua. The language looks fairly complicated for a nonprogrammer.
Posted: 06 Sep 2007, 07:55
by yuritch
Actually, there is a SetMaxReloadTime(time) call in COB (often used in OTA Cavedog scripts) that sets a variable to highest reload time of all the weapons the unit has. So no need to use LUA for something the engine already does. This was discussed way back
here.
Posted: 07 Sep 2007, 02:42
by MadRat
Awww, much nicer solution for me at this moment. But I still need to explore LUA.