Guest User

Untitled

a guest
Dec 18th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. struct luaTest
  2. {
  3.     int aaa;
  4.     char bbb;
  5.     float ccc;
  6. };
  7.  
  8. int l_set(lua_State * L)
  9. {
  10.     luaTest * data = (luaTest*)luaL_checkudata(L, 1, "userdata");
  11.     const c8 * key = luaL_checkstring(L, 2);
  12.  
  13.     if(strcmp(key, "aaa") == 0)
  14.         data->a = luaL_checkint(L, 3);
  15.     if(strcmp(key, "bbb") == 0)
  16.         data->b = luaL_checkint(L, 3);
  17.     if(strcmp(key, "ccc") == 0)
  18.         data->c = luaL_checknumber(L, 3);
  19.  
  20.     return 0;
  21. }
Add Comment
Please, Sign In to add comment