Jump to content

bansama

Members
  • Posts

    64
  • Joined

  • Last visited

Posts posted by bansama

  1. "Run through leadwerks" does this mean debug (the bug icon) or release (the play icon) ?

     

    I mean both of the run options offered in Leadwerks while it's running. They're represented by a full green arrow and an outline green arrow. Doesn't matter which I use, both will cap at 30 fps when sync is set to true. Only when the project is published through the project manager does sync then cap at 60 fps (which would be right for my monitor).

  2.  

    Nope.

     

    Framerate is not capped at 30.

     

    Then I wonder what's going on. My hardware has not changed. They only thing that has is Leadwerks though the normal non-beta updates =/

     

    I've also just tried building a new copy of my old project and that is now capped at 60 fps when published as a standalone. So something has definitely changed in the last few months.

     

    Update:

    Yeah, something has definitely changed with app.lua. I managed to build the project again with the old app.lua script and that one shows fps of several hundred. With the current default app.lua script created by Leadworks, it is showing a cap of 30 when testing through Leadwerks (both Debug and Run) or 60 when published.

  3. With one possible exception, I've never had an update break scripts. I can't even be sure it was an update that did break the script that stopped working... That said, I have had updates wipe out all connections in the Flowgraph. I've also had to manually update all my projects as a new update to Leadwerks only seems to give you a warning that existing projects are out of date. So if you're concerned something will break, there's certainly opportunity to make a backup of the project directory yourself.

     

    As for getting a refund from Steam, they do offer a one-time goodwill gesture refund. But you'll have to fight for it and be polite while doing so.

  4. Note that I don't think your csg trigger can be touching anything. In your test scene if the pad is level with the ground setting to Trigger didn't work, but if I raised the pad so it's floating in air, it worked.

     

    Yeah, I just found this. It only works if I make the trigger object really tall. Perhaps this is connected to the height of the player?

     

    This now appears to be working again. I would still like to work out how to use a separate entity to toggle this though just in case something else breaks it again in the future (and it could probably be useful for other things too). That is, to be able to access the variable for enabling/disabling with an imported script. I think I have an idea of how to try this. I just need to wrap my head around self and local variables...

     

    Thanks everyone for all the help and ideas thus far.

  5. I have tried exactly as your video, making trigger objects on the pads and adding the script to the triggers. In that case nothing happens. That is, I collide with the trigger and don't teleport. If I add the script to the pads without the teleport, they work as long as their collision type is not trigger (but with the behaviour mentioned at the start of this topic). In short, the Trigger collision type is not working for me.

  6. When I run your map I don't have any trigger objects. The scene only has:

     

    Directional Light 2

    Box 1

    Pad 1

    Pad 2

    Pivot 2

     

    You probably need to add the included script to Pad 1 and Pad 2, linking to the other pad respectively. The forum was being a pain while I was trying to attach the files.

  7. Thanks for the answer but, now everytime I run the game there's a black screen that says "Leadwerks". Again, I'm pretty new to Lua, so I really don't know how to put the text to show up only when the player interacts with the object.

     

    I'm new to Lua too and wanted to to something similar myself. It probably isn't very good, but my solution was as follows:

     

    Script.ObjectDescription = "" --String "Object Description"
    Script.DisplayTimeMax = 5000 --Int "Display time"
    Script.Used = "0"
    Script.DisplayTime = 0
    Script.DisplayEnabled = false
    local font1 = Font:Load("Fonts/arial.ttf", 15)
    
    function Script:Use(context)
      self.Used = "1"
      self.CurrentTime = Time:GetCurrent()
      self.DisplayTime = Time:GetCurrent() + self.DisplayTimeMax
    end
    
    
    function Script:PostRender(context)
      if self.Used == "1" then
      App.context:SetBlendMode(Blend.Alpha)
      App.context:SetFont(font1)
      self.DisplayEnabled = true
    	   if self.DisplayEnabled == true then
    		    if self.DisplayTime > Time:GetCurrent() then
    
    				 self.texture = Texture:Load("Materials/Developer/GreenGrid.tex")
    				 App.context:SetColor(1,1,1)
    				 App.context:DrawRect(598,598,304,104,0)
    				 App.context:DrawImage(self.texture,600,600,300,100)
    				 App.context:SetColor(1,1,1)
    
    				 App.context:SetColor(0.1,0,1)
    				 context:DrawText(self.ObjectDescription, 610, 625)
    			 else
    				 self.DisplayEnabled = false
    				 self.Used = "0"
    			 end
    		   end
    		   App.context:SetBlendMode(Blend.Solid)
    	   end
    end
    

     

    Basically, this allowed me to display a short piece of text with a background when I pressed the Use key over an object the script was attached to.

    • Upvote 2
  8. So I took the script above and remove it to just be the below and it works fine for me. When I teleport and if I'm still touching the trigger I can move very small increments inside the trigger and stop and nothing happens. I then move out of the trigger and back in and I get teleported. I don't get what the problem is. In my example and what I did is make a pivot and set it as the player (collision type of character and physics mode of character controller, and attach the FPSPlayer.lua script to it). Are you doing something different maybe that's causing an issue?

     

    Even with that stripped down script, the result is the same. The only difference is likely that I am using the default FPSPlayer.pfb. But that has the same Physics mode, Collision type, and script that you are adding to a pivot, so it shouldn't be acting any different. Have you tried your script using the FPSPlayer.pfb?

     

    I've tried making a brand new map, using a pivot as the character and again, the same problem occurs.

     

    Just in case, I've attached a rar of the new map I just knocked together, along with the script I attached.

    _temp.rar

  9. Really? I don't recall that happening at all. Are you saying when you get teleported and you move slightly but are still inside the trigger it'll say you've exited? If you don't move at all after teleportation does it do anything?

     

    Yep. The script acts as if an "exit" is detected when you stop moving and then move again. I.e., teleport and jump, etc. I can solve that by not allowing the script to enable itself, but that makes the teleport one-way. If I then move away from the teleport and re-enter, it won't send me back to the original teleport.

     

    The script above is what I think I should work from for the outer pads (the ones I want to use to enable the teleports. The script I am using on each of the actual teleports is as follows:

     

    Script.entered = false
    Script.exited = false
    Script.hadCollision = false
    
    Script.Target = nil --entity
    Script.Enabled = true --bool
    
    
    function Script:UpdatePhysics()
       if self.entered then
           if self.hadCollision == false then
               if self.exited == false then
                   self.exited = true
                   self.component:CallOutputs("OnExit")
                   --System:Print("Exited")
                   --self.Enabled = true  ** this can also be self.Target.script.Enabled = true, doesn't matter it will have the same effect **
                   self.entered = false
               end
           end
       end
       self.hadCollision = false
    end
    
    function Script:Collision(entity, position, normal)
    -- speed
    self.hadCollision = true
    self.component:CallOutputs("OnCollide")
       if self.entered == false then
           if self.Enabled == true then
               self.component:CallOutputs("OnEnter")
               --System:Print("Entered")
               self.Target.script.Enabled = false
               --entity:SetPosition(self.Target:GetPosition()) -- Teleports
               if entity:GetKeyValue("name") == "Player" then
                   EntPlayerCoord = entity:GetPosition():ToString()
                   --System:Print("Player "..EntPlayerCoord)
                   EntPadCoord = self.entity:GetPosition():ToString()
                   --System:Print("Send Pad "..EntPadCoord)
                   TarPadCoord = self.Target:GetPosition():ToString()
                   --System:Print("Targ Pad "..TarPadCoord)
               end
    
    
               PlayerTable = split(EntPlayerCoord, ", ")
               --for key,value in ipairs(PlayerTable) do
               --    System:Print( key .. " has value " .. value)
               --end
               SendPadTable = split(EntPadCoord, ", ")
               --for key,value in ipairs(SendPadTable) do
               --    System:Print( key .. " has value " .. value)
               --end
               TarPadTable = split(TarPadCoord, ", ")
               --for key,value in ipairs(TarPadTable) do
               --    System:Print( key .. " has value " .. value)
               --end
    
               -- Will need to use checks like this
               -- to help cope with minus numbers, etc., when teleporting
               BaseValue = "0" -- Need to set this to avoid error
               if SendPadTable[1] < BaseValue then
               OffsetX = PlayerTable[1] - SendPadTable[1]
               --System:Print("LT X " .. OffsetX)
               end
               if SendPadTable[2] < BaseValue then
               OffsetY = PlayerTable[2] - SendPadTable[2]
               --OffsetYa = SendPadTable[2] + OffsetY
               --System:Print("LT Y " .. OffsetY)
               end
               if SendPadTable[3] < BaseValue then
               OffsetZ = PlayerTable[3] - SendPadTable[3]
               --System:Print("LT Z " .. OffsetZ)
               end
    
               if SendPadTable[1] >= BaseValue then
               OffsetX = PlayerTable[1] - SendPadTable[1]
               --System:Print("GT X " .. OffsetX)
               end
               if SendPadTable[2] >= BaseValue then
               OffsetY = PlayerTable[2] - SendPadTable[2]
               --OffsetYa = SendPadTable[2] + OffsetY
               --System:Print("GT Y " .. OffsetY)
               end
               if SendPadTable[3] >= BaseValue then
               OffsetZ = PlayerTable[3] - SendPadTable[3]
               --System:Print("GT Z " .. OffsetZ)
               end
    
               TargetX = TarPadTable[1] + OffsetX
               TargetY = TarPadTable[2] + OffsetY
               TargetZ = TarPadTable[3] + OffsetZ
               --System:Print ("XYZ: " .. TargetX .. ", " .. TargetY .. ", " .. TargetZ)
               entity:SetPosition(TargetX, TargetY, TargetZ)
           end
    
           self.entered = true
           self.exited = false
       end    
    end
    
    
    
    function split(s, delimiter)
       result = {}
       for match in (s..delimiter):gmatch("(.-)"..delimiter) do
        table.insert(result, match)
       end
       return result
    end
    

     

    Don't mind the system:prints, I just used those while coding to check what the script was doing. The section commented with ** is where enabling the teleport again is likely causing the problem. This is why I need to work out how best to enable the script again from a different entity. Does this make any sense?

  10. Could you not just make a switch which is near the teleporter that you have to press that turns the teleporter on. Afetr one use the switch is automatically set back to off. This might interrupt the flow of the game, depends what you are going for.

     

    Another idea is to use Entity:GetDistance that will switch the teleporter back on when you have moved so far away.

     

    The first suggestion is not going to work, no. I am using the teleports as a way to move players around without their knowledge, so having them specifically hit a button isn't going to work in all situations.

     

    The second idea might work, thanks. But again, I could use some help on how best to access variables from an imported script, as half the time I try, they cannot be found (I get the usual attempt to access nil value error).

  11. Reference: http://www.leadwerks.com/werkspace/topic/8462-how-to-pass-variables-between-scripts-lua/

     

    As a follow on to what I was doing in the above topic, I notice that a later update to Leadwerks resulted in my solution breaking a bit. I'm now trying to find a better way to do things. But I have noticed some strange behaviour which I'd like to try and resolve.

     

    The following is the basic collision script I am using:

     

    Script.entered = false
    Script.exited = false
    Script.hadCollision = false
    
    Script.Target = nil --entity
    Script.Enabled = true --bool
    
    
    function Script:UpdatePhysics()
    if self.entered then
    if self.hadCollision == false then
    if self.exited == false then
    self.exited = true
    self.component:CallOutputs("OnExit")
    
    		 -- command for enabling placed here
    
    self.entered = false
    end
    end
    end
    self.hadCollision = false
    end
    
    function Script:Collision(entity, position, normal)
    -- speed
    self.hadCollision = true
    self.component:CallOutputs("OnCollide")
    
    
    if self.entered == false then
    if self.Enabled == true then
    self.component:CallOutputs("OnEnter")
    self.entered = true
    self.exited = false
    end
    end
    end
    

     

    The basic idea is that on detecting collision, the trigger activates and performs what I need it to do. In this case, it's a teleport. As such, it also needs to disable the script for the receiving end. But when entering the receiver a second time, it should allow the player to return to the original teleport.

     

    My problem is, the script detects the player as "exiting" as soon as the player stops moving. Thus, the script activates when the player moves again (either when they walk, or change where they are facing).

     

    This can cause a loop where the player rapidly moves from one pad to the other.

     

    As such, I'm trying to find a good way to ensure the script only resets to its default active state when the player really does "exit" the entity the script is attached to.

     

    The solution I thought of trying was to have an outer pad and an inner pad for both teleporters. These would be separate entities of course. Imagine something like:

     

    <Pad a [Pad b]> <Pad c [Pad d]>

     

    Pad a and c are the outer pads, these I would want to use to enable the scripts connected to Pad b and d respectively. Pad b and d are the actual teleports, they will move the player to the linked pad [b to d, d to b]. But these scripts need to disable themselves as soon as a teleport has finished.

     

    The aim being that the player will not then re-teleport until they have actually left the pad (ie, made contact with pad a or c).

     

    Could someone suggest a good way to do this?

     

    I was thinking of importing the script attached to the teleport pad into the script attached to the outer pad, but could then not work out how to actually interact with the variables from the imported script.

     

    All help and suggestions will be greatly appreciated!

  12. So I was just rewatching this tutorial, which is a part of the "Pick Up Objects" tutorial map. It mentions that if you press the left mouse button, the carried object should be thrown. This is not the case. Using that tutorial map, or any map for that matter, the left mouse button does nothing while carrying an object. Was something perhaps changed in an update that has rendered this non-operational?

  13. Maybe if people gave ideas on how this should work someone will look into it.

     

    Something that introduces a new user (or returning one, wanting a refresher) to the features in Leadwerks, in a coherent and consistent manner. The tutorial levels, etc., are nice but each one is individual and self-contained. If the features could be introduced while guiding the user in the creation of an end product, it may help with learning how everything interacts together. This need not be anything too complex. It just needs to be a consistent project that walks through each feature.

     

    The actual documentation is okay, but many of it lacks a working example to help explain how that feature works. Some have script examples of course, but many of those don't do anything but cause an error if you try to plug that script into a default Leadwerks setup.

  14. You can simulate classes. Look at the Animation script included in all projects to see how you do this. This gives you a more C++ feel and allows you to make "classes" for your functionality. It's a nice clean way to handle stuff like this.

     

    If it's not too much trouble, could you explain this a little more? I've looked at both AnimationManager and SimpleAnimation scripts, and don't get which one you are referring to. The contents of AnimationManager are definitely beyond my current understanding. This would certainly prove useful for a variety of things, so I'd like to gain an understanding of this.

  15. Now see, this is the exact type of response some one just might be looking for. o flaming, no hurt feelings of veteran members because we noobies arent getting it right off as non coders.

     

    Off topic, I know, but I also wanted to echo this. The kindness and helpfulness of the Leadwerks Community is what makes my feel my $100 was well spent.

    • Upvote 1
  16. You could try using Time:GetCurrent() to deal with the specific amount of time. By the way, does pressing F11 drop your FPS that much?

     

    Thanks! I had looked at Time: but hadn't realised I could use it that way. Silly really, as I used to use similar in PHP years ago (I'm very rusty with coding). But thanks to your help, I now have something to work with!

     

    Pressing F11 itself doesn't drop frame rate no, but the default set up in App.lua has any rendering toggled off with F11. I did try to create a new window, etc., to render text to, but that never worked with either Assert failed crashes or other errors. I've since added a section after the F11 toggle which seems to help. So the relevant section in App.lua now looks like this:

     

     --Render statistics
    self.context:SetBlendMode(Blend.Alpha)
    if DEBUG then
    self.context:SetColor(1,0,0,1)
    self.context:DrawText("Debug Mode",2,2)
    self.context:SetColor(1,1,1,1)
    self.context:DrawStats(2,22)
    self.context:SetBlendMode(Blend.Solid)
    else
    --Toggle statistics on and off
    if (self.window:KeyHit(Key.F11)) then self.showstats = not self.showstats end
    if self.showstats then
    self.context:SetColor(1,1,1,1)
    self.context:DrawText("FPS: "..Math:Round(Time:UPS()),2,2)
    end
    -- Allows text to be rendered when FPS is toggled off
    self.context:SetColor(1,1,1,1)
    self.context:DrawText("", 0, 0)
    end

     

    I do get frame rate drops, but only when outputting with System:Print() which I use from time to time to help with debugging. And that was the cause of my FPS drops I think with the While loop I was testing.

×
×
  • Create New...