Jump to content

GorzenDev

Members
  • Posts

    141
  • Joined

  • Last visited

Posts posted by GorzenDev

  1. in theorie you could check KeyHit() for each letter you need as you suggested
    then put each letter into a string and compare that string to your cheat.
    you obviously would want to put some kind of timer/delay in between each keypress
    to make sure the typing of the cheat is done in a certain time period else discard the string.

    pseudo code:

    self.godMode = false
    self.lastPress = 0
    self.cheatstring = ""
    
    local maxPressTime = 5000 --assuming 1000 is 1 second
    
    if window:KeyHit(Key.G) then
      self.cheatstring = self.cheatstring + "g"
      self.lastPress = Time:GetCurrent()
    end
    if window:KeyHit(Key.O) then
      self.cheatstring = self.cheatstring + "o"
      self.lastPress = Time:GetCurrent()
    end
    if window:KeyHit(Key.D) then
      self.cheatstring = self.cheatstring + "d"
      self.lastPress = Time:GetCurrent()
    end
    
    if self.cheatstring.compare("god") then
      self.godMode = true;
    end
    
    local pressCheck = Time:Getcurrent() - self.lastPress
    if pressCheck > maxPressTime then
      self.cheatstring = ""
      self.lastPress = 0;
    end

     

    • Like 2
  2. 38 minutes ago, Core said:

    Thank you again for your help, @GorzenDev, I just got working the first iteration of the interface. This was a big milestone for me! I might never have looked Josh's chat example without your tip.

    One question arised though. How can I make/add own modified widgets or load modified script file to default ones? Now I just modified the stock ones (made backups).


    you would need to have the widget point to your script. 

    Widget:Create("text", x, y, w, h, parent, "scriptfile");

    that would create a custom widget with your own behaviour.
    change values in your script with:

    widget:SetBool("variableName", false)
    widget:GetBool("variableName")
    
    widget:SetFloat("variableName", 0.0)
    widget:GetFloat("variableName")
    
    widget:SetString("variableName", "value")
    widget:GetString("variableName")

    there are more Get/Set functions in the documentation:
    https://www.leadwerks.com/learn?page=API-Reference_Object_Widget_Create
     

    alternatively you could do:

    newbutton = Widget:Button("button",10,10,300,20, gui:GetBase())
    newbutton:SetSript("Scripts/GUI/customButton.lua")

     

    • Thanks 1
    • Upvote 1
  3. whenevver i try to download an attachment people released from blogs i get this error..

    Sorry, there is a problem
    The page you are trying to access is not available for your account.
    Error code: 2C171/1

    whats wrong with my account ?
    i have the professional edition of leadwerks.

  4. 51 minutes ago, randomdude said:

    I actually have no problem, I wanted a map as a background so that I dont have to use MS Paint skills. =D

    
    --if gamemenu:Hidden() then
    		
    		--Update the app timing
    		Time:Update()
    		
    		--Update the world
    		world:Update()
    		
    	--end

    I put both commands into the gamemenu:show function it has the same effect as the pause.time command commented out.

    gui:GetBase():SetObject("backgroundcolor",Vec4(0,0,0,0))  This thing here is like a layer that lies above the actual map. but even if would work, I think thats what einlander says, it is affecting all menus so if it wouldnt stop the startmenu map it will not stop the playing maps as well what is not such a good idea. So either I need to code a only startmenu menu. or I have a broken game. so I leave it and take the "screenshot" version. I have full colours so thats fine. I could make it map look like I did this stop on purpose what looks cool than. Anyway thank you guys.

    just a suggestion.
    you could always add a check to your menu for checking if the menu is in starting positon or no game loaded/started.

    pseudo code would be:

    --Main.lua
    
      if gamemenu:Hidden() or gamemenu:IsStart() then
        --if gamemenu:Hidden() then
    
        --Update the app timing
        Time:Update()
    
        --Update the world
        world:Update()
    
      end
    --Menu.lua
    
        local GameMenu={}
        GameMenu.startscreen = true --default to true
    
        function GameMenu:IsStart()
            return self.startscreen
        end
    
        function GameMenu:ProcessEvent(event)
            if event.source == self.newbutton then
                if self.newbutton:GetText()=="NEW GAME" then
                    if Map:Load("Maps/start.map") then
                        prevmapname = "start"
                        self.newbutton:SetText("RESUME GAME")
                        --disable startscreen when a map is loaded
                        self.startscreen = false
                    end
                end
            end
        end

     

  5. 10 hours ago, randomdude said:

    Hey man,

    the forumupdate delete my old post. I think this function here is the reason.

    gui:GetBase():SetObject("backgroundcolor",Vec4(0,0,0,0))

    If commented out the screen turns grey. so if we could manipulate the size of it, it should work. Time pause is only called once in the script, if commented out you hear sound. but this other function is over it so you still have a "screenshot".

    gui:GetBase():SetObject("backgroundcolor",Vec4(0,0,0,0))
    all this does is set the backgroundcolor for the baseWidget to transparant i dont see why this would be any problem to be honest.

    im not sure but it almost sounds like you only see 1 frame and the context doesnt clear the previous frame.
    i must admit it sometimes is hard to understand what exactly is your problem.

    ------

    after reading through a unedited Main.lua
    could this be giving you problems ?

    	if gamemenu:Hidden() then
    		
    		--Update the app timing
    		Time:Update()
    		
    		--Update the world
    		world:Update()
    		
    	end

     

  6. On 8-9-2017 at 10:20 AM, randomdude said:

    Good news, I thought I try it anyway and it is working.

    Main.lua

    
    -Create a world
    world=World:Create()
    
    Map:Load("Maps/Start.map")
    
    local font = Font:Load("Fonts/Arial.ttf",10)
    context:SetFont(font)

    and Menu.lua

    
    elseif event.source == self.newbutton then
    				if self.newbutton:GetText()=="NEW GAME" then
    					world:Clear()
    					if Map:Load("Maps/NMLVL01.map") then

    Okay so but how do I get rid of the Time pause in the start menu? so that the map is played?

    if i understand you correctly you want NO PAUSE when in mainmenu and PAUSE when a level is loaded?

    honestly you would need to edit the Menu.lua quite heavily.
    since the vanilla Menu.lua pauses the Time whenever it Shows (escape key pressed).
    you would have to do a check on Show if a New Game is not started you would not use Time:Pause()
    else if a New Game is started you would want to use Time:Pause().

    to "hack" your way out of it you could use Time:Resume() and some point.

    but the best solution would still be to change your Menu.lua to support Time to play when a New Game has not started yet.

     

  7. 8 hours ago, randomdude said:

    Hello, where do I load a map as a background for the startmenu?


    i assume you want a pause menu (with map already loaded).
    just make your background transparant so you can see the world behind it.
    with SetObject("backgroundcolor",Vec4(r,g,b,a));

    otherwise i dont see any possibility to load the actual map as a background.
    you could simulate this with a simple screenshot as background.
    or maiby even with a render to texture. (not sure havent tried it)

  8. you would need to create a custom button script for that.
    just take the Button.lua from Scripts/GUI/ and create a copy and edit it.

    set the new script with either Widget::SetScript() or Widget:Create().
    for info on how to change color you could use Panel.lua as a example.
     

    • Upvote 1
  9. i am certain the client connects since the prints get done when  Message::Connect is received by the server,
    after that i succesfully send receive and respond to a clientversion check so all is well in the form of connection and communication
    its just that the address info of the peer returns empty.

    • Upvote 1
  10. i have another question about networking i hope you guys can answer.

    is there some way to get an ip or some kind of id from a connection for stuff like banning accounts etc ??

    i have been trying things like 

    
    //prints a memory address i assume
    System::Print("Address?: " + message->peer->driver->GetAddress(message->peer)); 
    //get address info from peer ?
    Address ip = message->peer->address;
    //all print empty or 0
    System::Print("Connection from: " + to_string(ip.host));
    System::Print("name: " + ip.name);
    System::Print("port: " + to_string(ip.port));

     

  11. 1 hour ago, Crazycarpet said:

    Under the hood the Leadwerks networking system is ENet, nothing more... ENet provides great flow control as-is and you really shouldn't have a "channel" for each user. You (generally) should have a channel for reliable packets, and a channel for unreliable packets which LE's networking system uses ENet to create for you already. But really the channels you have created and what they're used for will vary hugely game-to-game.

    Have a look at: http://enet.bespin.org/\

    "Features and Architecture" is a good read.

    You'll see that channels although they do not operate concurrently, will not hold up the sending/receiving of other channels if one channel is waiting or hanging on a reliable packet that hasn't arrived...

    You'd be best off reading up on ENet and the features it provides and deciding what behavior would be best for your game as depending on the style of game (FPS, RTS, etc) you'll need drastically different networking setups for optimal performance.

    Leadwerks::Server is as "smart" as an ENet host with a couple of channels (See the LE docs, one is reliable and sequenced, the other is just sequenced).

    If you're using C++, shoot me a PM and I can help you with Leadwerks networking. I have a basecode that I can share that will help you with dealing with endianness, further aggregation, and a few other gotchas that come with the use of ENet.

    thank you that whas an interesting read and it seems ENet is pretty robust on its own.
    since all the server channels are sequenced i guess i could just process all received messages whenever they are received.
    no use in me putting them in a list and process later then.

  12. 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 ?

     

  13. 3 minutes ago, Rick said:

    All instances of a model placed in the editor share the material no matter how it's set. So it doesn't matter where or how he sets the material for this model, whenever he set it's for 1 all instances will automatically change as well. The same model placed x times in the editor are setup to share the same material.

    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.

  14. 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();

     

    • Upvote 1
  15. 2 hours ago, Einlander said:

    Avoid using port 8000 and 8080, those are standard web ports. Around 20000 or so it is safe to use.

    makes sence if the port is in use the Server:Create() returns nil

  16. 18 minutes ago, Josh said:

    Your network card does not have that port?

    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 :D)

     

  17. very nice :D

    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

     

×
×
  • Create New...