Skip to content

Commit f2e8df4

Browse files
authored
Lua access to puncture flag status (scp-fs2open#7323)
* lua access to puncture flag status * disallow setting flag * and don't grab the value even * fix
1 parent afc1db7 commit f2e8df4

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

code/scripting/api/objs/weaponclass.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,28 @@ ADE_VIRTVAR(Bomb, l_Weaponclass, "boolean", "Is weapon class flagged as bomb", "
650650
return ADE_RETURN_FALSE;
651651
}
652652

653+
ADE_VIRTVAR(Puncture, l_Weaponclass, "boolean", "Is weapon class flagged as puncture", "boolean", "New flag")
654+
{
655+
int idx;
656+
if(!ade_get_args(L, "o", l_Weaponclass.Get(&idx)))
657+
return ADE_RETURN_FALSE;
658+
659+
if(idx < 0 || idx >= weapon_info_size())
660+
return ADE_RETURN_FALSE;
661+
662+
weapon_info *info = &Weapon_info[idx];
663+
664+
if(ADE_SETTING_VAR)
665+
{
666+
LuaError(L, "Setting Puncture flag is not supported");
667+
}
668+
669+
if (info->wi_flags[Weapon::Info_Flags::Puncture])
670+
return ADE_RETURN_TRUE;
671+
else
672+
return ADE_RETURN_FALSE;
673+
}
674+
653675
ADE_VIRTVAR(CustomData, l_Weaponclass, nullptr, "Gets the custom data table for this weapon class", "table", "The weapon class's custom data table")
654676
{
655677
int idx;

0 commit comments

Comments
 (0)