fork download
  1.  
  2. static int l_get2dMap(lua_State *L)
  3. {
  4. // Get the table insert function
  5. lua_getglobal(L, "table");
  6. lua_getfield(L, -1, "insert");
  7. int table_insert = lua_gettop(L);
  8.  
  9. LuaPerlinNoiseMap *o = checkobject(L, 1);
  10. v2f p = read_v2f(L, 2);
  11.  
  12. Noise &n = o->noise;
  13. n.perlinMap2D(p.X, p.Y);
  14. int i = 0;
  15. for (int y = 0; y != n.sy; y++) {
  16. lua_pushvalue(L, table_insert);
  17. lua_pushvalue(L, table);
  18. for (int x = 0; x != n.xy; x++) {
  19. lua_pushvalue(L, table_insert);
  20. lua_pushvalue(L, table);
  21. lua_pushnumber(L, n.result[i++]);
  22. }
  23. }
  24. return 1;
  25. }
  26.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty