-
Posts
7,936 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Downloads
Everything posted by Rick
-
Was just thinking it would be nice if the engine.exe and editor.exe both created a lua variable so our main lua applications can tell where it's being called from. Different things need to happen depending on where it's called from and this would be a nice easy way of telling. A few different things that I can think of depending on where the main lua file is being run from: 1. Create framework. If run from the editor we don't need to do this. If run from the engine we do. A check of fw == nil does work, but this would be an added support. 2. Load a sandbox map. When from the editor the map is the current map, but when from the engine you need to load a map. Knowing the main lua file is being called from the engine, we can then load a map. I know we can check if the fw variable is nil, but that might not work in every situation. A person might not use the fw variable at all. Having the executable "pass in" a value indicating where it's called from would just be a more concrete approach in my view.
-
I would want some way to get a collision method called for a physics body that I create in code inside an object model. An example might be the monster truck. You create the tires on the fly in the object code. If those have physics bodies around them, how can you tell if the tires collide with something? My example is a cube. I have an object that you drag into your scene. It creates a cube mesh that has a physics body around it. You can resize the cube in the editor and so the physics body needs to be created in the editor script. The physics on it works great, but I can't get a collision method called when that physics body collides with something because it's not the editor's object that's colliding, it's the physics body I create via script inside the object. I'm using this for a 3D platform game. For the platforms not having a collision function called is fine, but I'm also going to use it for triggers. When the character collides with this resizable physics body that is created in the script, I need a collision function called for it.
-
Any ideas on how to do this? Any hack ideas out there even?
-
In lua terms it would be a table of functions where the key is the message id. I guess it's nothing we couldn't do ourselves, but would be cool to have it part of the code. So instead of: Function ClientCallBack(client:TClient,id:Int,packet:TPacket) Select id Case NETWORK_CHANGENAMERESPONSE If packet.ReadByte()=1 Print "Changed name to "+packet.ReadLine() Else Print "Name change rejected." EndIf Case NETWORK_JOINRESPONSE If packet.ReadByte()=1 Print "Joined game" Local count:Int=packet.ReadByte() Print count+" players" For Local n:Int=1 To count Print n+". "+packet.ReadLine() Next Else Print "Rejected from game" Select packet.ReadByte() Case 1 Print "Name already in use" Default Print "Unknown reason" EndSelect EndIf Case NETWORK_DISCONNECT Print "Disconnected from server." Case NETWORK_CONNECT Print "Connected to server." Case NETWORK_CHAT Print "Says: "+packet.ReadLine() Case NETWORK_PINGRESPONSE Print "Ping = "+(MilliSecs()-packet.ReadInt()) EndSelect EndFunction So the users would define a function and assign it to the message function NameChange(client, packet) end networkMessage[NETWORK_CHANGENAMERESPONSE] = NameChange Then the library message pump would check the message id to see if it exists in the table and if so call the function the user defined for it. networkMessage[id](client, packet) The users could still do this even if you have 1 callback function anyway I guess. This just seems more "event" driven.
-
This is probably just preference, but I also liked mapping messages to functions instead of having 1 huge callback function for all the events with 1 huge case statement. I just felt it makes the code cleaner. That's starting to look like Win32 API programming with the case statement.
-
I don't have to restart my editor when I change an objects properties window. It shows up instantly. Josh has said he prefers the system he is using so I doubt this will be changed. He say some other game dev company do it the way it is currently and liked it.
-
I'd advise against that actually. It'll probably only make you more angry. The wiki and/or forums are your best bet. Sure you paid $200, but that doesn't entitle you to get instant one on one support from Josh. He's a one man show here and if he gave one on one support to us all he'd never get anything done. Plus he tends to put "humor" into some of his responses, which some people don't take well. So don't take it personally.
-
worked for me, first time. No issues.
-
Also, you can request from the community some functionality via lua objects. These would be objects that have functionality in them already that you can use in the editor. I'm a real big fan of this, and think more people should start requesting functionality and more programmers making objects.
-
If inside my lua object, I create another object with physics, say I create a cube and attach a physics body in lua code inside my editor, is there any way I can get a lua method to fire with the collision of that object I created? Ideally I would be able to piggy back on the editor object collision method.
-
I found a work around. I set the mass to 0 when in editor mode, and the first time in Update in game mode is where I set the mass to whatever the user sets in the properties. That seems to work out well.
-
hmm, well this is all just for editor mode so you can position the cube where you want it to be when the game runs. I need the cube to follow the position of the editor object model. Would you think there would be a way to reset the physics body so it doesn't have this high velocity after SetPosition() is stopped being called on the body? That way I could do that on the first run inside the update method.
-
I can't think of a reason why fw.Update() isn't being called. Nothing is blocking it from being called.
-
Has anyone experienced issues when setting the position of a physics body and then not setting the position and letting physics happen on the body, but the body velocity is really fast now. Almost like while set position was being called on it, it was increases it's velocity even though it was standing still?
-
Here's something interesting. So I uncomment the code in the update method that positions the body so I can move the body around in the editor. When I run the game everything drops and works as expected except for 1 detail. The longer I'm in editor mode and then switch to game mode, the faster the objects drop to the ground. For example, if I sit in editor mode for 1 second, then switch to game mode, the objects fall at a decent speed. Then if I go back to editor mode and wait 10 seconds and then go back into game mode, the objects fly to the ground really fast. It's almost because I SetPosition() of the body in editor mode that it's really building up speed behind the scenes, and when I don't call SetPosition() anymore, it still has the speed at which it would be falling. How can I get around this? Ideally I would think that once SetPosition() is called it resets any velocity the body would have so when it's not called on the body anymore the velocity is starting from scratch.
-
Parenting the other way works, except the box and the cube aren't together (the physics body moves with my editor object but the box is created at the origin, however when I move the physics body the box does move also), but from my understanding you can't scale bodies after they are created. You can, but the physics gets messed up from what I remember. That shouldn't be an issue though as I just recreate the physics body when the size changes anyway. Just need to get the cube at the same position as the body now. [EDIT] I got it. Thank you!
-
The issue I have now, is when I set the bodymass to 1, the body falls, but the cube doesn't go with it. Any ideas? require("scripts/class") require("Scripts/hooks") require("Scripts/linkedlist") local class=CreateClass(...) function class:InitDialog(grid) self.super:InitDialog(grid) group = grid:AddGroup("Cube") group:AddProperty("size", PROPERTY_VEC3, "0", "Cube Scale") group:AddProperty("mat", PROPERTY_FILE, "", "Material") group:AddProperty("body_mass", PROPERTY_FLOAT, "", "Body Mass") group:AddProperty("entity_type", PROPERTY_INTEGER, "", "Entity Type") group:Expand(1) end function class:CreateObject(model) local object=self.super:CreateObject(model) function object:CreateCube(size, mass, type) -- delete if already exists if object.cube ~= nil then object.cube:Free() object.cube = nil object.body:Free() object.body = nil end -- create object.body = CreateBodyBox(size.x, size.y, size.z) object.body:SetMass(mass) EntityType(object.body, type) object.cube = CreateCube() object.cube:SetScale(size) object.body:SetParent(object.cube, 1) -- paint object.mat = LoadMaterial(object.matFile) object.cube:Paint(object.mat) -- position local scale = object.cube:GetScale() local pos = object.model:GetPosition() pos.y = pos.y - (scale.y / 2) object.cube:SetPosition(pos) object.cube:SetRotation(object.model:GetRotation()) end -- defaults object.model = model object.matFile = "abstract::cobblestones.mat" object.bodyMass = 1 object.entityType = 1 object.size = Vec3(2, 2, 2) object.cube = nil object.body = nil object.material = nil -- create default cube object:CreateCube(object.size, object.bodyMass, object.entityType) function object:SetKey(key,value) if key == "mat" then object.matFile = "abstract::"..value object.mat = LoadMaterial(object.matFile) object.cube:Paint(object.mat) elseif key == "size" then object.size = StringToVec3(value) object:CreateCube(object.size, object.bodyMass, object.entityType) elseif key == "body_mass" then object.bodyMass = tonumber(value) object:CreateCube(object.size, object.bodyMass, object.entityType) elseif key == "entity_type" then object.entityType = tonumber(value) object:CreateCube(object.size, object.bodyMass, object.entityType) else return self.super:SetKey(key,value) end return 1 end function object:GetKey(key,value) if key=="" then else return self.super:GetKey(key,value) end return value end function object:Update() if GetGlobalString("mode") == "GAME_MODE" then else -- editor mode -- moves the editor model to the top of the cube local scale = object.cube:GetScale() local pos = object.model:GetPosition() pos.y = pos.y - (scale.y / 2) --object.cube:SetPosition(pos) --object.body:SetPosition(pos) --object.cube:SetRotation(object.model:GetRotation()) end end function object:Free(model) if object.cube ~= nil then object.cube:Free() object.cube = nil end if object.body ~= nil then object.body:Free() object.body = nil end --if object.mat ~= nil then -- object.mat:Free() --end self.super:Free() end end
-
Thank macklebee, that did it! I wonder why the wiki tutorial doesn't do that and it works there?
-
It's a good engine. Lumooja goes a little overboard, but this engine is easy to learn and very powerful. That chart is just something Lumooja created with his own personal weights applied to what he feels important so take it with a grain of salt.
-
lol, well the parenting is kind of key I see now that if I comment out the parenting it's the right size, but I have to have the parenting, so like you said ScaleMesh would probably do it. Although looking at the wiki, it uses ScaleEntity() and parenting just like I'm doing: http://www.leadwerks.com/wiki/index.php?title=CreateBodyBox
-
You can see my issue here: http://leadwerks.com/werkspace/index.php?/topic/751-body-box-vs-createcube-set-scale/ but it seems ScaleMesh isn't in the lua command and it seems to be causing me issues with matching body boxes with cubes. The cube can be dynamically sized in the editor so I need a way to match the physics body to it.
-
The size will need to be variable though. You'll be able to size it to whatever you want from properties. I thought you said it worked for you with those 3 lines of code, but now you seem to be saying it's not?
-
Can you try it in your editor. Drop this folder anywhere in your leadwerks folder. http://dl.dropbox.com/u/1293842/Pi-Cube.zip
-
No, the cube is in the middle of the body box for me so that's not it. This is what it looks like for me. http://dl.dropbox.com/u/1293842/img.jpg
-
Why does the below code produce a larger physics box than cube mesh? object.cube = CreateCube() object.cube:SetScale(Vec3(2,2,2)) -- default size object.body = CreateBodyBox(2,2,2)