Example #1
0
int lh_getpixel(lua_State *L) {
  checkArg(L, 3, "getpixel");

  Image *srcI = luaO(1, Image);
  int srcX = luaInt(2);
  int srcY = luaInt(3);
#ifdef OPENGL
  if(useGL(srcI)) return retInt(L, getpixelGL(srcX, srcY));
#endif
  srcI->setLock(true);
  int res = qpixel(srcI->s, srcX, srcY);
  return retInt(L, res);
  }
Example #2
0
int lh_newimage(lua_State *L) {
  int params = lua_gettop(L);
  if(params != 2 && params != 3) {
    noteyeError(1, "Bad arg to newimage", NULL); 
    return retInt(L, 0);
    }
  Image *i = new Image(luaInt(1), luaInt(2), params == 3 ? luaInt(3) : 0);
  return retObject(L, i);
  }
Example #3
0
bool
CLuaState::call_luafunction(int retnum, const char *func, const char *argform, va_list ap)
{
    // lua関数の名称をスタックに積む
    lua_getglobal(m_L, func);

    int count = 0;
        
    // 引数をスタックに積む
    if(argform) {
        for(const char * sp = argform; *sp; sp++) {
            switch(*sp)
            {
                case 'B': {
                    int b = va_arg(ap, int);
                    retBoolean((b) ? true : false);
                    count++;
                    break;
                }
                case 'I': {
                    int i = va_arg(ap, int);
                    retInt(i);
                    count++;
                    break;
                }
                case 'N': {
                    double d = va_arg(ap, double);
                    retDouble(d);
                    count++;
                    break;
                }
                case 'S':{
                    const char * str = va_arg(ap, const char *);
					retString(str);
                    count++;
                    break;
                }
                case 'P':{
                    void * p = va_arg(ap, void *);
                    retPointer(p);
                    count++;
                    break;
                }
                case 'G': {
                    const char * p = va_arg(ap, const char *);
                    retGlobal(p);
                    count++;
                    break;
                }
            }
        }
    }
	return call(count, func, retnum);
}
Example #4
0
int lh_setfont(lua_State *L) {
  checkArg(L, 2, "setfont");
  Font *f = luaO(2, Font);
  Process *p = dluaO(1, Process);
  if(p) {
    p->f = f;
    }
  Screen *s= p ? p->s : dluaO(1, Screen);
  if(s) {
    for(int y=0; y<s->sx * s->sy; y++)
      s->v[y] = tileSetFont(s->v[y], f);
    }
  Tile *t = dluaO(1, Tile);
  if(t) return retInt(L, tileSetFont(t->id, f));
  return 0;
  }
Example #5
0
int lh_iso(lua_State *L) {
  checkArg(L, 2, "isoproject");
  IsoParam *P = luaO(2, IsoParam);
  
  int t0;
  int ti = luaInt(1);
  t0 = addFreeform(distill(ti, spIFloor), P->Floor);
  t0 = addMerge(t0, addFreeform(addRecolor(distill(ti, spIWallL), 0xFF808080, recMult), P->WalL), false);
  t0 = addMerge(t0, addFreeform(addRecolor(distill(ti, spIWallR), 0xFFC0C0C0, recMult), P->WalR), false);
//t0 = addMerge(t0, addFreeform(distill(ti, spIWallL), P->WalL), false);
//t0 = addMerge(t0, addFreeform(distill(ti, spIWallR), P->WalR), false);
  t0 = addMerge(t0, addFreeform(distill(ti, spICeil), P->Ceil), false);
  t0 = addMerge(t0, addFreeform(distill(ti, spIItem), P->Item), false);
  
  return retInt(L, t0);
  // return retInt(L, renderAsIso(luaInt(1), spIFloor | spIItem | spIWallL | spIWallR | spICeil, luaO(2, IsoParam)));
  }
Example #6
0
int lh_loadimage(lua_State *L) {
  checkArg(L, 1, "loadimage");
  Image *o = new Image(luaStr(1));
  if(!o->s) { delete o; return retInt(L, 0); }
  return retObject(L, o);
  }
Example #7
0
int lh_objcount(lua_State *L) {
  return retInt(L, size(objs));
  }
Example #8
0
int lh_vgaget(lua_State *L) {
  checkArg(L, 1, "vgaget");
  return retInt(L, vgacol[luaInt(1)]);
  }
Example #9
0
int lh_colorpartset(lua_State *L) {
  checkArg(L, 3, "colorset");
  int a = luaInt(1);
  part(a, luaInt(2)) = luaInt(3);
  return retInt(L, a);
  }
Example #10
0
int lh_colorpart(lua_State *L) {
  checkArg(L, 2, "colorpart");
  int a = luaInt(1);
  return retInt(L, part(a, luaInt(2)));
  }
Example #11
0
int lh_colormix3(lua_State *L) {
  checkArg(L, 3, "colormix3");
  int a = luaInt(1);
  mixcolorAt(a, luaInt(2), luaInt(3));
  return retInt(L, a);
  }
Example #12
0
int lh_colormix(lua_State *L) {
  checkArg(L, 2, "colormix");
  int a = luaInt(1);
  mixcolor(a, luaInt(2));
  return retInt(L, a);
  }
Example #13
0
int lh_getcrashval(lua_State *L) {
  return retInt(L, crashval);
  }
Example #14
0
int lh_bXOR(lua_State *L) {
  return retInt(L, luaInt(1) ^ luaInt(2));
  }
Example #15
0
int lh_bAND(lua_State *L) {
  return retInt(L, luaInt(1) & luaInt(2));
  }