Jump to content

Aaron Symons

Members
  • Posts

    90
  • Joined

  • Last visited

Posts posted by Aaron Symons

  1. Hi Rick,

     

    I thought I'd have to go over to C++. Even though I don't have the C++ version of Leadwerks, would I be able to reference my own C++ code via Lua somehow, or would that be naughty?

     

    I'm wanting to make things happen in-game to the BPM of the played music. I have all the calculations ready, but I need to be more precise with the timing because, currently, I'm out of time with the music by quite a bit. I also have other ideas for a BPM-based timer that I'd love to implement.

  2. Hello there!

     

    I require a more precise timer that deals with millionths of a second, or more. I've played around with default Leadwerks Time commands, but the most precise I can get is a thousandth of a second, eg:

     

    
    

    Time:GetCurrent() / 1000

    -- 0.654

     

    Does anyone know a way in which I can handle millionths or billionths of a second with Leadwerks and Lua?

  3. Hello,

     

    Time:GetCurrent() seems to be rounded to a maximum precision of three decimal places, and I need it to be more precise for my timer. Is there any way I can have a more precise time, to say five or six decimal places?

     

    Thanks! smile.png

  4. How about a "MonsterManager" script that keeps track of each entity that are referred to in a Lua table? This could be done dynamically as well: as you load from the prefab, add the monster entity to the Lua table, then refer. The "MonsterManager" could also have a function to delete/kill the each monster in the table, perhaps by setting a boolean, eg: monsters[index].killed = true?

     

    I have a similar setup for displaying game achievements. I could adapt it to keeping track of entities.

     

    I can work on some code/pseudo code to better explain the idea if wanted. smile.png

  5. Hiya,

     

    You can refer to the monster's health this way:

     

    
    

    Script.monster = nil --entity "Monster"

     

    function Script:Start()

    if (self.monster == nil) then

    Debug:Error("Please attach 'monster' script.")

    end

    end

     

    function Script:PostRender(context)

    context:SetBlendMode(Blend.Alpha)

     

    -- Get the current health

    local monsterHealth = self.monster.script.health

     

    -- Set the draw color to white

    context:SetColor(1, 1, 1)

     

    -- Display the health on screen

    context:DrawText(tostring(monsterHealth), 2, 2)

     

    context:SetBlendMode(Blend.Solid)

    end

     

    The first line will allow you to link the Monster's script to this one via the Leadwerks Editor view.

     Script.monster = nil --entity "Monster" 
    

    Simply attach this script to a pivot in your scene. After doing so, a blank box should be displayed labeled "Monster". Drag and drop the Monster entity to this (from the Scene tree). You will now be able to access all variables and functions contained therein via this script.

     

    I hope this helps!

  6. Hi there!

     

    Just a quick update, I think I found the original problem: originally, I was rushing through the scene quite fast (far faster than a player would) and triggered many sound sources to play at once. I'm guessing OpenAL doesn't like this, and must "overload" somehow. I have stopped rushing around since. :)

     

    I know it may seem silly running through the scene that fast, but I did have an excuse.

     

    Word to the wise: don't trigger loads of sound sources at once. Not good! :)

    • Upvote 1
  7. Hi.

     

    Igor's motion blur works by blurring the full screen during camera rotation. My camera is fixed to the player, and I'm wishing to only have motion blur on the player entity alone, not the whole screen. I guess I could adapt his script and shader to do this, but I have no idea where to start.

  8. Hi Rick.

     

    Thanks for your help! I've got myself some "Loading..." text displaying during the map load now. Not really what I wanted, but it'll do - better than a blank screen!

     

    I tried to draw the name of the current entity being loaded, but it didn't display. I might be missing something simple, so I may pursue a better loading screen in the future.

     

    Thanks again for your help!

  9. Howdy!

     

    Since it looks like I can't create threads using Lua, how would I go about creating an animated loading screen during a map change using Lua?

     

    The program seems to freeze during this process, and I wish to display images, text, etc and update these of their own accord while loading the next map. For example, I wish to display: an animated loading icon, and displaying an image slideshow.

     

    Many thanks in advance!

  10. Hi all!

     

    I'm wanting to create a motion blur effect on the player entity. I'm wondering how to go about this as the camera follows the player: so overlaying the previous rendered image probably wont work, as the player is always center screen.

     

    I'm guessing I could go about achieving the effect by creating a shader which duplicates the diffuse texture of the player entity and stretches it across the screen, and/or duplicates it across the screen with a fade on the alpha.

     

    I'm just getting started with shaders, and creating effects such as this, so I'm hoping someone can offer some advice or tips.

     

    Many thanks in advance!

  11. Thank you for your replies guys!

     

    I reworked my audio managment after being inspired by Gonan's reply and changing maps no longer causes errors. It's a good thing too because I've simplified everything and it's far easier to manage. :)

     

    I'm still not sure whether my previous way of managing the audio was the problem or if I did indeed encounter a bug. I may look into that again in an attempt to figure it out.

     

    Thanks again!

  12. Hey guys!

     

    I'm experiencing an issue when I try to switch maps: "OpenAL: AL_INVALID_OPERATION".

     

    I have many small audio samples loaded as a Source in one map (each 1 second long), each being played whenever the player triggers them through interaction. I've noticed that if none of the samples are played the map will switch just fine, but if one or more are played the map switch will fail with the above error.

     

    I've tried explicitly telling each sample to stop playing right before the map switch, just to make sure, but this didn't work. I've also combined this with releasing each Source, again with no luck.

     

    What could this invalid operation be, and how do I solve it?

     

    Many thanks in advance!

  13. This is VC++ related only ?

    I have Lua project running, and errors don't delete the Exe file i compiled before.

     

    Yeah. I'm 100% sure it's some issue with Visual Studio itself, or perhaps the connection between Visual Studio and the project.

     

    If you use Lua, and use the Leadwerks Editor to write your scripts, I'd say you're pretty much 100% safe from this. smile.png

  14. maybe for some reason your compile cancels and the file is actually deleted since the compile stopped while writing the file?

     

    Just guessing.

     

    That's a very logical guess and I'd bet that's the answer! The only thing now is to find a solution to the problem, since when the executable is deleted I can't run the game via Visual Studio.

     

    My current workaround is to copy all the relavent files to a new folder, delete the project, create a new one and paste the files into the new project. I'd rather not have to do this anymore, so I hope someone could offer a solution to the problem, or at the very least a better workaround.

     

    It seems to occur when there are errors in the code. Not always, but that seems to be the case.

×
×
  • Create New...