-
Posts
7,936 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Downloads
Everything posted by Rick
-
The The fact that I do the following object.cameraPivot:SetParent(object.playerPivot, 1) is causing the issue. If I comment that out, then the camera is placed in the correct location. However, I want that behaviour. I want the cameraPivot to move when the playerPivot moves.
-
delete it and rerun the updater
-
Could it be something around: object.cameraPivot = CreatePivot() object.playerPivot = CreatePivot() object.cameraPivot:SetParent(object.playerPivot, 1) I do set the parent with the cameraPivot. But again, same script being ran so I wouldn't think so.
-
Here is the C++ code to expose the fw BP L = GetLuaState(); lua_pushobject(L, framework); lua_setglobal(L, "fw"); lua_pop(L, 1); Do I need to do something else with this? I wouldn't think so because I can set the fw.main.camera to the position I know it should be and it works, but for some reason when I try to set the position based on the pivots position it doesn't work. I get the offset thing, but I can't understand how the lua scripts would create the pivot differently based on when ran from my C++ code vs the editor. It's all being done in the script.
-
Would that matter between running from the editor vs running from my own C++ program? I mean both are running this lua script and in there I just do: object.cameraPivot = CreatePivot() to create the pivot. This all works perfect in the editor. There just must be something I'm missing between running from the editor to running from C++.
-
What I don't get is if I do object.cameraPivot:SetPosition(object.model:GetPosition(1), 1) pos = object.cameraPivot:GetPosition(1) Notify("object.cameraPivot position = "..pos.x..","..pos.y..","..pos.z) I get (-13, 26, -11) Then a couple lines down if I do fw.main.camera:SetPosition(object.cameraPivot:GetPosition(1), 1) pos = fw.main.camera:GetPosition(1) Notify("camera = "..pos.x..","..pos.y..","..pos.z) I get (-23,48,-29) What am I missing? If the position of object.cameraPivot is A and I set fw.main.camera to object.cameraPivot position, how can fw.main.camera position be B?
-
But I am setting camera position based on a thingoids position. So it shouldn't matter where the camera starts. Once this script runs it should set the position of the camera to the thingoid position.
-
So after the camera gets set I added this code: pos = fw.main.camera:GetPosition(1) Notify("fw.main.camera pos = "..pos.x..","..pos.y..","..pos.z) I do get different values when ran from my C++ program vs running from the editor. They are running the same script and loading the same scene so why would I get different values? C++ program gives (in x,y,z) -9.96,22.05,-18.01 Editor gives -13.9,26.4,-11.3
-
Now with what I'm seeing I have to wonder. It seems like lua_setglobal(L, "fw") and lua_pop(L, 1) are something Josh created and aren't the normal lua methods (even though they are sharing the same name)? Can anyone confirm this because if so this really screws up using normal lua methods. The fact that these methods are the same name as normal lua methods but those lua methods are expecting lua_State* as the first parameter and when we pass BP it works, leads me to believe these are Josh's functions and not the normal lua functions. The issue this seems to cause is that when I include lua in my project it doesn't like me passing BP to those methods. So if I cast them to (lua_State*) I don't get compile errors but then things don't seem to function right because the underlying LE method must be doing something else. Basically when including lua in a LE project and LE having the same function names are lua function, all hell breaks loose because it doesn't know which function you want to use. A simple rename of the LE lua methods would solve this and should probably be different anyway. No sense in confusing people that are linking in lua by having the same function name.
-
If we have the lua state in C++, then I would expect that I could then expose a C++ method to use in lua using: static int KattSendMessage(lua_State* L) { char* _msg = (char*)lua_tostring(L, 1); char* _extra = (char*)lua_tostring(L, 2); return 1; } BP L = GetLuaState(); lua_register((lua_State*)L, "KattSendMessage", KattSendMessage); But that doesn't seem to work. My function never seems to get called and I also notice that when I save a script in the script editor that comes with the editor it always complains about KattSendMessage() being a nil value. I can do this with normal lua and it works. What would be different?
-
I'm having an issue where my lua script for my camera works fine from the editor, but when I load the map that has this script in it from my own C++ program it acts differently. I will now describe acting differently. The script is my ThirdpersonCamera script. Basically wherever you place the editor model is where the fw.camera will be placed. Then you assign it a target and it'll point at that target. This all works just fine and great when run from the editor. function object:Update() local t = object.model:GetTarget(0) if GetGlobalString("mode") == "GAME_MODE" then if object.oneTime == false then object.cameraPivot:SetPosition(EntityPosition(object.model, 1), 1) object.playerCube:Hide() local p = t:GetPosition(1) p.x = p.x + object.targetOffset.x p.y = p.y + object.targetOffset.y p.z = p.z + object.targetOffset.z object.playerPivot:SetPosition(Vec3(p.x, p.y, p.z)) object.cameraPivot:Point(object.playerPivot, 3, 1, 0) fw.main.camera:SetMatrix(object.cameraPivot.mat) object.oneTime = true end if t == nil then else -- the pivot to follow the player around -- debug code --object.cameraCube:SetPosition(object.cameraPivot:GetPosition()) --object.playerCube:SetPosition(object.playerPivot:GetPosition(1)) end else if t ~= nil then local p = t:GetPosition(1) p.x = p.x + object.targetOffset.x p.y = p.y + object.targetOffset.y p.z = p.z + object.targetOffset.z object.playerPivot:SetPosition(Vec3(p.x, p.y, p.z)) object.cameraPivot:SetPosition(EntityPosition(object.model)) end -- debug code --object.cameraCube:SetPosition(object.cameraPivot:GetPosition()) object.playerCube:SetPosition(object.playerPivot:GetPosition()) end end I then created my own C++ program that has all the lua stuff loaded and working. I know this because I load the scene and I can see from the engine.log that it's loading the lua files and I see the lua stuff working. The problem is that the camera when ran from my program isn't in the same place. It looks to be at the target location instead of the editor model location. I did set the global string "mode" to "GAME_MODE". So in the script object.cameraPivot:SetPosition(EntityPosition(object.model, 1), 1) should set the camera pivot to the location of the object model. Then fw.main.camera:SetMatrix(object.cameraPivot.mat) should set the fw.camera (which I did create in my C++ program and expose to lua) to the object.cameraPivot. So what am I missing?
-
So in some C++ examples I notice it uses some lua methods without having to include any lua stuff. But when I try some other lua methods they aren't recognized. Why would that be? For example I tried lua_register() to register a function for lua to be able to call, but I get the error: 'lua_register': identifier not found. I assume this lua methods you are using below and work without including any lua stuff are the actual lua methods and not a copy of the methods that Josh made? BP L = GetLuaState(); lua_pushobject(L, framework); lua_setglobal(L, "fw"); lua_pop(L, 1);
-
Doesn't sound like to many people have tried. I came up with a way that I'll be testing tonight. It's basically a messaging system. It works pretty slick for what I'm doing. I was just curious if anyone else had ideas that I may have overlooked.
-
Does it amaze anyone else that people like Kevin aren't already working for a major game company?
-
Since it looks like you want fuseActive to be local to this thingoid try doing this instead: object.fuseActive = 0 Then use that to check in the ReceiveMessage() if object.fuseActive then ...
-
I'm not big on UV-coordinates but I always thought they had to be between 0 and 1?
-
I'm curious on the approach some others have taken on communicating from lua back to your C++ program. Has anyone worked on something like this?
-
You can look at any of my Pi objects, but basically in the Update() method you can set the position of your mesh to the models position. Here is how I handle this. function class:CreateObject(model) local object = self.super:CreateObject(model) object.model = model -- this will save off the editor model so you can use it later object.sphere = CreateSphere(object.resolution, "0") function object:Update() -- I can't remember if these are the right names or not but you get the idea object.sphere:SetPosition(object.model:GetPosition()) end end Also, to avoid the sphere being to large and covering up your editor model which prevents you from being able to click it to select it (you can still select it on the tree view side), I generally offset the sphere down 1/2 the size of it. This puts the editor model 1/2 way sticking out the top so I can still select it and move it around. OR you could probably parent it. I avoid parenting because when I create objects in code when I'm in game mode I generally hide the editor model since it's not needed. It's basically used to just be able to move your objects you create in code when in editing mode. This is why I create that global game mode variable and check that in the Update() method in my Pi objects. Also, be sure to free the objects you create in the free method. Or even if you delete the editor model your object that you created in code will stay in the scene. Also note that if you try to create a body in lua code there is no way to get a collision method fired for that. I have a request in for this because it limits the usefulness of creating bodies in lua code.
-
You've done a good job Lumooja with LEO. I've already put a ton of faith in 1 person with Josh and LE. I just have a hard time doing it twice with LEO. If the buses go crazy and hit you both I don't know what we'd do!
-
I just use the engine commands. LEO always makes me nervous because from what I can tell Josh doesn't seem to be the one updating it so I'm always concerned that who ever is updating LEO will leave and it'll be left in the dust some day.
-
I was wondering about this too. Why would that be the case? If we have the single lua state, I was under the impression that any variable that didn't have local or wasn't part of a "class" (like class.variable), was global to the lua state.
-
That's my house I like my toys.
-
Just for that I'm going to put a job offer on monster.com for that!
-
I would push people away from it because there is no market for it. Go do a monster.com search for BMax and tell me how many jobs come up. To me it would make more sense to use a language where the knowledge you get from your hobby could help in a job.