Jump to content

AggrorJorn

Members
  • Posts

    4,816
  • Joined

  • Last visited

Posts posted by AggrorJorn

    1. You can look for a child pivot called UI position that your attach via the editor.
    2. If you open the model in the model editor, you can see if the model has a head bone in place. If so you can just look for that child entity and gets is position.
    3. Another way is just a float value that you add per character which is an offset to the characters position.
  1. So you load the model, set the script, and mass and physics type are set. And your medkit falls down when you start the game?

    If you run your game in debug mode and debug physics (I think you have to press P or F1) to toggle, does your entity have a physics shape? Does that differ from a medkit that is loaded via the editor?

  2. Note that the pickinfo object needs to be created before you do a pick. 

    local pickInfo = Pickinfo()
    
    if world:Pick( posPivote.x, posPivote.y, posPivote.z, posCamara.x, posCamara.y, posCamara.z, pickInfo, 0, true )  then 
    	System:Print(pickInfo.position)
    end

     

    • Upvote 1
  3. If you still want to use FlowGui, there is a small wiki: https://bitbucket.org/Aggror/flowgui/wiki/GUI Manager

    here is how a minimal example would work:

    • import flowGui somewhere in your main.lua
    • create a flowGui manager
    • create a gui element and add it to the manager. (styles are not even needed to get a ui element to work. )

    Remember that FlowGui is no longer being developed and that is there is an official Leadwerks ui that has been released.

    • Thanks 1
    • Upvote 1
  4. We are getting closer. So for some reason the Flowgui manager is empty in your script. Is it referenced in your countdown script? 

    Instead of linking in the flowGUI manager, you can also create it by script. Note that you only need 1 flowguiManager. So you would either place it in main.lua or you have to make sure it is made only once.

    self.flowGUIManager = FlowGUI_Manager:Create(Window:GetCurrent(), Context:GetCurrent() )

     

     

  5. "argument #3 is 'string';'[no object]' 

    means that you put in an object rather than a string. Can you post the code were you print info?

     

    I tried with FlowGUI it's telling me "attempt to index field 'healthLabel' (a nil value) --line 93

    Can you screenshot the scene tree were you have created the style, guimanager? Child/parent isn't really required but helps organising the scene. As long as the guimanager is loaded first and the styles are being loaded before you create the label, everything should work. If you look at any example scene from the FlowGUI project, you can see that I like to organise my scene as follow:

    • pivot-GuiManager (gui manager script attached)
      • pivot styles (no script attached)
        • timerLabelStyle (labelstyle script attached)
    • mycustomobject (in your case the timer)
      • Referencing GUI manager and Timer lablestyle.

    here is loading the ui style with a wait time build in. I am not at home, so haven't tested it.

    --Load FlowGUI if a script makes use of it.
    import "Scripts/FlowGUI/FlowGUI.lua"
    
    Script.guiManager = nil --entity "GUI manager"	
    Script.healthLabelStyle = nil --entity "HealthLabelStyle"
    Script.healthLabel = nil
    
    Script.uiLoadInterval = 1
    Script.startTimeStamp = nil
    Script.uiLoaded = false
    
    function Script:Start()
    	self.startTimeStamp = Time:GetCurrent()
    	self.guiManager = self.guiManager.script	
    end
    
    function Script:UpdateWorld()	
    	if self.uiLoaded == false and Time:GetCurrent()-self.startTimeStamp > self.uiLoadInterval then
    		self.healthLabelStyle = self.healthLabelStyle.script:GetStyle()
    		self:CreateLabel()
    		sel.uiLoaded = true
    	end
    end
    
    function Script:CreateLabel()
    	self.healthLabel = FG_Label:Create()
    	self.healthLabel:SetPosition(Vec2(200,120))
    	self.healthLabel:SetScale(Vec2(150,50))
    	self.healthLabel:SetText("Your health")
    	self.healthLabel:SetGUIStyle(self.healthLabelStyle)
    	self.healthLabel:SetTextPosition(FG_TextPosition.Center)
    	self.healthLabel:SetDebug(false)	
    	self.guiManager:AddElement(self.healthLabel)
    end
    
    function Script:PostRender()
    	if sel.uiLoaded then
    		self.healthLabel:SetText("Your updated health")
    	end
    end

     

  6. You can load the font in the start function, and set the font in the postrender function.

    self.font = Font:Load("Fonts/arial.ttf",10)

    You can clean it up (like you already said) with something like this:

    centerTimerX = context:GetWidth() - (timerAreaWidth / 2)
    drawX = centerTimerX - (font:GetTextWidth(text)/2)

    You can also System:Print(font:GetTextWidth(text)) to see if the width of the text is actually changing. 

     

    Sorry I was thinking of a healthbar for some reason, but it doesn't matter for its purpose.

  7. Technically you would only have to recalculate the position if your health changes, but it can't hurt to do it every frame.
    Context:GetWidth will get you the width of your game window.
    GetTextWidth, will get get you the length of a text string. https://www.leadwerks.com/learn?page=API-Reference_Object_Asset_Font_GetTextWidth 

    Alternatively with FlowGui.

    Best to download the sample project and opening a sample scene with text element. From the top of my head

    • create a pivot and attach flowgui manager lua script
    • create a pivot and attach label style lua script (here you can fine tune font, text size, color, center positioning)
    • create a healtbar script (your existing script) which references the label style and flowgui manager. Add something like this:
    --Load FlowGUI if a script makes use of it.
    import "Scripts/FlowGUI/FlowGUI.lua"
    
    Script.guiManager = nil --entity "GUI manager"	
    Script.healthLabelStyle = nil --entity "HealthLabelStyle"
    Script.healthLabel = nil
    
    function Script:UpdateWorld()	
    	self.healthLabelStyle = self.healthLabelStyle.script:GetStyle()
    	self:CreateLabel()
    end
    
    function Script:CreateLabel()
    	self.healthLabel = FG_Label:Create()
    	self.healthLabel:SetPosition(Vec2(200,120))
    	self.healthLabel:SetScale(Vec2(150,50))
    	self.healthLabel:SetText("Your health")
    	self.healthLabel:SetGUIStyle(self.healthLabelStyle)
    	self.healthLabel:SetTextPosition(FG_TextPosition.Center)
    	self.healthLabel:SetDebug(false)	
    	self.guiManager:AddElement(self.healthLabel)
    end
    
    function Script:PostRender()
    	self.healthLabel:SetText("Your updated health")
    end

     

  8. One thing you can do is for every monster:

    • Get position of monster.
    • use Camera:Unproject(monsterPosition) to get the 2d coordinates of the monster's 3d position
    • Do a distance check from the monster2dCoordinates to the crossHaird2dCoordinates. 
  9. Ah I get it now. The best solution is not applying any 'move over' margin at all. Instead do the following:

    1. Lets say your health circle is 200 px wide. 
    2. Get center position of the health UI: centerUiX = ScreenWidth - (healthCircleWidth/2)
    3. Get the healthAmountWidth of the text every frame. There is a leadwerks API command for that.
    4. Subtract half of the text width from the centerUiX: drawX = centerUiX - (healthAmountWidth/2)
    5. Draw the text with drawX;

    You can also use FlowGUI (free for download at https://bitbucket.org/Aggror/flowgui/src). I don't know if the official leadwerks UI has text centering.

    1. Verify integrity of game cache
      1. Restart your computer and relaunch Steam.
      2. Head over to the library section and right click on the game which is giving you problems.
      3. Click on its properties and select the local files.
      4. Click the “Verify Integrity of Game Cache” button and Steam will verify that game in a few minutes.
    2. Latest drivers?
    3. Verify if Visual Studio redistributable is installed. This can be found in the following folder: C:\Program Files (x86)\Steam\steamapps\common\\Leadwerks\_CommonRedist
    • Access to the Leadwerks 5 alpha forum
    • Early access to demo's, tests
    • Join discussions on development
    • You are listed as supporter in the bottom of the forum
    • You get a different forum status:

    image.png.ad564b498067b512317fca99c4159e35.png

×
×
  • Create New...