MCPcopy Create free account
hub / github.com/9chu/LuaSTGPlus / PostEffect

Method PostEffect

LuaSTGPlus/LuaWrapper.cpp:1423–1470  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1421 return 0;
1422 }
1423 static int PostEffect(lua_State* L)LNOEXCEPT
1424 {
1425 const char* texture = luaL_checkstring(L, 1);
1426 const char* name = luaL_checkstring(L, 2);
1427 BlendMode blend = TranslateBlendMode(L, 3);
1428
1429 // 获取纹理
1430 ResTexture* rt = LRES.FindTexture(luaL_checkstring(L, 1));
1431 if (!rt)
1432 return luaL_error(L, "texture '%s' not found.", texture);
1433
1434 // 获取fx
1435 ResFX* p = LRES.FindFX(name);
1436 if (!p)
1437 return luaL_error(L, "PostEffect: can't find effect '%s'.", name);
1438 if (lua_istable(L, 4))
1439 {
1440 // 设置table上的参数到fx
1441 lua_pushnil(L); // s s t ... nil
1442 while (0 != lua_next(L, 4))
1443 {
1444 // s s t ... nil key value
1445 const char* key = luaL_checkstring(L, -2);
1446 if (lua_isnumber(L, -1))
1447 p->SetValue(key, (float)lua_tonumber(L, -1));
1448 else if (lua_isstring(L, -1))
1449 {
1450 ResTexture* pTex = LRES.FindTexture(lua_tostring(L, -1));
1451 if (!pTex)
1452 return luaL_error(L, "PostEffect: can't find texture '%s'.", lua_tostring(L, -1));
1453 p->SetValue(key, pTex->GetTexture());
1454 }
1455 else if (lua_isuserdata(L, -1))
1456 {
1457 fcyColor c = *static_cast<fcyColor*>(luaL_checkudata(L, -1, TYPENAME_COLOR));
1458 p->SetValue(key, c);
1459 }
1460 else
1461 return luaL_error(L, "PostEffect: invalid data type.");
1462
1463 lua_pop(L, 1); // s s t ... nil key
1464 }
1465 }
1466
1467 if (!LAPP.PostEffect(rt, p, blend))
1468 return luaL_error(L, "PostEffect failed.");
1469 return 0;
1470 }
1471 static int PostEffectCapture(lua_State* L)LNOEXCEPT
1472 {
1473 if (!LAPP.PostEffectCapture())

Callers

nothing calls this directly

Calls 5

TranslateBlendModeFunction · 0.85
FindTextureMethod · 0.80
FindFXMethod · 0.80
SetValueMethod · 0.80
GetTextureMethod · 0.45

Tested by

no test coverage detected