Added helpers to stdlib

Author Mitja Felicijan <mitja.felicijan@gmail.com> 2025-08-11 19:35:30 +0200
Committer Mitja Felicijan <mitja.felicijan@gmail.com> 2025-08-11 19:35:30 +0200
Commit eb5dee514ba02f866d1eb3378df9ccc5830e7747 (patch)
-rw-r--r-- main.c 2
-rw-r--r-- stdlib/helpers.lua 11
2 files changed, 13 insertions, 0 deletions
diff --git a/main.c b/main.c
...
13
#include "stdlib/json.h"
13
#include "stdlib/json.h"
14
#include "stdlib/color.h"
14
#include "stdlib/color.h"
15
#include "stdlib/button.h"
15
#include "stdlib/button.h"
  
16
#include "stdlib/helpers.h"
16
  
17
  
17
#include "fonts/dejavusans_mono_bold.h"
18
#include "fonts/dejavusans_mono_bold.h"
18
  
19
  
...
593
		if (!load_embedded_module(L, json, json_len, "json")) return 1;
594
		if (!load_embedded_module(L, json, json_len, "json")) return 1;
594
		if (!load_embedded_module(L, color, color_len, "color")) return 1;
595
		if (!load_embedded_module(L, color, color_len, "color")) return 1;
595
		if (!load_embedded_module(L, button, button_len, "button")) return 1;
596
		if (!load_embedded_module(L, button, button_len, "button")) return 1;
  
597
		if (!load_embedded_module(L, helpers, helpers_len, "helpers")) return 1;
596
  
598
  
597
		// Registring Raylib mappings.
599
		// Registring Raylib mappings.
598
		lua_register(L, "open_window", l_open_window);
600
		lua_register(L, "open_window", l_open_window);
...
diff --git a/stdlib/helpers.lua b/stdlib/helpers.lua
  
1
function print_table(t, indent)
  
2
	indent = indent or ""
  
3
	for key, value in pairs(t) do
  
4
		if type(value) == "table" then
  
5
			print(indent .. key .. ":")
  
6
			print_table(value, indent .. "  ")
  
7
		else
  
8
			print(indent .. key .. ": " .. tostring(value))
  
9
		end
  
10
	end
  
11
end