• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Razakhel / RaZ / 23265498158

18 Mar 2026 05:29PM UTC coverage: 74.491% (-0.01%) from 74.502%
23265498158

push

github

Razakhel
[Render/Cubemap] Made the cubemap's vertices meshless

- They are now statically fetched according to the vertex ID

15 of 23 new or added lines in 6 files covered. (65.22%)

69 existing lines in 2 files now uncovered.

8632 of 11588 relevant lines covered (74.49%)

1706.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.24
/src/RaZ/Script/LuaScript.cpp
1
#include "RaZ/Application.hpp"
2
#include "RaZ/Script/LuaScript.hpp"
3
#include "RaZ/Script/LuaWrapper.hpp"
4
#include "RaZ/Utils/FilePath.hpp"
5
#include "RaZ/Utils/FileUtils.hpp"
6
#include "RaZ/Utils/Logger.hpp"
7

8
#define SOL_SAFE_GETTER 0 // Allowing implicit conversion to bool
9
#include "sol/sol.hpp"
10

11
#include "tracy/Tracy.hpp"
12

13
namespace Raz {
14

15
LuaScript::LuaScript(const std::string& code) {
10✔
16
  Logger::debug("[LuaScript] Creating script...");
10✔
17

18
  Raz::LuaWrapper::registerTypes();
10✔
19
  loadCode(code);
10✔
20

21
  Logger::debug("[LuaScript] Created script");
8✔
22
}
12✔
23

24
void LuaScript::loadCode(const std::string& code) {
19✔
25
  ZoneScopedN("LuaScript::loadCode");
26

27
  Logger::debug("[LuaScript] Loading code...");
19✔
28

29
  const sol::object owningEntity = m_environment.get("this");
19✔
30

31
  m_environment.clear();
19✔
32

33
  if (!m_environment.execute(code))
19✔
34
    throw std::invalid_argument("Error: The given Lua script is invalid");
2✔
35

36
  if (m_environment.get("update").get_type() != sol::type::function)
17✔
37
    throw std::invalid_argument("Error: A Lua script must have an update() function");
1✔
38

39
  if (owningEntity.is<Entity>()) {
16✔
40
    m_environment.registerEntity(owningEntity.as<Entity>(), "this");
×
41
    setup();
×
42
  }
43

44
  Logger::debug("[LuaScript] Loaded code");
16✔
45
}
19✔
46

47
void LuaScript::loadCodeFromFile(const FilePath& filePath) {
2✔
48
  ZoneScopedN("LuaScript::loadCodeFromFile");
49
  ZoneTextF("Path: %s", filePath.toUtf8().c_str());
50

51
  Logger::debug("[LuaScript] Loading code from file ('{}')...", filePath);
2✔
52
  loadCode(FileUtils::readFileToString(filePath));
3✔
53
  Logger::debug("[LuaScript] Loaded code from file");
1✔
54
}
1✔
55

56
bool LuaScript::update(const FrameTimeInfo& timeInfo) const {
16✔
57
  ZoneScopedN("LuaScript::update");
58

59
  const sol::unsafe_function updateFunc = m_environment.get("update");
16✔
60
  const sol::unsafe_function_result updateRes = updateFunc(timeInfo);
16✔
61
  return (updateRes.get_type() == sol::type::none || updateRes);
32✔
62
}
16✔
63

64
void LuaScript::setup() const {
4✔
65
  ZoneScopedN("LuaScript::setup");
66

67
  if (!m_environment.exists("setup"))
4✔
68
    return;
3✔
69

70
  const sol::reference setupRef = m_environment.get("setup");
1✔
71

72
  if (setupRef.get_type() != sol::type::function)
1✔
73
    return;
×
74

75
  Logger::debug("[LuaScript] Running script setup...");
1✔
76

77
  const sol::unsafe_function setupFunc = setupRef;
1✔
78

79
  if (!setupFunc().valid())
1✔
NEW
80
    throw std::runtime_error("[LuaScript] The Lua script failed to be setup");
×
81

82
  Logger::debug("[LuaScript] Ran script setup");
1✔
83
}
1✔
84

85
} // namespace Raz
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc