-
Posts
7,936 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Downloads
Everything posted by Rick
-
Thanks. I guess it would just be nice not have to change my game script at all from editor to engine. I could modify my editor one to check for fw and if not there make it I guess, but would be nice in my mind to not have to worry about that. At least it's easy Thanks again.
-
Yeah. Just to get an example of the setup that needs to be done in Lua so that it's setup the same as when ran from the editor which does this (and other maybe?) setup for you. Come to think of it shouldn't Engine.exe set the framework up? That would seem the best way I guess so that we could xfer our editor lua game script right over to run in Engine.exe without changes. When I just tried that it complained about fw. I don't even know if Engine.exe is going to not have this Lua issue I'm having but just wanted to try it before making my own exe because if I don't have to then great!
-
So you are stepping through this and e->UpdateBall() makes it into your Controller::UpdateBall() and you are seeing _campivot as a bad pointer is that right? I don't see where _campivot is being created in your code above. Also not seeing where the callback is setup above. Can you show that. Also I assume you are creating a pointer to Controller like: Object* obj1 = new Controller(); ??
-
Looks like the example start.lua file isn't using the fw variable? Since we can just use the fw variable when running scripts in the editor I would think start.lua should have that same setup for the example. Does anyone have the snippet of code to setup start.lua to be the same as when ran from editor? Not sure if anyone has ran into any other gotcha's when switching from editor to engine.
-
If you have specific Lua questions don't be afraid to ask. Most of us won't bite!
-
Really what you would be looking for is just general AI tutorials and then use your knowledge of the Lua programming language to make those tutorials come to life inside Lua. Most every programming language has the pieces to make a "theory" of AI come to life via code.
-
So Josh you are using 5.1 right? Nothing special modified of the Lua version that you are using? This all works fine if lua.exe (the binary you can download of lua) is running my script, so it almost leads me to believe that it's the implementation of Lua in the editor and any slight Lua modifications that may have been made (to the Lua library itself)? There was another strange quirk I noticed where getting the first thing on the stack of a function call wasn't the first argument but a function, which wasn't the case in lua.exe when running a test script. I think at one point you gave me the person who did this implementation of Lua for you. Would that person still be associated with LE and would I be able to ask that person a question around this? Or if you know of any Lua change would you happen to have the changed Lua library that I could use in my C++ program? It just seems like this is something specific to the engine's version of Lua. Going to give Engine.exe to see if that gives the same results. Never used Engine.exe before so will have to see how that works.
-
Thanks for that. Still gives me the error. If I misspell the function name it fails the is_function call so I know it's finding the function, and pushing it on the stack but it just fails when calling. This is Lua 5.1 right? I'm currently using the binaries so I guess I'll get the source and use that in my project so I can step through the pcall method and see if I can get any more details around the error. It seems odd that the error would be coming from the editor and not my DLL though. The editor is single threaded right? I mean while I'm in my DLL making lua calls nothing should be happening on the Lua side of the editor calling model scripts right? It's erroring internally to Lua at: void luaV_execute (lua_State *L, int nexeccalls) { LClosure *cl; StkId base; TValue *k; const Instruction *pc; reentry: /* entry point */ pc = L->savedpc; cl = &clvalue(L->ci->func)->l; base = L->base; k = cl->p->k; /* main loop of interpreter */ for (; { const Instruction i = *pc++; // access violation error here Of course I have no idea of the internal workings of Lua but pc doesn't seem to be null or 0. It has what seems to be a valid address but when this tries to increase it, the failure happens. I wouldn't think it would be any sort of cross process issue as I thought the lua_State was meant to be self contained and passed around at will.
-
I can't figure out why this isn't working: int state = lua_type(L, -1); Is telling me a function (the one I push) is on the stack, but any call to it (lua_pcall(L, 0, 0, 0) gives the Editor the ACCESS VIOLATION error. The fact that getglobal seems to be finding the function seems good, but not sure what else the call is expecting to make the editor crash. Also, those ACCESS VIOLATION errors I assume is from a lack of error handling so would be nice if we had more graceful error checking around Lua.
-
Does anyone know the Lua code in that is used to call engine Lua functions from say the editor? I'm using the following but the editor gives me access violation: lua_getglobal(L, "LuaFunctionName"); lua_pcall(L, 0, 0, 0); If Josh is able to show how say the editor is calling lua function from C++ or BMax that should help.
-
Yes, up to a certain revenue value. I believe if you make $250,000 you have to start paying them something.
-
One of the nice things about the model viewer is that it shows you how "off" you might be from the base scale of LE.
-
I think it's left or right mouse click and hold then move mouse up and down
-
[EDIT] Title shouldn't have LE just Lua at this point. This is still pretty early stage but I was able to get a wrapper around RakNet working in Lua. I'm simply using C methods currently so it's not like I did class wrapping for all of RakNet as that would be pretty intense and overkill for what I need. I'll show how I'm doing it in case anyone else is interested, but you would have to download RakNet yourself and compile the code because that's how the RakNet developer wants you do work with his code. He doesn't want precompiled wrappers around his code distributed. RakNetLua.dll is my wrapper. The below code will load the dll for Lua to use. Inside the DLL I define a table as 'raknet' so after calling this that's how you use the methods in the dll. After loading the dll and binding to the connection success message (those all caps are ints that use the same values from RakNet's header) I connect to my server. The connect is async so it then hits the main loop calling an update method for RakNet to check for packets coming in. The server gets my connection request and accepts, causing my ConnectionSuccess lua function to get called. Inside that method I'm create a BitStream (just a structure that you write your data to and then send it after you are finished writing to it) and send the server a game message. In my test server when it see's this game message 1, it'll write back game message 2 and since I've bound that message the GameMessage2 lua method will fire in which it reads the string that the server sent. *Note* This lua example isn't from inside LE. It was basic Lua exe that you can download. I didn't want to introduce LE yet, but there should be no reason this won't work in LE Lua which I will be doing today or tomorrow pending time. package.loadlib("RakNetLua.dll", "luaopen_raknet")() -- this lua function will get called by the DLL given the binding that happens below function ConnectionSuccess(reader) print "Connection success!" -- create a bitstream and write something to it local writer = raknet.net_CreateBitStream(ID_GAME_MESSAGE_1) raknet.net_WriteBitStream(writer, "Welcome") -- send this bitstream to the server raknet.net_Send(writer) end function GameMessage2(reader) print "Inside game message 2" local msg = "" msg = raknet.net_ReadBitStream(reader, TYPE_STRING) print(msg) end -- Bind connection success! raknet.net_BindMessageEvent(ID_CONNECTION_REQUEST_ACCEPTED, "ConnectionSuccess") -- Bind game message raknet.net_BindMessageEvent(ID_GAME_MESSAGE_2, "GameMessage2") raknet.net_Connect("127.0.0.1", 60000) while i == 1 do raknet.net_Update() end Currently this only supports strings and doubles but that's the basic building blocks of most data anyway. Below is the DLL I currently have. It'll change as I refine this. If you were to duplicate this the idea is that you link in Lua 5.1 and RakNet lib which you've registered to download yourself and compiled. Given the post here you should be able to make this yourself if you are interested in using RakNet via Lua. #define LUA_API_EXP __declspec(dllexport) #include "RakPeerInterface.h" #include "MessageIdentifiers.h" #include "BitStream.h" #include "RakNetTypes.h" // MessageID #include <string> #include <map> using namespace std; extern "C" { #include "lua.h" #include "lualib.h" #include "lauxlib.h" // prevents the function name from being mangled LUA_API_EXP int luaopen_raknet(lua_State *L); } RakNet::RakPeerInterface *peer = RakNet::RakPeerInterface::GetInstance(); RakNet::Packet *packet; RakNet::SystemAddress serverAddress; map<RakNet::MessageID, string> luaHandlers; static int NetConnect(lua_State* L) { const char* ip = luaL_checkstring(L, 1); int port = luaL_checknumber(L, 2); peer->Startup(1, &RakNet::SocketDescriptor(), 1); peer->Connect(ip, port, 0,0); return 0; } static int NetSend(lua_State* L) { //luaL_checktype(L, 1, LUA_TLIGHTUSERDATA); // cast the first param to the bitstream to send RakNet::BitStream *stream = static_cast<RakNet::BitStream*>(lua_touserdata(L, 1)); // send the bitstream to the server peer->Send(stream, HIGH_PRIORITY, RELIABLE_ORDERED, 0, serverAddress, false); return 0; } static int NetCreateBitStream(lua_State* L) { RakNet::BitStream *stream = new RakNet::BitStream(); // the first parameter is the message id int v1 = luaL_checknumber(L, 1); // write the message id to the bitstream stream->Write((RakNet::MessageID)v1); // return the bitstream to lua lua_pushlightuserdata(L, stream); return 1; } static int NetWriteBitStream(lua_State* L) { // cast the first param to the bitstream to send RakNet::BitStream *stream = static_cast<RakNet::BitStream*>(lua_touserdata(L, 1)); // get the type of the value we want to write to the bitstream int type = lua_type(L, 2); //double vDbl; //const char* vStr; switch(type) { case LUA_TNUMBER: double vDbl; vDbl = luaL_checknumber(L, 2); stream->Write(vDbl); break; case LUA_TBOOLEAN: // TODO: implement boolean values break; case LUA_TSTRING: const char* vStr; vStr = luaL_checkstring(L, 2); RakNet::RakString str = vStr; stream->Write(str); break; } return 0; } static int NetReadBitStream(lua_State* L) { // cast the first param to the bitstream to send RakNet::BitStream *stream = static_cast<RakNet::BitStream*>(lua_touserdata(L, 1)); // get the type to read int type = luaL_checknumber(L, 2); switch(type) { case 0: // double (constant in Lua) double v; stream->Read(v); lua_pushnumber (L, v); break; case 1: // string (constant in Lua) RakNet::RakString str; stream->Read(str); lua_pushstring(L, str.C_String()); break; } return 1; } static int NetBindMessageEvent(lua_State* L) { int msgID = luaL_checknumber(L, 1); const char* luaFunctionName = luaL_checkstring(L, 2); string functionName = luaFunctionName; // link the lua function name to this msg id luaHandlers[msgID] = functionName; return 0; } static int NetUpdate(lua_State* L) { // check for new packets for (packet=peer->Receive(); packet; peer->DeallocatePacket(packet), packet=peer->Receive()) { switch(packet->data[0]) { // if we get connected store off the servers address to use when we send data case ID_CONNECTION_REQUEST_ACCEPTED: serverAddress = packet->systemAddress; break; } // get the lua method to call if(luaHandlers.find(packet->data[0]) != luaHandlers.end()) { lua_getglobal(L, luaHandlers[packet->data[0]].c_str()); // push the bitstream pointer on the lua stack RakNet::BitStream reader(packet->data,packet->length,false); reader.IgnoreBytes(sizeof(RakNet::MessageID)); lua_pushlightuserdata(L, &reader); // call the function (1 param, 0 return) lua_pcall(L, 1, 0, 0); } } return 0; } static const luaL_reg netLib[] = { {"net_Connect", NetConnect}, {"net_Update", NetUpdate}, {"net_BindMessageEvent", NetBindMessageEvent}, {"net_CreateBitStream", NetCreateBitStream}, {"net_Send", NetSend}, {"net_WriteBitStream", NetWriteBitStream}, {"net_ReadBitStream", NetReadBitStream}, {NULL, NULL} }; // lua calls this to open the library LUA_API_EXP int luaopen_raknet (lua_State *L) { luaL_openlib(L, "raknet", netLib, 0); return 1; } I'm open to suggestions/comments/thoughts.
-
Yes. At least that's what I do and the scripts attached do run.
-
You could use animated trees and just animate them very very slowly.
-
I'm just starting to play around with RakNet exposed to Lua so stay tuned. (I think some others might be doing this also). The catch being that I probably can't just give the DLL that I make to others because of the licensing of RakNet, but I could show how to create the same thing and you would have to download the RakNet source and generate your own DLL following the steps. I'm trying to make my design generic enough so the DLL would never have to be changed. You would simply register and define messages and message handlers via Lua.
-
I like gamedev.net's version of that store because they show you how many ppl have purchased things
-
Videos like that are so funny. Humans are always amazed by lots of things having physics ran on them At about :09 on the top left shelf looks like a strange spring up of a chair. That must be one of those bugs you speak of. As long as it's easy to use and 1/2 bum decent I'm cool with it.
-
I found this method works great, but a warning from my experience. Test change you make in Lua often. The debugging in Lua is horrible. The errors you'll get sometimes will have nothing to do with what is actually wrong. I know this can happen in other languages but I've found it is worse in Lua (with LE at least). On average every function I add I'll test right away if possible because a missed end or messed up variable and you'll be hosed. I can't even imagine adding a big framework of code and then run it. In C++ I don't have an issue with doing that as I can fix the few errors I've made and recompile. In Lua doing such a thing could have your scratching your head for hours.
-
I honestly wouldn't. I was/am big on "thingoids" because they are cool and easy for other people to plug and play, but coming up with the design and interactions between all these to make a complete game is more of the same of fussing about proper design and given his comment using the main Lua file is the best way to go. You can sub in entity scripts for certain things but if finishing a game is your main priority over coming up with a cool design, then don't fully rely on entity scripts as you'll get lost in design. I speak from my experience in this area. I was against the main Lua file and all for entity scripts because it was fun making those interactions, but to do it for every aspect of a game will eat up a ton of time and make you "hack" around things to get a game done. It's just easier to code in your main Lua file and supplement with the entity scripts. I use my entity scripts like classes. Then I code most of my game in a C fashion in Lua and found I was able to produce something much faster and easier. Just my experience I speak of though.
-
In C++: luaL_loadfile (lua_start_var, "start.lua")) I think the lua state variable is exposed right?
-
I would think it would still add value. Even if it's to advertise that you have a demo game in which people could play before they buy LE, but have to buy LE to see how it's done. Would help get people in the door sort of speak.
-
What I find about some of these things is that it dulls out the image some and isn't as sharp, but it looks way better when moving around.