Jump to content

Genebris

Members
  • Posts

    517
  • Joined

  • Last visited

Posts posted by Genebris

  1. I have also used material names to determine sound type, for example, material named "my dark_wood 76" will play "wood" sounds. But my script uses footsteps manager like old animation manager. This way you can use it both for player and NPCs and any other objects.

     

    Supports several sounds per material type, 3D sound, can be played from many characters at the same time, only need 3 lines of code to add to your script (import, create, update).

     

     

    Main script: https://gitlab.com/Genebris/MSC-Footsteps/blob/master/Scripts/Footsteps.lua

     

    Download project (120 MB): https://gitlab.com/Genebris/MSC-Footsteps/repository/archive.zip?ref=master

    • Upvote 5
  2. You can remove main.system to make the function global by itself.

    function CallFunction(entity, func, a,b,c)
    

     

    This fragment simply calls needed function with optional parameters. You don't have to use any parameters, or you can use only two of them because it's Lua.

    
    

    ...

    func = "Hurt"

    a = 5 --damage

    b = "Magic" --damage type

    --C not used

    entity.script[func](entity.script,a,b,c)

    ...

     

    You need to pass entity.script as a first parameter because you are calling function via "." instead of ":"

    I think I wasn't able to call it with ":" this way, so I passed script manually.

     

    When you have global function created all you need to do is this:

    
    

    local e = Prefab:Load("prefabs/myprefab.pfb")

    CallFunction (e, "Start")

  3. I made this function so I can call something on all child objects at any time from any script.

    
    

    function main.system:BroadcastMessage(entity, func, a,b,c)

    if entity.script and type(entity.script[func])=="function" then entity.script[func](entity.script,a,b,c) end

    for i=0, entity:CountChildren()-1 do

    local child = entity:GetChild(i)

    if child:CountChildren()~=0 then self:BroadcastMessage(child, func, a,b,c) end

    if child.script and type(child.script[func])=="function" then child.script[func](child.script,a,b,c) end

    end

    end

    • Upvote 1
  4. 
    

    Prefab:Load("prefabs/projectiles/arrow.pfb")

    Prefab:Load("prefabs/projectiles/arrow.pfb",Map.LoadScripts,Prefab.NoStartCall)

     

    First function will load prefab correctly, second one will fail to load it. This will be in the log:

     

    Loading prefab "C:/Users/Genebris/Desktop/SotKaal/prefabs/projectiles/arrow.pfb"...

    ..

    Loading prefab "prefabs/projectiles/arrow.pfb" [32]...

    Error: Failed to read file "prefabs/projectiles/arrow.pfb".

    Error: Failed to load prefab "prefabs/projectiles/arrow.pfb".

     

    You can see that second call didn't get a correct file path. This happens ONLY in published game (standalone or launcher). Does NOT matter if you included only used files or not.

    It doesn't happen in the editor or if you launch exe in your project folder.

     

    I'm not sure if this is the correct use of loading flags, but if it's not, it should at least give the same error in the editor because I spent 40 minutes thinking that my prefab doesn't get included into the build.

  5. You need blend mode set to alpha, z sort enabled and change diffuse color to half transparent. There is also default glass material in Materials/Effects in FPS template. But all half transparent materials really don't work well in Leadwerks, they won't receive shadows.

    • Upvote 1
×
×
  • Create New...