Jump to content

GorzenDev

Members
  • Posts

    141
  • Joined

  • Last visited

Everything posted by GorzenDev

  1. i am creating a server for my game (mmo). sending/receiving packets all work fine on a single client. now i like to extend the server to accept multiple clients. i have created a class called connections which holds all the info for a single client. put a new connection in the list with peer info whenever a new succesfull connection is made with the server. i then compare message->peer against connections.peer to read the messages from each client. but now my question is what do you guys advice? should i make a send/receive list for each connection to process the messages at a certain interval (connection thread maiby) ? or is Leadwerks::Server smart enough to keep its own send/receive list ? and is this enough ?
  2. i am not saying you are wrong in anything you said. sorry i should have explained it proper in my first post. personaly i would not have created theses materials in the editor at all but rather load the texture and create a new material for every instance of the script that runs the start() function as AggrorJon points out nicely.
  3. in this case his material does to since his material is set through the editor. creating a material in the start() function will fix this like you suggested in your first post.
  4. move certain variable declarations inside the start() function. since declaring Script.variablename will make them shared across all instances of the script.
  5. tried that but yields same result. tried not deleting/releasing at all yields same result but on the parent Panel of the widget.
  6. i get a Debug Assertion Failure when closing my app in C++ debugging shows the error occurs at the destructor of my class on this line: delete logTextArea; //same result //logTextArea->Release(); logTextArea is a Widget::TextArea() the debugger tells me the Expression: list iterator not incrementable. does Widget::TextArea have a bug in his destructor ? or is this error on my part somehow? i do not use any type of list in my code myself at the moment.. ------------------------------------- Solved i figured out that when releasing/deleting a Widget::TextArea you need to clear the kids list first, even when its just a blank TextArea who is not a parent of any other widget. the code below gives no assertion failure logTextArea->kids.clear(); logTextArea->Release();
  7. makes sence if the port is in use the Server:Create() returns nil
  8. like i said my expertise in networking is limited so there is no way i can say you are wrong. but i have ran gameservers for steamgames and those are in the port ranges of 27000. anyway thanks for the help i can tinker some more now (fun fun )
  9. this did work thank you for that. could you maiby explain why ? my expertise in networking is limited
  10. very nice i am trying to recreate your example for my own purposes and get stuck at Server:Create() it always returns a nil value for me . at some point i even added a line of code like this what gave the same result if server == nil then server = Server:Create(port) end my Main.lua gives an "attempt to index local 'server' (a nil value)" error i know what this means but cant realy understand why. anybody able to help me out here ? Main.lua --Set the application title title="GameServer" -------------------------------------------------------- --Function to build user interfaca -------------------------------------------------------- function BuildServerGUI(context) local interface = {} interface.gui=GUI:Create(context) interface.root = interface.gui:GetBase() interface.root:SetScript("Scripts/GUI/Panel.lua") interface.chatlog = Widget:TextArea(4,4,interface.root:GetClientSize().x-8,interface.root:GetClientSize().y-30-8,interface.root) interface.textbox = Widget:TextField("",4,interface.root:GetClientSize().y-30,interface.root:GetClientSize().x-8-72-4,26,interface.root) interface.sendbutton = Widget:Button("Send",interface.root:GetClientSize().x-4-72,interface.root:GetClientSize().y-30,72,26,interface.root) return interface end -------------------------------------------------------- --Initialize client and server -------------------------------------------------------- local MESSAGE_CHAT=1 local peer = nil local port=8000 --local client = Client:Create() local server = Server:Create(port) --local success = client:Connect("127.0.0.1",port) -------------------------------------------------------- --Create a server window -------------------------------------------------------- serverwindow=Window:Create(title,0,0,800,600,Window.Titlebar) local serverInterface = BuildServerGUI(serverwindow) -------------------------------------------------------- --Main loop -------------------------------------------------------- while true do -------------------------------------------------------- --Exit the program -------------------------------------------------------- if serverwindow:KeyHit(Key.Escape) then return end -------------------------------------------------------- --Handle closed window -------------------------------------------------------- if serverwindow:GetHidden()==false then if serverwindow:Closed() then serverwindow:Hide() server:Disconnect(peer) end end -------------------------------------------------------- --Update server -------------------------------------------------------- while true do if server == nil then server = Server:Create(port) end local message = server:Update() <<----------Gives error on this line if message==nil then break end if message.id==Message.Connect then serverInterface.chatlog:AddText(">> New client connected.") peer = message.peer elseif message.id==Message.Disconnect then serverInterface.chatlog:AddText(">> Client disconnected.") elseif message.id==MESSAGE_CHAT then serverInterface.chatlog:AddText("Client: "..message.stream:ReadString()) end message:Release() end -------------------------------------------------------- --Handle GUI events -------------------------------------------------------- while EventQueue:Peek() do local event = EventQueue:Wait() if event.id == Event.WidgetAction then if event.source == serverInterface.sendbutton or event.source==serverInterface.textbox then local s = serverInterface.textbox:GetText() server:Send(peer,MESSAGE_CHAT,s) serverInterface.chatlog:AddText("Me: "..s) serverInterface.textbox:SetText("") serverInterface.gui:SetFocus(serverInterface.textbox) end end end end
  11. 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.
  12. this is still a work in progress and dont mind the graphics, i used whatever images i had laying about. just wanted to show that even animated elements could be created http://www.youtube.com/watch?v=4sapsnW9O1I
  13. 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 .
  14. 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.
  15. 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
  16. 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
  17. 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: this works for me. undocumented though
  18. also removing the line of code that had a breakpoint will also make the breakpoint invisible.
  19. 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.
  20. 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)
  21. thanks for the answers guys. maiby josh can elaborate on the current possibilty of the vehicle class parameters ? and if suspensionless tires are currently possible at all ?
  22. 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.
  23. 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?
×
×
  • Create New...