Skip to content

Commit bbf527b

Browse files
authored
grant lua access to closeup values (scp-fs2open#7342)
1 parent c820166 commit bbf527b

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

code/scripting/api/objs/shipclass.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,38 @@ ADE_VIRTVAR(Model, l_Shipclass, "model", "Model", "model", "Ship class model, or
582582
return ade_set_args(L, "o", l_Model.Set(model_h(sip->model_num)));
583583
}
584584

585+
ADE_VIRTVAR(CloseupPosition, l_Shipclass, nullptr, "Ship class closeup position", "vector", "closeup position, or nil if handle is invalid")
586+
{
587+
int idx;
588+
if (!ade_get_args(L, "o", l_Shipclass.Get(&idx)))
589+
return ADE_RETURN_NIL;
590+
591+
if (!SCP_vector_inbounds(Ship_info, idx))
592+
return ADE_RETURN_NIL;
593+
594+
if (ADE_SETTING_VAR) {
595+
LuaError(L, "Setting Closeup Position is not supported");
596+
}
597+
598+
return ade_set_args(L, "o", l_Vector.Set(Ship_info[idx].closeup_pos));
599+
}
600+
601+
ADE_VIRTVAR(CloseupZoom, l_Shipclass, nullptr, "Ship class closeup zoom", "number", "closeup zoom, or nil if handle is invalid")
602+
{
603+
int idx;
604+
if (!ade_get_args(L, "o", l_Shipclass.Get(&idx)))
605+
return ADE_RETURN_NIL;
606+
607+
if (!SCP_vector_inbounds(Ship_info, idx))
608+
return ADE_RETURN_NIL;
609+
610+
if (ADE_SETTING_VAR) {
611+
LuaError(L, "Setting Closeup Zoom is not supported");
612+
}
613+
614+
return ade_set_args(L, "f", Ship_info[idx].closeup_zoom);
615+
}
616+
585617
ADE_VIRTVAR(CockpitModel, l_Shipclass, "model", "Model used for first-person cockpit", "model", "Cockpit model")
586618
{
587619
int ship_info_idx=-1;

code/scripting/api/objs/weaponclass.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,38 @@ ADE_VIRTVAR(Model, l_Weaponclass, "model", "Model", "model", "Weapon class model
263263
return ade_set_args(L, "o", l_Model.Set(model_h(wip->model_num)));
264264
}
265265

266+
ADE_VIRTVAR(CloseupPosition, l_Weaponclass, nullptr, "Weapon class closeup position", "vector", "closeup position, or nil if handle is invalid")
267+
{
268+
int idx;
269+
if (!ade_get_args(L, "o", l_Weaponclass.Get(&idx)))
270+
return ADE_RETURN_NIL;
271+
272+
if (!SCP_vector_inbounds(Weapon_info, idx))
273+
return ADE_RETURN_NIL;
274+
275+
if (ADE_SETTING_VAR) {
276+
LuaError(L, "Setting Closeup Position is not supported");
277+
}
278+
279+
return ade_set_args(L, "o", l_Vector.Set(Weapon_info[idx].closeup_pos));
280+
}
281+
282+
ADE_VIRTVAR(CloseupZoom, l_Weaponclass, nullptr, "Weapon class closeup zoom", "number", "closeup zoom, or nil if handle is invalid")
283+
{
284+
int idx;
285+
if (!ade_get_args(L, "o", l_Weaponclass.Get(&idx)))
286+
return ADE_RETURN_NIL;
287+
288+
if (!SCP_vector_inbounds(Weapon_info, idx))
289+
return ADE_RETURN_NIL;
290+
291+
if (ADE_SETTING_VAR) {
292+
LuaError(L, "Setting Closeup Zoom is not supported");
293+
}
294+
295+
return ade_set_args(L, "f", Weapon_info[idx].closeup_zoom);
296+
}
297+
266298
ADE_VIRTVAR(ArmorFactor, l_Weaponclass, "number", "Amount of weapon damage applied to ship hull (0-1.0)", "number", "Armor factor, or empty string if handle is invalid")
267299
{
268300
int idx;

0 commit comments

Comments
 (0)