-
Posts
7,936 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Downloads
Everything posted by Rick
-
What you are looking for is called a Singleton. Google "C++ Singleton Pattern" and you'll see how you implement that. I would tell you that they are bad and not needed and should be avoided, but I think you might need to experience it for yourself by using them given this post. I can tell you until my face is blue why it's bad and not needed, but it's hard to understand why until you start running into the problems globals bring with them.
-
Does it? Can't you remove the steam DLL without error as long as you comment out any Steam related code (I think App.lua/cpp has Steam DLL related command(s)).
-
@YouGroove I don't think if you publish a game right now it's dependent on Steam.
-
When I do this I always call Stop() when within a certain distance of destination. What you are seeing is probably floating point errors or something like that. As for your other problem you are using MouseHit() which will only register once per frame so it's registering for 1 enemy but not the other because they get processed in the same frame. That's my guess anyway with just looking at the code. One way to get around this and simulate a hit function like that is to give each script a bool value for mouse down and then do: if window:MouseDown(1) == true and self.mouseDown == false then -- do code here on mouse down self.mouseDown = true else if window:MouseDown(1) == false and self.mouseDown == true then -- do code here on mouse up after mouse down self.mouseDown = false end
-
You keep not showing us the whole script so we have to guess... There is no mystery to programming. The computer does what you tell it to do, but we need to see the script to tell what's up.
-
Where is self.xmin defined or given a value? After seeing what you have there I now think that this function is being called before you define or give xmin a value. LE doesn't do anything strange to Lua, which is why the reason is 99.9% always your usage of it and not understanding how it works.
-
Make sure you defined your walk function like: function Script:Walk() end My guess is you defined it just like: function Walk() end If you don't know why you need to do that then you don't have a fundamental idea of how Lua is working. Let me know and I can help explain. I'f I'm wrong then we need to see the entire script.
-
So SetRotation()/Turn() isn't simple enough for you? Get the bone entity via FindChild() and it's name and then you can rotate it and position it all you want via code. Just remember to do it AFTER you run your animation code or the animation will overwrite what you're doing.
- 1 reply
-
- 1
-
Lua is a scripting language. One of the benefits of a scripting language is that you don't have to compile it. It can also be one of it's drawbacks, but that's how scripting languages work. You can do OOP with Lua. You have much more freedom when passing things around between functions. Lua is less strict than C++. My guess is you'll start getting into C++ and come back complaining about how much more difficult it is
-
Do you get to step through your code? Does it redirect output for debugging?
-
Wasn't there already like 2 other people trying to do this already?
-
But C++ itself has nothing to do with remembering function names of objects. That's why intellisense is so great.
-
Where would you put that if collisiontype statement to check? You can't put it in the Collision() function because it won't get called unless you already setup collisions in another function (that we are trying to find). You would have to manually do your own collision checks, which shouldn't be needed because there is this other way if we could find it
-
The current system works like layers but it's not called layers. Just need to find that Collisions() function and expose it to Lua if it's not already. The concepts are basically the same anyway.
-
I think it's only available in C++. I don't see it in the docs. I know the old C++ template used to have it, but it doesn't appear to have it now. I can't remember for the live of me what class it's tied too. Checking... In 2.x it was just called Collisions() I think.
-
Ideally you will want to have some sort of callback/event system in your animation code for non looping animations. That way you can define a function to be called when a non looping animation is complete (in your case the dying animation) so that you can do other things inside of these functions, like end your game.
-
Yes, you can use Lua even in the C++ version. You load your map in C++ and you can loop over all the entities that were loaded in your scene and do whatever you want with them. Yes, you can use the flowgraph even in the C++ version.
-
Sorry, I linked to the wrong function. There is a function I think called Collisions() that does what you're after.
-
Can you elaborate on this because you can already play animations in LE via the AnimationManager.lua file.
-
I know you can do this in a C++. http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/entity/entitysetcollisiontype-r35
-
I have to wonder why an UpdatePhysics() hook would even exist then? I don't think it's ran on it's own thread. I think LE handles the timing and that's why there is an UpdatePhysics hook. Doing things inside UpdatePhysics is the way you get the timing don't for you. Either way, I think the point is (OP) to put your physics functions inside the UpdatePhysics hook and don't multiply by App::Speed()
-
You don't need to split out your animations. http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/entity/entitysetanimationframe-r141 Note that for the sequence parameter you can use 0 (which has all your animations). Then you pass the frame number for your specific animations. You'll have to track your animation frames yourself but the good thing about doing it this way is if you have to re-import your model you won't have to breakout ALL your animations again, which is a pain.
-
I think this is how it's setup which, like you said, is how you get values > 1 if your PC runs slow. But only when inside the UpdatePhysics() function I believe (which is only in Lua I think) because it's already set to run at a specific FPS. In C++ you'd have to make an UpdatePhysics() function yourself to act the same (maybe there is a hook for it?). I think Aggror had a topic on this and that's what Josh said. http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/entity/entityupdatephysicshook-r62 For the OP, a good test would be to implement this function hook for your character controller entity and then remove multiplying by AppSpeed() and see how it works.
-
Isn't the point of this function to return a value that deviates from 1 based on the speed of the computer at any given moment to achieve the same speed on all computers? If your computer runs at a specific speed you'd get 1 returned which wouldn't alter your value since you multiply by it. If your PC slows down the value returned is > 1 so as to put your positions where they should be in relation to a person who has a PC that runs at the "perfect" speed and if your PC is really fast then you'd get a value < 1 so as to put your positions where they should be in relation to a person who has a PC that runs at the "perfect" speed? Also, wasn't code like that supposed to be in an UpdatePhysics() function (Lua gives this but in C++ you have to make it yourself I think) so that you don't have to multiply by App::Speed() when sending values to SetInput() (which I assume is what you are doing).
-
It's a pain, but yes. Otherwise you are trying to extract an animation from an already extracted animation.