Jump to content

GorzenDev

Members
  • Posts

    141
  • Joined

  • Last visited

Posts posted by GorzenDev

  1. 2 minutes ago, Josh said:

    Awesome!  Using a script for each widget was a great idea, if I do say so myself, because it allows for unlimited customization like this.

    i agree and love it , the only wall i had to work around whas not being able to use  "CallFunction()" in lua and GetScript() doesnt return the script table.

    so currently the animationlogic is outside of the widget script which i love to have inside the script or some kind of Script:Update() function could also work (havent tried that yet to be honest)

    other then that i dont see any restrictions holding me back for now.

  2. 5 minutes ago, Core said:

    Thank you very much for seeing all that trouble to explain, I appreciate it. Sometimes I can be thick headed :), but I think I got it, going to fiddle with the menu this evening!

    dont forget to look at the documentation for Widget.

    it helps understanding whats available for adding and what to use for get/set script variables.

    good luck and have fun messing with it i like the GUI system it is very flexible and fast .

    • Upvote 1
  3. 3 hours ago, Core said:

    Ah, ok. But how would you add button or panel normally, never done that and I didn't find tutorials. Adding Pivot to the scene and script to that pivot? Do I have to add pivot for every button/panel I want to add to the menu? Like I said, I'm noob... I would love to get away with just editing current menu to my needs to keep everything menu-related as simple as possible.

     

    Edit. Yup, will post screenshot when I get this figured out! It is somewhat important step for me mentally. And thank you so much for the help so far!

    adding elements to the current menu doesnt involve pivots.
    i am still figuring it all out but i can try to explain what i learned so far.

    so lets start with saying Menu.lua is basicly just a function which creates/returns a table.

    function BuildMenu(context)
    
    	local GameMenu={}
    	local scale = 1

    in this function we create a gui for the menu to hold the elements.

    	--GUI
    	local gui = GUI:Create(context)
    	gui:Hide()
    	gui:SetScale(scale)
    	local widget
    	
    	gui:GetBase():SetScript("Scripts/GUI/Panel.lua")
    	gui:GetBase():SetObject("backgroundcolor",Vec4(0,0,0,0.5))
    
    	GameMenu.gui=gui
    	GameMenu.context = context

    then we create menu elements (in this case 3 buttons)

    	--Create a link button for new game
    	GameMenu.newbutton = Widget:Button("NEW GAME",100,gui:GetBase():GetSize().y/2-60,300,20,gui:GetBase())
    	GameMenu.newbutton:SetString("style","Link")
    	GameMenu.newbutton:SetAlignment(1,0,0,0)
    
    	--Create a push button for options
    	GameMenu.options = Widget:Button("OPTIONS",100,gui:GetBase():GetSize().y/2-10,300,20,gui:GetBase())
    	GameMenu.options:SetString("style","Push")
    	GameMenu.options:SetAlignment(1,0,0,0)
    
    	--Create a push button for Quit
    	GameMenu.quit = Widget:Button("QUIT",100,gui:GetBase():GetSize().y/2+40,300,20,gui:GetBase())
    	GameMenu.quit:SetString("style","Push")
    	GameMenu.quit:SetAlignment(1,0,0,0)

    after we added the elements we need , we could scroll down to the function GameMenu:ProcessEvent(event) 

    in that function there are some events WindowSize,WidgetSelect and WidgetAction

    in this case we just need the elseif event.id == Event.WidgetAction code block

    create your button logics here  (for easier reading i left only the 3 buttons we are using as example in this code block)

    elseif event.id == Event.WidgetAction then
    			--Options Button Logic
    			if event.source == self.options then
    				self:GetSettings()
    				self.tabber:SelectItem(0)
    				self:ProcessEvent(Event(Event.WidgetAction,self.tabber,0))
    				self.newbutton:Disable()
    				self.options:Disable()
    				self.quit:Disable()
    				self.optionspanel:Show()
    			
    			--New/Resume Game Button Logic
    			elseif event.source == self.newbutton then
    				if self.newbutton:GetText()=="NEW GAME" then
    					if Map:Load("Maps/WorkSpace.map") then
    						prevmapname = "WorkSpace"
    						
    						--Send analytics event
    						Analytics:SendProgressEvent("Start",prevmapname)
    						
    						self.newbutton:SetText("RESUME GAME")
    					end
    				end
    				self.gui:Hide()
    				--self.context:GetWindow():HideMouse()
    				self.context:GetWindow():FlushMouse()
    				self.context:GetWindow():FlushKeys()
    				self.context:GetWindow():SetMousePosition(self.context:GetWidth()/2,self.context:GetHeight()/2)
    				Time:Resume()
    				
    			--Quit Button Logic
    			elseif event.source == self.quit then
    				self.newbutton:Disable()
    				self.options:Disable()
    				self.quit:Disable()
    				self.confirmquitpanel:Show()
    
    			end
    		end

    and the function that will make it all tick will be the update function
     

    	function GameMenu:Update()
    		--show/hide menu logic
    		if context:GetWindow():KeyHit(Key.Escape) then
    			if self.optionspanel:Hidden() then
    				if self.newbutton:GetText()=="NEW GAME" then
    					self:ProcessEvent(Event(Event.WidgetAction,self.quit))
    				else
    					if self.gui:Hidden() then
    						Time:Pause()
    						self.gui:Show()
    						self.context:GetWindow():ShowMouse()
    					else
    						self.gui:Hide()
    						self.context:GetWindow():FlushMouse()
    						self.context:GetWindow():FlushKeys()
    						--self.context:GetWindow():HideMouse()
    						self.context:GetWindow():SetMousePosition(self.context:GetWidth()/2,self.context:GetHeight()/2)
    						Time:Resume()
    					end
    				end
    			else
    				self:ProcessEvent(Event(Event.WidgetAction,self.closeoptions))
    			end
    		end
    		
    		while EventQueue:Peek() do
    			local event = EventQueue:Wait()
    			if self:ProcessEvent(event)==false then return false end
    		end
    		return true
    	end

     

    i hope this explains a bit as to how Menu.lua is build in basic ways.
    and how to add new buttons.

     

     

     

    • Thanks 2
  4. 4 hours ago, Josh said:

    Fun fact: Leadwerks GUI renders in exactly one draw call, unless something changes, and then the minimum amount of redrawing is performed to update only the section of the GUI that changed.

    can we in some way mark a section of the gui as changed to force a redraw?
    in some cases: image as button for example the control needs a mousehover at least once to draw the image correctly

  5. 30 minutes ago, Core said:

    Thanks, but both of those crashed the map right from the start! I tried them in Panel.lua inside function Script:Draw().

    for that you dont need to edit Panel.lua at all
    just add a button or panel as you would normaly.

    look at Menu.lua for example we could change the options panel if we like.

    33	optionspanel = Widget:Panel(gui:GetBase():GetClientSize().x/2-250,gui:GetBase():GetClientSize().y/2-300,500,600,gui:GetBase())
    34	optionspanel:SetAlignment(0,0,0,0)
    	--load and set out image here
    	local image = gui:LoadImage("path/to/texture.tex")
    	optionspanel:SetImage(image)
    	--
    35	GameMenu.optionspanel=optionspanel


     

  6. local image = gui:LoadImage("Path/To/Texture.tex")
    --
    local imageButton = Widget:Button("", 0, 0, 1024, 768, gui:GetBase())
    imageButton:SetString("style","Push")
    imageButton:SetImage(image)
    --
    local imagePanel = Widget:Panel(0,0,1024,768, gui:GetBase())
    imagePanel:SetImage(image)

    Result:

    leadwPrev.JPG.29bbcf5de42f3bb67288497d2c6f7fce.JPG

    this works for me.

    undocumented though

    • Like 1
    • Upvote 4
  7. I assume using the build-in water shaders and textures on a brush/model will not work like that.

     

    either use the build-in water by going to your root in the scenepanel and enable waterlayer and set height etc.

     

    or

     

    create your own shaders to work on a brush/model.

  8. to answer my own question i dont think it is possible to have suspensionless tires with the current vehicle class.

     

    my solution to this is calculate each wheels moment force then calculate the rotation and velocity of the main body.

    (this does not use the vehicle class but rather 4 individual wheels)

     

    preview of robotic body moving by individual wheel forces (WIP)

    • Upvote 1
  9. Hi with these settings i have a very stiff suspension :

    chassis:SetMass(2000)
    local tiremass=40
    suspensionDamper = 10
    suspensionSpring = 3000
    suspensionLength = 1
    lateralStiffness = 20
    longitudinalStiffness = 10000
    aligningMOmentTrail = 1.5
    friction = 1.0
    

     

    this is a lot better thank you.

     

    although this still has suspension and bounces during cornering and slopes.

    i am building a robotics game and want to attach wheels to a chassis.

    but most robotics wheels/servos do not have any kind of suspension.

  10. After playing aroud with the Vehicle:AddTire() parameters i get some weird results.

     

    Is there any way to have a tire with 0 suspension length?

     

    I have tried setting the length parameter to zero and playing with the damp and spring values.

    wich gets some weird and fun result but nothing that comes close to a suspensionless tire.

     

    Any help or tricks?

  11. first i like to say happy new year to all and i wish you a safe and productive year.

     

     

    i have a question about the pin argument of creating a joint.

     

    after playing around with joints it looks like the pin argument is in global space.

     

    how would i go about setting a joint's pin orientation based on some local rotation?

     

    for example 2 cubes binded by a hinge joint with a pin value of Vec3(1,0,0) X axis

    looks alright when both cubes are aligned with 0 rotation.

     

    but whenever i bind 2 cubes togheter with some rotation in mind the result is always global axis based?

     

    -------------------------------------

    Edit:

     

    currently i have a workaround

    which involves aligning both cubes to a global axis then bind them with the joint:hinge

    then rotate it all back to there origional state.

    the joint then rotates as if local to the parented cube.

     

    but i assume there must be a better way.?

    please help.

×
×
  • Create New...