Skip to content

Commit

Permalink
Merge pull request #760 from LoboEire/master
Browse files Browse the repository at this point in the history
Lua tweaks
  • Loading branch information
dashodanger authored Dec 22, 2024
2 parents dd950a6 + 2f5ea68 commit 2686e34
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 11 deletions.
53 changes: 43 additions & 10 deletions source_files/edge/script/compat/lua_hud.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,21 @@ static int HD_text_font(lua_State *L)

FontDefinition *DEF = fontdefs.Lookup(font_name);
if (!DEF)
return 0;

{
lua_pushboolean(L, 0);
return 1;
}

Font *font = hud_fonts.Lookup(DEF);
if (!font)
return 0;
{
lua_pushboolean(L, 0);
return 1;
}

HUDSetFont(font);

return 0;
return 1;
}

// hud.text_color(rgb)
Expand Down Expand Up @@ -331,9 +337,15 @@ static int HD_draw_image(lua_State *L)
HUDDrawImageNoOffset(x, y, img);
else
HUDDrawImage(x, y, img);

lua_pushboolean(L, 1);
}
else
{
lua_pushboolean(L, 0);
}

return 0;
return 1;
}

// Dasho 2022: Same as above but adds x/y texcoord scrolling
Expand All @@ -360,9 +372,14 @@ static int HD_scroll_image(lua_State *L)
HUDScrollImage(x, y, img, -sx,
-sy); // Invert sx/sy so that user can enter
// positive X for right and positive Y for up
lua_pushboolean(L, 1);
}
else
{
lua_pushboolean(L, 0);
}

return 0;
return 1;
}

// hud.stretch_image(x, y, w, h, name, [noOffset])
Expand All @@ -387,9 +404,14 @@ static int HD_stretch_image(lua_State *L)
HUDStretchImageNoOffset(x, y, w, h, img, 0.0, 0.0);
else
HUDStretchImage(x, y, w, h, img, 0.0, 0.0);
lua_pushboolean(L, 1);
}
else
{
lua_pushboolean(L, 0);
}

return 0;
return 1;
}

// hud.tile_image(x, y, w, h, name, offset_x, offset_y)
Expand All @@ -411,9 +433,14 @@ static int HD_tile_image(lua_State *L)
if (img)
{
HUDTileImage(x, y, w, h, img, offset_x, offset_y);
lua_pushboolean(L, 1);
}
else
{
lua_pushboolean(L, 0);
}

return 0;
return 1;
}

// hud.draw_text(x, y, str, [size])
Expand Down Expand Up @@ -735,11 +762,17 @@ static int HD_play_sound(lua_State *L)
SoundEffect *fx = sfxdefs.GetEffect(name);

if (fx)
{
StartSoundEffect(fx);
lua_pushboolean(L, 1);
}
else
{
LogWarning("hud.play_sound: unknown sfx '%s'\n", name);

return 0;
lua_pushboolean(L, 0);
}

return 1;
}

// hud.screen_aspect()
Expand Down
5 changes: 4 additions & 1 deletion source_files/edge/script/compat/lua_player.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1923,9 +1923,12 @@ static int MO_render_view(lua_State *L)
if (!temp_value.empty())
{
HUDRenderWorld(x, y, w, h, mo, 1);
lua_pushboolean(L, 1);
}
else
lua_pushboolean(L, 0);

return 0;
return 1;
}


Expand Down

0 comments on commit 2686e34

Please sign in to comment.