1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
/*This file defines some things that all igui stuff can do*/
extern "C" {
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
}
#include <irrlicht.h>
#include "igeneric.hpp"
#include "../gameparts.hpp"
using namespace irr;
using namespace core;
using namespace scene;
static LISceneNode* toiscenenode(lua_State* L, int index){
LISceneNode* ret = (LISceneNode*)lua_touserdata(L,index);
if(ret == NULL)
luaL_typerror(L,index,"LISceneNode");
return ret;
}
int iscenegetpos(lua_State* L){
ISceneNode* i = toiscenenode(L,1)->n;
vector3df pos = i->getAbsolutePosition();
lua_createtable(L,3,0);
lua_pushnumber(L,1);
lua_pushnumber(L,pos.X);
lua_settable(L,-3);
lua_pushnumber(L,2);
lua_pushnumber(L,pos.Y);
lua_settable(L,-3);
lua_pushnumber(L,3);
lua_pushnumber(L,pos.Z);
lua_settable(L,-3);
return 1;
}
int iscenesetpos(lua_State* L){
ISceneNode* i = toiscenenode(L,1)->n;
lua_pushnumber(L,1);
lua_gettable(L,-2);
f32 x = (f32)lua_tonumber(L,-1);
lua_pop(L,1);
lua_pushnumber(L,2);
lua_gettable(L,-2);
f32 y = (f32)lua_tonumber(L,-1);
lua_pop(L,1);
lua_pushnumber(L,3);
lua_gettable(L,-2);
f32 z = (f32)lua_tonumber(L,-1);
lua_pop(L,1);
printf("Trying to set pos of %p to %f %f %f",i,x,y,z);
i->setPosition(vector3df(x,y,z));
i->updateAbsolutePosition();
vector3df pos = i->getAbsolutePosition();
printf("After setting pos, new pos is %f %f %f",pos.X,pos.Y,pos.Z);
return 0;
}
|