droids - .armed and .group properties
Posted: 11 Feb 2012, 20:05
Currently the .armed and .group props only get added if applicable to the droid. However, this means that in JS there's often going to be additional checks (regardless of how simple they are) to accommodate these transient properties.
Could the https://github.com/Warzone2100/warzone2 ... tfuncs.cpp be updated to something like this:
This way the .armed and .group properties always exist so when scripts are checking those props they won't need to first check to see if they exist.
Could the https://github.com/Warzone2100/warzone2 ... tfuncs.cpp be updated to something like this:
Code: Select all
if (isVtolDroid(psDroid))
{
value.setProperty("armed", 100.0 / (double)asWeaponStats[psDroid->asWeaps[0].nStat].numRounds
* (double)psDroid->asWeaps[0].ammo);
// why doesn't the above property have a "QScriptValue::ReadOnly" setting?
}
else
{
value.setProperty("armed", -1, QScriptValue::ReadOnly);
}
if (psDroid->psGroup)
{
value.setProperty("group", (int)psDroid->psGroup->id, QScriptValue::ReadOnly);
}
else
{
value.setProperty("group", -1, QScriptValue::ReadOnly);
}