mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 19:49:19 +02:00
Fix Lua memcell API
- Fixed the `api.memcell_update` and `api.memcell_update_n` functions to accept the `memcell_values` structure instead of three separate values. - Additionally, also fixed the error message for when the memcell is not found.
This commit is contained in:
@@ -326,9 +326,7 @@ int lua::scriptapi_memcell_read_n(lua_State *L)
|
|||||||
int lua::scriptapi_memcell_update(lua_State *L)
|
int lua::scriptapi_memcell_update(lua_State *L)
|
||||||
{
|
{
|
||||||
auto *mc = static_cast<TMemCell *>(lua_touserdata(L, 1));
|
auto *mc = static_cast<TMemCell *>(lua_touserdata(L, 1));
|
||||||
std::string str = lua_tostring(L, 2);
|
auto [str, num1, num2] = get_memcell_values(L);
|
||||||
double num1 = lua_tonumber(L, 3);
|
|
||||||
double num2 = lua_tonumber(L, 4);
|
|
||||||
if (mc)
|
if (mc)
|
||||||
mc->UpdateValues(str, num1, num2,
|
mc->UpdateValues(str, num1, num2,
|
||||||
basic_event::flags::text | basic_event::flags::value1 | basic_event::flags::value2);
|
basic_event::flags::text | basic_event::flags::value1 | basic_event::flags::value2);
|
||||||
@@ -338,15 +336,13 @@ int lua::scriptapi_memcell_update(lua_State *L)
|
|||||||
int lua::scriptapi_memcell_update_n(lua_State *L)
|
int lua::scriptapi_memcell_update_n(lua_State *L)
|
||||||
{
|
{
|
||||||
std::string mstr = lua_tostring(L, 1);
|
std::string mstr = lua_tostring(L, 1);
|
||||||
std::string str = lua_tostring(L, 2);
|
auto [str, num1, num2] = get_memcell_values(L);
|
||||||
double num1 = lua_tonumber(L, 3);
|
|
||||||
double num2 = lua_tonumber(L, 4);
|
|
||||||
TMemCell *mc = simulation::Memory.find(mstr);
|
TMemCell *mc = simulation::Memory.find(mstr);
|
||||||
if (mc)
|
if (mc)
|
||||||
mc->UpdateValues(str, num1, num2,
|
mc->UpdateValues(str, num1, num2,
|
||||||
basic_event::flags::text | basic_event::flags::value1 | basic_event::flags::value2);
|
basic_event::flags::text | basic_event::flags::value1 | basic_event::flags::value2);
|
||||||
else
|
else
|
||||||
ErrorLog("lua: missing memcell: " + str);
|
ErrorLog("lua: missing memcell: " + mstr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user