LuaPreprocess - straightforward preprocessor with simple syntax
- yetneverdone
- Party member
- Posts: 448
- Joined: Sat Sep 24, 2016 11:20 am
- Contact:
Re: LuaPreprocess - straightforward preprocessor with simple syntax
I've noticed that a syntax error in a handler.lua file does throw an error but not detailed enough? Like there is no line number where the syntax error is.
My GameDev Website
Going Home:A Pixelated Horror Game
My Repositories!
Follow me lovingly!
Nga pala, pinoy ako.
Going Home:A Pixelated Horror Game
My Repositories!
Follow me lovingly!
Nga pala, pinoy ako.
Re: LuaPreprocess - straightforward preprocessor with simple syntax
Thanks for the report! There was an internal error in the error reporting function. Oops. It's been fixed now.yetneverdone wrote: ↑Sun May 30, 2021 2:08 am I've noticed that a syntax error in a handler.lua file does throw an error but not detailed enough? Like there is no line number where the syntax error is.
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
LuaPreprocess update 1.14
Update 1.14
Changes since 1.13.2:
Library:
Changes since 1.13.2:
Library:
- !(), !!() and @insert now work in macros.
- Macro names can now contain lookups.
- Updated string serialization, including for newToken("string").
- Fixed error in output for @line.."" .
- Improved some error messages.
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
- yetneverdone
- Party member
- Posts: 448
- Joined: Sat Sep 24, 2016 11:20 am
- Contact:
Re: LuaPreprocess - straightforward preprocessor with simple syntax
How does one insert a table to another like:
a solution ive found is:
But maybe theres another way of like copy-pasting a table into the output code?
Code: Select all
!(
local t = {
{1},
{2},
{3},
)
local t2 = {
--insert contents of `t` here,
{4},
{5},
}
Code: Select all
!(
t_player = {
{"sheet_player_idle_normal", path_images .. "player/sheet_player_idle_normal.png"},
{"sheet_player_walk_normal", path_images .. "player/sheet_player_walk_normal.png"},
{"sheet_player_run_normal", path_images .. "player/sheet_player_run_normal.png"},
{"sheet_player_open_door_normal", path_images .. "player/sheet_player_open_door_normal.png"},
}
function get_t_player()
local str = ""
for _, t in ipairs(t_player) do
str = str .. toLua(t) .. ",\n"
end
return str
end
)
--usage
local t = {
!!(get_t_player())
}
My GameDev Website
Going Home:A Pixelated Horror Game
My Repositories!
Follow me lovingly!
Nga pala, pinoy ako.
Going Home:A Pixelated Horror Game
My Repositories!
Follow me lovingly!
Nga pala, pinoy ako.
Re: LuaPreprocess - straightforward preprocessor with simple syntax
The first code snipped has an error, which confused me at first. (I assume there's supposed to be an additional `}` after `{3},`).
Also, the code snippets seem to show different things you're trying to do. To insert things from a table in the metaprogram into a table in the final program you can do this:
!(expression) serializes and outputs a value.
For the second code snipped you can just do this:
Also, the code snippets seem to show different things you're trying to do. To insert things from a table in the metaprogram into a table in the final program you can do this:
Code: Select all
local t2 = {
!for _, v in ipairs(t) do
!(v),
!end
{4},
{5},
}
-- Output:
local t2 = {
{1},
{2},
{3},
{4},
{5},
}
For the second code snipped you can just do this:
Code: Select all
local t = !(t_player)
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
- yetneverdone
- Party member
- Posts: 448
- Joined: Sat Sep 24, 2016 11:20 am
- Contact:
Re: LuaPreprocess - straightforward preprocessor with simple syntax
Im going to insert the contents of the table in many places many times so doing a for-loop is not favourable. Any other method?
My GameDev Website
Going Home:A Pixelated Horror Game
My Repositories!
Follow me lovingly!
Nga pala, pinoy ako.
Going Home:A Pixelated Horror Game
My Repositories!
Follow me lovingly!
Nga pala, pinoy ako.
Re: LuaPreprocess - straightforward preprocessor with simple syntax
Why is a for-loop not favorable?yetneverdone wrote: ↑Thu Jul 29, 2021 9:47 am Im going to insert the contents of the table in many places many times so doing a for-loop is not favourable. Any other method?
Anyway, instead of having get_t_player() you could instead make the function output the code directly.
Code: Select all
!(
function output_t_player()
for _, t in ipairs(t_player) do
outputValue(t)
outputLua(",\n")
end
end
)
local t = {
!output_t_player()
}
Code: Select all
!(
function output_comma_separated_values(values)
for _, v in ipairs(values) do
outputValue(v)
outputLua(",\n")
end
end
)
local t = {
!output_comma_separated_values(t_player)
}
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
- yetneverdone
- Party member
- Posts: 448
- Joined: Sat Sep 24, 2016 11:20 am
- Contact:
Re: LuaPreprocess - straightforward preprocessor with simple syntax
The goal is to make the function more abstract so it can return other tables by id as well over multiple places where it may be repeated. thanks for the help
My GameDev Website
Going Home:A Pixelated Horror Game
My Repositories!
Follow me lovingly!
Nga pala, pinoy ako.
Going Home:A Pixelated Horror Game
My Repositories!
Follow me lovingly!
Nga pala, pinoy ako.
LuaPreprocess update 1.15
Update 1.15
Changes since 1.14:
Library:
Changes since 1.14:
Library:
- Added functions: getOutputSoFar(), getOutputSizeSoFar(), getCurrentLineNumberInOutput().
- outputValue() with multiple values will now output commas between the values.
- Added `@insert func!(...)` as syntax sugar for `@insert func(!(...))`.
- Added `@insert func!!(...)` as syntax sugar for `@insert func(!!(...))`.
- Added --nogc option.
Last edited by ReFreezed on Mon Aug 02, 2021 12:23 am, edited 1 time in total.
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
Re: LuaPreprocess - straightforward preprocessor with simple syntax
I think the URLs aren't correct
Who is online
Users browsing this forum: No registered users and 0 guests