Jump to content

Rick

Members
  • Posts

    7,936
  • Joined

  • Last visited

Everything posted by Rick

  1. When I call Release() on the world, the Script:Release() for entities in that world doesn't seem to be getting called. I would expect this to happen so we can release things that we make in Start() (per the documentation). For example, how else would we free up the sounds in FPSPlayer.lua that are loaded in Start()? This is important or else we'll have memory leaks when we switch levels. I say this because of the following observation. 1) I have a simple scene with a floor, player prefab, 1 csg block with a level changing script attached to it. 2) I noticed when the world gets released when the player collides with the csg level (this sets a flag and in App:Loop() is where it checks to release the world, create a new one, then load the new map) that the memory slowly goes up. 3) I then put a System:Print("Releasing") inside the FPSPlayer.lua Script:Release() function and I never see it in the output. This leads me to conclude that this isn't working correctly causing a memory leak.
  2. Yeah, I think that might have been old. Clear() does cause a crash. Release(), for me anyway, does not, and it doesn't cause the memory to go up as fast as not. However it does more slowly still go up. I'm guessing Josh has a memory leak somewhere.
  3. Read this as recommended by the creator of this engine. I didn't do the extra work for ****s and giggles http://www.leadwerks.com/werkspace/files/file/430-next-level/ Not releasing the world, 100% causes the memory to go up. Be sure you aren't looking at the Leadwerks.exe and you are looking at your games name exe in Task Manager. The memory keeps going up and up if you don't release the world!
  4. A path returns a string. It just tells the editor to show the path dialog button to allow you to navigate to a file.
  5. I'm pretty sure Minecraft is within Leadwerks ability. However, it's just about someone taking the time to learn how to do it and making some kind of tutorial. I put Voxel on the front page so we can see if anyone, or myself, have time to learn this. For me, I know this would span a week or so of pretty focused effort, which is hard to come by with 3 kids, wife, full-time job
  6. That tutorial is 8 sections. By no means is that small. I'd love to get to something like this but it's a decent time commitment and I have a few other things going on. I'll add it to the front page though. Anyone is welcome to do something like this too.
  7. Point me to some of those discussions and if I have time to check it out I can give it a try.
  8. Look at my telport tutorial to see how you can do triggers.
  9. You are setting that variable in Script:Create(). Try moving it to Script:Start() which is the function that all entity scripts call on startup. Not sure where you got Create() from.
  10. I think you mean the x axis. If you expect it to rotate upward/downward that's not the y axis but the x axis. Character controllers only rotate on the y axis (turns left/right). You'll either have to manually rotate the model yourself up/down based on some factor or use a different physics method to move your tank around.
  11. I'll play around with that. That script has been modified since then as I keep it always close and truly over the shoulder now, but I think I just commented out the code to move it back and forth.
  12. You might be better off in this case making 1 timer and a counter variable because on different machines, or even the same machine, things might end up slightly off. In this specific case having 1 timer and a counter would make sure that doesn't happen at all. Because this timer isn't async it can end up off if things take longer to do in your scene. Also make a change in the Timer:Update(). Say >= instead of just > That way if it's exact it'll fire the callback.
  13. Try switching the order of your timer updates. Update timer2 before timer. The thing is your last tick would be on 10 seconds exactly for timer2, but because timer (your 10 second tick) is evaluated first it would fire it's function first, which you are stopping the other timer in so it won't fire then. Or make your 10 second one 11 or something like that. You could also now just have 1 timer that fires every 2 seconds and then make a counter in your script that you increase inside this timer and when it reaches 5 you do something. That would possibly avoid the timing issue between the 2 timers that might happen.
  14. I think this would leave the old world loaded, which means the old world entities as well. Do this a bunch of times in a row and watch your memory and I would think it would keep going up. I could be wrong, but I think releasing the world is the right thing to do. It works right now for me to release the world as well. It's just his version that doesn't seem to work.
  15. Sorry, yes. Go into the Timer:Start() function and add self.lastTick = Time:GetCurrent() this will make it so it doesn't fire right away the firs time. I missed that After making that change you don't have to multiple by Time:GetSpeed(). It uses Time:GetCurrent() inside to track the time.
  16. The self.OnTick part of the Create() is where you specify your own function that you define in the entity script. It's a user created function that gets called when the interval is up on the timer. You need to define your own and they should be different for each timer since you'll be doing different stuff in them. That function gets called by the timer when the interval is reached. An example would be like: function Script:OnTick() end But you should make your own function names to show what timer they belong to. Maybe like: function Script:timer2_OnTick() end function Script:timer1_OnTick() end It would probably be best to create the timers in the Start() and just start them in the use. Why do you have 2 UpdateWorld() functions? You should only have 1. Don't do the if check on them either. The code you want to actually do the thing you want to make should be in those user defined functions that you passed to the Create() method. All you need to do in UpdateWorld() is call the timer's Update() method.
  17. Here you go. Usage is: At the top of your script where you use this: import "Scripts/Timer.lua" Inside Start() create and start: self.timer = Timer:Create(5000, self, self.OnTick) -- You must make a function in your script named function Script:OnTick() self.timer:Start() Inside UpdateWorld(): [size=4]self.timer:Update()[/size] [size=4] [/size] For your problem create 2 instances of this class. One that ticks every 2 seconds and one that ticks ever 10 seconds. Start both at startup. Then in your 2 second one do whatever it is you want to do. In your 10 second one stop the 2 second one and the 10 second one with: self.TwoSecondTimer:Stop() self.TenSecondTimer:Stop() Timer.lua
  18. You could just have 2 timers. One that does something every 2 seconds and one that disables the 2 second one when it reaches 10 seconds. I've made an entity script that is a timer. You can hook things up in the flowgraph. Attach this to a pivot in your scene. http://www.leadwerks.com/werkspace/files/file/412-le3-timer-node/ Another example of this would be to make a timer class that accepts script functions as the callback to fire when it ticks. I think I had one of those laying around somewhere. Let me see if I can find it or just make a new one as it's fairly simple. If you wanted to try then look at AnimationManager to see how you can make a "class" and it even allows for calling script functions as callbacks.
  19. I tried this out and it crashes when the world is released. That should help Josh pinpoint why it's crashing. I even made a smaller test map with his project and same crash. Something about what's built into the exe seems to be causing it.
  20. I mean inside Start() or any other function, but mostly Start(), you can make variables by using: self.MyVariable = "Rick" and then use those anywhere in that script. Script. is mainly used for 2 purposes. If what you are making is a table variable, then it spans multiple instances of the same script attached (it's shared between them). The other reason is mainly for exposing parameters in the editor. Other than that, there isn't a language reason to make Script. variables besides trying to use it as a pretty way to show what variables are used in this script (which isn't required but can be a nice convention to use).
  21. You do not need to do that either actually. The wonders of Lua
  22. This gets me too. At the bottom of that is a checkbox that enabled/disables this. I have no idea who would ever want to see it this way
  23. You don't have to declare variables like that. Just setting it to anything (in his case empty string) makes the variable.
  24. Those work for me so not really sure what the deal could be. Take the entire project folder and zip it up and make a post in the Bugs forum and attach it for Josh to see what's up.
  25. Attach your maps so I can test them please.
×
×
  • Create New...