@@ -99,6 +99,7 @@ void CLuaElementDefs::LoadFunctions()
9999 {" setElementFrozen" , SetElementFrozen},
100100 {" setLowLODElement" , ArgumentParser<SetLowLodElement>},
101101 {" setElementCallPropagationEnabled" , SetElementCallPropagationEnabled},
102+ {" setElementLighting" , ArgumentParser<SetElementLighting>},
102103 };
103104
104105 // Add functions
@@ -191,6 +192,7 @@ void CLuaElementDefs::AddClass(lua_State* luaVM)
191192 lua_classfunction (luaVM, " setLowLOD" , " setLowLODElement" );
192193 lua_classfunction (luaVM, " setCallPropagationEnabled" , " setElementCallPropagationEnabled" );
193194 lua_classfunction (luaVM, " setStreamable" , " setElementStreamable" );
195+ lua_classfunction (luaVM, " setLighting" , " setElementLighting" );
194196
195197 lua_classvariable (luaVM, " callPropagationEnabled" , " setElementCallPropagationEnabled" , " isElementCallPropagationEnabled" );
196198 lua_classvariable (luaVM, " waitingForGroundToLoad" , NULL , " isElementWaitingForGroundToLoad" );
@@ -225,6 +227,7 @@ void CLuaElementDefs::AddClass(lua_State* luaVM)
225227 lua_classvariable (luaVM, " velocity" , SetElementVelocity, OOP_GetElementVelocity);
226228 lua_classvariable (luaVM, " angularVelocity" , SetElementAngularVelocity, OOP_GetElementTurnVelocity);
227229 lua_classvariable (luaVM, " isElement" , NULL , " isElement" );
230+ lua_classvariable (luaVM, " lighting" , " setElementLighting" , " getElementLighting" );
228231 // TODO: Support element data: player.data["age"] = 1337; <=> setElementData(player, "age", 1337)
229232
230233 lua_registerclass (luaVM, " Element" );
@@ -1340,6 +1343,7 @@ std::variant<bool, float> CLuaElementDefs::GetElementLighting(CClientEntity* ent
13401343 break ;
13411344 }
13421345 case CCLIENTOBJECT:
1346+ case CCLIENTWEAPON:
13431347 {
13441348 CObject* object = static_cast <CClientObject*>(entity)->GetGameObject ();
13451349 if (object)
@@ -2604,3 +2608,41 @@ int CLuaElementDefs::IsElementWaitingForGroundToLoad(lua_State* luaVM)
26042608 lua_pushboolean (luaVM, false );
26052609 return 1 ;
26062610}
2611+
2612+ bool CLuaElementDefs::SetElementLighting (CClientEntity* entity, float lighting)
2613+ {
2614+ switch (entity->GetType ())
2615+ {
2616+ case CCLIENTPLAYER:
2617+ case CCLIENTPED:
2618+ {
2619+ auto * ped = static_cast <CClientPed*>(entity)->GetGamePlayer ();
2620+ if (!ped)
2621+ return false ;
2622+
2623+ ped->SetLighting (lighting);
2624+ return true ;
2625+ }
2626+ case CCLIENTVEHICLE:
2627+ {
2628+ auto * vehicle = static_cast <CClientVehicle*>(entity)->GetGameVehicle ();
2629+ if (!vehicle)
2630+ return false ;
2631+
2632+ vehicle->SetLighting (lighting);
2633+ return true ;
2634+ }
2635+ case CCLIENTOBJECT:
2636+ case CCLIENTWEAPON:
2637+ {
2638+ auto * object = static_cast <CClientObject*>(entity)->GetGameObject ();
2639+ if (!object)
2640+ return false ;
2641+
2642+ object->SetLighting (lighting);
2643+ return true ;
2644+ }
2645+ }
2646+
2647+ return false ;
2648+ }
0 commit comments