Jump to content

AggrorJorn

Members
  • Posts

    4,816
  • Joined

  • Last visited

Blog Comments posted by AggrorJorn

  1. Small update published: I have added the parameters as indexes as well. The syntax is converted from

    SetRotation(number pitch, number yaw, number roll,  bool global=false)

    to

    SetRotation(pitch, yaw, roll, global)

    The description contains the explanation of the parameters. see image below. It is not waterproof though. Sometimes the syntax parameters are missing in the description, causing the description to be empty or imcomplete. You can identify mistakes/incomplete information in the documentation easier this way.

     The biggest downside at the moment is the way Vs code scales the intellisense window. Right now that is not optimal. However there is word that they are working on that by making the styling more accessible through settings. In the image below I applied custom styling to make the width 2 x its original size.

    AddForce command with 2 different versions of paramters.

    image.png.fc0af2e1a73ad616c5cc8e4ae83cc962.png

    image.png.5b158b75c54b8bbb534054c0ae96d8d5.png

     

    • Like 1
  2. It was really interesting to follow along with the lua/C++ discussion with Josh and Rick. I feel like I learned a lot by just reading the comments. 

    My money is on Gearhead Engine (a person who pursues mechanical or technological interests (as in automobiles or computers). Fits with the gear logo too. But seriously surprised about the name change.

    Either way, I like how you are open to the feedback of the community.

  3. That looks amazing! There is so much overhead disappearing this way. Looking forward to using it.

    So you would get something like this?

    --le4
    Script.playerEntity = nil --entity
    local playerScript = nil
    
    function Script:Start()
    	--Get the script of the  referenced player entity and call its hello function
    	playerScript = self.playerEntity.script
    	playerScript:Hello()
    end
    
    --le5?
    Script.playerEntity = nil --entity
    
    function Script:Start()
    	self.playerEntity:Hello()
    end

     

  4. The popup window can be restyled I think. I haven't tried it yet, but it is basically css so perhaps it is fairly easy to achieve a larger width.

    Adding the parameter information to the description could work. This way I can also add 'cleaner' parameter names. As long as the documentation holds up to its current parameter convention, it can be easily transformed. 

    type name: "number x" or "bool ignoreCollision"
    type name=value: "bool global=true" or "number velocity = 1.0"

    Fyi: at https://www.leadwerks.com/learn?page=API-Reference_Object_Entity_SetPosition the first syntax is missing a comma.

    • SetPosition(number x number y, number z, bool global = false)
  5. 7 hours ago, Josh said:

    Seeing all the API in VSCode is pretty awesome. It looks like this is your raw input from the docs:

    
    SetRotation(number pitch, number yaw, number roll,  bool global=false)

    And you will want to turn that into this:

    
    SetRotation(&pitch, &yaw, &roll, &global)

     

    Yeah those parameters need some work. What do you think looks better? Your post or the thing below?

    SetRotation($number_pitch, $number_yaw, $number_roll, $bool_global=false)
    SetRotation($vec3_rotation, $bool_global=false)

    On one hand I don't want to lose the type, but on the other hand it looks uglier. Both are just easily made so its just a matter of picking a style.

  6. 5 minutes ago, Josh said:

    I am also considering the Squirrel script language. It's like a cross between Lua and C++:
    http://www.squirrel-lang.org/

    Valve is using it for a lot of their games.

    Never heard of it but it looks pretty good at first glance. The constructutor, classes and inheritance support by default are a big plus.  https://en.wikipedia.org/wiki/Squirrel_(programming_language)

  7. 1 hour ago, Josh said:

    One would be a comment above the function that hints at what type of object each parameter should be.

    That actually doesn't sound bad. For the Leadwerks API that could result in something like this. People can use this for their own functions too, but it is not mandatory.

    --pos, A vector 3 position
    --global, boolean that detemines global=true or local=false 
    SetPosition(pos, global)

     

    1 hour ago, Josh said:

    This would work for variables called "entity", "world", as well as "texture2", "entity_test", etc.

    This gives me bad memories to an internship were every variable was prefixed with the datatype: (integer) i_myVar, (string)s_myVar. I personally find this really ugly. 

     

    1 hour ago, Josh said:

    The other part of this would be a static analysis routine that can figure out types based on the code:

    That is how I did it in my post. Funny to see you would do something similar.

    • Like 1
  8. 18 hours ago, Josh said:

    Can it be configured to display Leadwerks commands? How does it know the object type? For example, in this function how can you tell it that the entity is a Leadwerks entity object?

    
    function Script:Collision(entity0,entity1,position,normal,speed)
    	entity0:...
    end

     

    These are things that I haven't tried yet. I will have to play around with this before I can give an accurate answer. Like I said, it is not as powerful as with strong typed languages like C#/C++. But maybe something like showing a list of all Leadwerks functions is possible once you have type something like "myVariable:". The 'intellisense' you saw in the screenshot above only roughly displays some of the functions it can find on the page and perhaps some other methods. Either way a custom intellisense extension could work/help, but will not be as sophisticated as C#/C++.

    Perhaps when the colon is typed, the variable used in this case, could be lookup in the current page and see where it is first declared. The intellisense could see that 'Model:load' is used and 'assumes' it is a model, display Leadwerks model functions first. I don't know, just thinking out loud here. 

    local someVariable = Model:Load()
    someVariable: 

    There is enough stuff out here to spend a lot of time on. Will make a video/blog if I have something worthwhile.

  9. 2 hours ago, Rick said:

    I have VS Code but haven't worked too much with it. It's crossplatform too isn't it? Do you like it? Honestly with it being newer and more lightweight I'm sure it's great and could probably be considered as a defacto editor for lua and LE.

    Some advantages that make it my default text editor next to notepad++

    • Comes with various default styles, but can be completely styled to ones desire.
    • Supports many languages. Lua support via plugins.
    • Lightweight 
    • Crossplatform
    • You can attach your own debugger code via debugger extensions. 
    • My favorite: can be easily extended with custom plugins.
      • I could make this little leadwerks plugin that looks at the online documentation and shows it in the second screen. It could actually load in the entire Leadwerks api from here and display it for you.
      • You can even extend the intellisense using your own documentation
      • Something like this: https://github.com/Microsoft/vscode-extension-samples/tree/master/contentprovider-sample
      • it can automatically install a lua intellisense plugin as a dependency.
      • You can import all keyboard shortcuts from visual studio if you want
      • I ahve got dozens of little snippets already made this way: 
        • For instance type: lestart followed by 2 tabs and you get:
    function Script:Start()
    
    end

     

     

    • Like 1
  10. 31 minutes ago, Rick said:

     However, like I was saying as long as there is a networked way to communicate with the LE editor then people can use whatever they want and feel comfortable with because all of those frameworks can make network connections to do that communication very easily.

    That would also go for the debugger. If we had an api to Leadwerk we can add our own IDE's. I use Visual studio code for writing Lua but it lacks the debugging options. It is possible to extend the tool with a custom debugger but not without having access to leadwerks debugger functionality. 

  11. 13 hours ago, Josh said:

    I think it would actually work if you made mytable.insert equal to the function table.insert. ?

    That flexibility is the strong part of Lua (arguably also a weakness). I am sure you could even adept the default table behavior to do this automatically for all tables. It is a pity Lua doesn't do this by default.

  12. 2 minutes ago, Josh said:

    I usually avoid indices at all. Instead, I insert items with Table.Insert() and iterate through them with pairs() or ipairs():

    I guess for general tables that is a better approach. However when using a multidimensional array, I prefer indices.  I do find the Table.insert function a bit weird. I wish Lua did it more like below. It helps when using intelisense.

    myTable:Insert("Thing 1") 

     

    • Like 1
  13. 13 minutes ago, Josh said:

    or ipairs() to iterate through them in numerical order.

    You have the same issue there when using ipair, the 0 index is ignored. Try it out Lua online.

    output

    create enemies: 4
    I am enemy 0
    I am enemy 1
    I am enemy 2
    I am enemy 3
    
    #enemiesCount: 3    
    
    I am enemy 0
    I am enemy 1
    I am enemy 2
    
    Using IPAIR
    1_I am enemy 1
    2_I am enemy 2
    3_I am enemy 3
    
    Using PAIR
    1_I am enemy 1
    2_I am enemy 2
    3_I am enemy 3
    0_I am enemy 0


     

  14. So the mortar scripts works with a raycast to detect impact. 

    What you can do is trying to find out where the raycast is going.You can store the origin and target of the raycast and draw a line between them

    self.pos = self.entity:GetPosition(true)
    self.targetpos = Transform:Point(0,0,self.movespeed/60.0 * Time:GetSpeed(),self.entity,nil)
    
    function Script:PostRender(context)
    	--You need a camera refernce in this script.
    	local p1 = camera:UnProject(self.pos)
    	local p2 = camera:UnProject(self.targetPos)
    	context:DrawLine(p1.x, p1.y, p2.x, p2.y)
    end

     

  15. Looks nice. 

    as for the projectile not directly exploding: without seeing the script for the projectile we can only gues.

    As for the force to apply. Since you use an angular mortar, all you need to do is play with the angle you fire and the maximum fire power.

    • First experiment with the angle of the mortar. With a force of 1000, which angle will get you the furthest? 
    • When you have gotten the furthest distance, ask yourself if this is the maximum required distance of the mortar.
    • Adjust the force of the mortar to match the maximum distance.
    • As for a basic adjustment. Try something like this (I haven't tried it):
      • Force is 1000
      • Lets say an angle of 45 gives you a distance of 80 meters
      • Lets say an angle of 80 gives you a distance of 10 meters
      • If an enemy is at 60 meters: 
        • 80-10 = 70. (max dist-shortest dist = gapDist)
        • 60-10=  50. (enemy dist - shortest dist = distRange)
        • 50/70=0.7. (distRange / gapDist = distRatio)
        • 80-45 = 35 (maxAngle - minAngle = angleGap)
        • 35* 0.7 = 24.5 (angleGap * distRatio = additionalAngle)
        • 24.5 + 45= 70.5 (additionalAngle + minAngle = newAngle)
      • You can add an additional random value to the force or the angle to get some more random results.
    • Like 2
×
×
  • Create New...