Jump to content

Genebris

Members
  • Posts

    517
  • Joined

  • Last visited

Posts posted by Genebris

  1. I have quickly tried to edit terrain shader and realized you can actually cutout fragments depending on texture color to make a visual "hole". If you also add a trigger that toggles player collision with terrain, you will actually be able to do this, but in a messy way.

     

     

    I have added this to the end of terrain shader:

    if (outcolor.x==1)
    discard;
    

    I barely have any idea of what I did because I know nothing about shaders, but I meant to remove red fragments from terrain and it worked.

    Add trigger that does this and you can walk through.

    Collision:SetResponse(Collision.Character, Collision.Scene, Collision.None)
    
    • Upvote 10
  2. The problem I had, was that I needed to also access an element within the table and I struggled figuring out a way to search for a keyword within the file.

    what's the problem?

    
    

    local name = "health"

    while (not stream:EOF()) do

    local s = stream:ReadLine()

    local i = string.find(s,"=")

    local k = string.sub(s,1,i-1)

    if k==name then break end

    end

    --here is your line

     

    But I have a question. What does string.sub exactly do?

    You give it string and two indexes, it returns part of the string between them.

  3. 1)Get entity unique id ? If I have 10 crawlers how do we know which is which when saving and loading ?

    Great question, we need a value that is the same each time you load a map, but is unique for every entity. MAYBE if Start execution order is always the same, then you can assign id yourself, but I doubt. This is probably not reliable.

    
    

    function Script:Start() {

    if not IDCounter then IDCounter = 0 end

    self.ID = IDCounter + 1

    IDCounter = IDCounter + 1

    ...

    Or just by entities order with world:GetEntity() if it's always the same.

     

    2)How to get the animation state of a crawler and make it continue playing that animation after loaded. Example the crawler is playing attack animation and at the frame no15 , when loaded it back it should continue playing attack animation at frame no15.

    I don't think you can do this with new animation commands. Strange, there is SetAnimationFrame but no GetAnimationFrame.

    But you can do it with old AnimationManager script.

  4. Why can't you make a table of all needed data and loop through it to save each table key and value into file?

    Remember that these two lines refer to the same variable:

    
    

    myTable.abc

    myTable["abc"]

     

    Try something like this:

    
    

    for k,v in pairs(myTable) do

    stream:WriteLine(k.."="..v)

    end

    This way you will get a file like this:

    health=35

    armor=20

    magic=110

     

    To load this data into the game you need to read each string, separate it by "=" symbol and use left part as key and right as value.

    
    

    data={}

    while (not stream:EOF()) do

    local s = stream:ReadLine()

    local i = string.find(s,"=")

    local k = string.sub(s,1,i-1)

    local v = string.sub(s,i+1)

    data[k]=v

    end

    I haven't actually tried this code, so there can be mistakes.

    I believe you won't even need to convert value from string to number, it should be converted automatically if used in calculation. But you can also use tonumber function http://www.lua.org/manual/5.1/manual.html#pdf-tonumber

     

    You can also use string value to access global table itself because every global variable is an element of _G table. These two lines also refer to the same variable:

    
    

    myT.a

    _G["myT"]["a"]

     

    So you can make a header in your save file like this:

    [player]

    health=10

    magic=20

     

    And when you read a string that starts with "[" you can use it as a name of table which you are going to fill with data.

    
    

    if string.sub(s,1,1) == "[" then

    local tableName = string.sub(s,2,string.len(s)-1)

    ...

    _G[tableName][k]=v

  5. In the last two tournaments I realized how painful it is to use editor when you have more than 10 objects on the map. I think it could be changed with a few improvements:

     

    Characters' bones and other child objects take up most of the space in the hierarchy window and 99% of the time you don't need to look at them.

    q7jKJDE.gif

    And this is just one goblin character. Sure, artist probably shouldn't have included so many child objects, but it shouldn't be a problem anyway.

     

    Suggestions:

    • All child objects in the hierarchy should be collapsed when map is opened.
    • When you add new objects, their children should be collapsed by default.
    • It should never uncollapse automatically. It definitely shouldn't uncollapse when object is selected. Again 99% of the time when you select an object you only want to move it, you don't want to check if all those hundreds of bones are still there.
    • There could be a small "Collapse all" button.

    • "Frame Selection" button should scroll the hierarchy to the selected object. Also, there should be a hotkey for it, "F" for example.
    • "Move to folder" button would help avoid a lot of scrolling
    • Search field

    jfaH9Jb.png

     

     

     

    Prefabs suggestions:

     

    When saving altered prefab save dialog should open with a path to prefab's last version.

    For example, I have a prefab with this path: "prefabs/enemies/goblin1.pfb". I have loaded it, changed and pressed save as prefab. Save window should open with "prefabs/enemies/" path opened and file goblin1.pfb should already be selected.

    Not only it saves time, but also eliminates the risk of overwriting wrong prefab and loosing your data, which happened to me several times.

     

    Prefabs should remember a hierarchy folder that they were saved from and appear in this folder when added to the scene. If I have saved goblin in "Entities" folder then it should appear in this folder next time I add it to the scene (if this folder still exists).

    • Upvote 10
×
×
  • Create New...