Jump to content

GorzenDev

Members
  • Posts

    141
  • Joined

  • Last visited

Everything 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
  2. 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")
  3. josh posted a example chat program. i think you can get your answers there if not tell me and ill show you. https://www.leadwerks.com/community/topic/16341-chat-example/ Hint: local s = interface.textbox:GetText()
  4. 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.
  5. 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
  6. 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
  7. 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.
  8. 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)
  9. the free 2015 version would be the express edition. go to: https://www.visualstudio.com/vs/visual-studio-express/ and scroll all the way down for the express editions.
  10. 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.
  11. GorzenDev

    Widget Fields

    Finished and added Field functionality meaning its now possible to set the Fields for each widget. for example the style for a button (Push,Link,Checkbox), or backgroundcolor for panels etc. below is a screenshot of the fields in action Next will be finishing support for custom widgets which i already started on as you can see in the screenshot above(colorlabel). At the moment the way to add your custom widgets is a 3 step process. First step is adding the widget name to the config.ini like [DefineTypes] CustomTypeCount=2 name_0=ColorLabel name_1=MultiListView Next is adding a type_file with content like so [Base] name=ColorLabel ;allow other widgets to use this as a parent allowparent=false ;allow addItem islistType=false ;location of the widget script in your leadwerks project - only used while exporting wScript=Scripts/GUI/ColorLabel.lua ;location of the widget script for this editor eScript=ElementTypes/Custom/Editor/editorColorLabel.lua ;default size defWidth=80 defHeight=20 ;amount of 'extras' defined dCount=6 [Define_0] name=align type=String [Define_1] name=valign type=String [Define_2] name=wordwrap type=Bool [Define_3] name=border type=Bool [Define_4] name=bordercolor type=Vec4 [Define_5] name=textcolor type=Vec4 And last but not least you need to edit a copy of your script and disable any EventQueue::Emit events, and add some mouseMove,mousDown,mouseUp events for the editor to interact with the widget. So a custom widget colorlabel would look like this when exported. //GUI Editor Generated #include "MenuClass.h" MenuClass::MenuClass(Context* context) { gui = GUI::Create(context); //Panel Panel = Widget::Create("", 0, 0, 1024, 100, gui->GetBase(), "Scripts/GUI/Panel.lua"); Panel->SetAlignment(false, false, false, false); //Button Button = Widget::Create("Template", 81, 38, 150, 20, Panel, "Scripts/GUI/Button.lua"); Button->SetAlignment(false, false, false, false); //Button1 Button1 = Widget::Create("Template", 338, 38, 150, 20, Panel, "Scripts/GUI/Button.lua"); Button1->SetAlignment(false, false, false, false); //ColorLabel ColorLabel = Widget::Create("colorlabel", 710, 39, 80, 20, Panel, "Scripts/GUI/ColorLabel.lua"); ColorLabel->SetAlignment(false, false, false, false); ColorLabel->SetString("align","Center"); ColorLabel->SetString("valign","Center"); ColorLabel->SetBool("border",true); ColorLabel->SetObject("bordercolor", new Vec3(1,0,0,0)); ColorLabel->SetObject("textcolor", new Vec3(0,0,1,1)); //Panel1 Panel1 = Widget::Create("", 342, 328, 300, 200, gui->GetBase(), "Scripts/GUI/Panel.lua"); Panel1->SetAlignment(false, false, false, false); Panel1->SetObject("backgroundcolor", new Vec3(0.2,0.2,0.2,1)); //Button2 Button2 = Widget::Create("exit", 80, 156, 150, 20, Panel1, "Scripts/GUI/Button.lua"); Button2->SetAlignment(false, false, false, false); //Button3 Button3 = Widget::Create("options", 77, 98, 150, 20, Panel1, "Scripts/GUI/Button.lua"); Button3->SetAlignment(false, false, false, false); //Button4 Button4 = Widget::Create("load", 76, 33, 150, 20, Panel1, "Scripts/GUI/Button.lua"); Button4->SetAlignment(false, false, false, false); } MenuClass::~MenuClass() { Button4->Release(); Button3->Release(); Button2->Release(); Panel1->Release(); ColorLabel->Release(); Button1->Release(); Button->Release(); Panel->Release(); gui->Release(); } // bool MenuClass::ProcessEvent(Event event) { if (event.id == Event::WidgetAction) { // } return true; } // bool MenuClass::Update() { return true; }
  12. finished basic exporting to lua or c++ code. the screenshot below results in the following files based on ExportType. Menu.lua --GUI Editor Generated function BuildMenu(context) local Menu = {} local scale = 1 --GUI local gui = GUI:Create(context) gui : SetScale(scale) Menu.gui=gui Menu.context=context --Panel Menu.Panel = Widget:Create("", 0, 0, 1024, 80, gui:GetBase(), "Scripts/GUI/Panel.lua") Menu.Panel:SetAlignment(true, true, true, false) --Button Menu.Button = Widget:Create("Template", 104, 32, 150, 20, Panel, "Scripts/GUI/Button.lua") Menu.Button:SetAlignment(false, false, false, false) --Button1 Menu.Button1 = Widget:Create("Template", 409, 33, 150, 20, Panel, "Scripts/GUI/Button.lua") Menu.Button1:SetAlignment(false, false, false, false) --Button2 Menu.Button2 = Widget:Create("Template", 782, 34, 150, 20, Panel, "Scripts/GUI/Button.lua") Menu.Button2:SetAlignment(false, false, false, false) --MenuPanel Menu.MenuPanel = Widget:Create("", 250, 249, 500, 300, gui:GetBase(), "Scripts/GUI/Panel.lua") Menu.MenuPanel:SetAlignment(true, true, true, true) --Button3 Menu.Button3 = Widget:Create("Start", 172, 52, 150, 20, MenuPanel, "Scripts/GUI/Button.lua") Menu.Button3:SetAlignment(false, false, false, false) --Button4 Menu.Button4 = Widget:Create("Exit", 167, 238, 150, 20, MenuPanel, "Scripts/GUI/Button.lua") Menu.Button4:SetAlignment(false, false, false, false) --Button5 Menu.Button5 = Widget:Create("Options", 168, 145, 150, 20, MenuPanel, "Scripts/GUI/Button.lua") Menu.Button5:SetAlignment(false, false, false, false) --Button6 Menu.Button6 = Widget:Create("adwadwdaw", 169, 98, 150, 20, MenuPanel, "Scripts/GUI/Button.lua") Menu.Button6:SetAlignment(false, false, false, false) -- function Menu:Show() self.gui:Show() end -- function Menu:Hidden() return self.gui:Hidden() end -- function Menu:Hide() return self.gui:Hide() end -- function Menu:ProcessEvent(event) if event.id == Event.WindowSize then -- elseif event.id == Event.WidgetAction -- end end -- return Menu end Menu.h //GUI Editor Generated #pragma once #include "Leadwerks.h" using namespace Leadwerks; class MenuClass { public: GUI* gui; // Widget* Panel; Widget* Button; Widget* Button1; Widget* Button2; Widget* MenuPanel; Widget* Button3; Widget* Button4; Widget* Button5; Widget* Button6; // MenuClass(); ~MenuClass(); // bool ProcessEvent(Event event); bool Update(); }; Menu.cpp //GUI Editor Generated #include "MenuClass.h" MenuClass::MenuClass(Context* context) { gui = GUI::Create(context) //Panel Panel = Widget::Create("", 0, 0, 1024, 80, gui->GetBase(), "Scripts/GUI/Panel.lua") Panel->SetAlignment(true, true, true, false) //Button Button = Widget::Create("Template", 104, 32, 150, 20, Panel, "Scripts/GUI/Button.lua") Button->SetAlignment(false, false, false, false) //Button1 Button1 = Widget::Create("Template", 409, 33, 150, 20, Panel, "Scripts/GUI/Button.lua") Button1->SetAlignment(false, false, false, false) //Button2 Button2 = Widget::Create("Template", 782, 34, 150, 20, Panel, "Scripts/GUI/Button.lua") Button2->SetAlignment(false, false, false, false) //MenuPanel MenuPanel = Widget::Create("", 250, 249, 500, 300, gui->GetBase(), "Scripts/GUI/Panel.lua") MenuPanel->SetAlignment(true, true, true, true) //Button3 Button3 = Widget::Create("Start", 172, 52, 150, 20, MenuPanel, "Scripts/GUI/Button.lua") Button3->SetAlignment(false, false, false, false) //Button4 Button4 = Widget::Create("Exit", 167, 238, 150, 20, MenuPanel, "Scripts/GUI/Button.lua") Button4->SetAlignment(false, false, false, false) //Button5 Button5 = Widget::Create("Options", 168, 145, 150, 20, MenuPanel, "Scripts/GUI/Button.lua") Button5->SetAlignment(false, false, false, false) //Button6 Button6 = Widget::Create("adwadwdaw", 169, 98, 150, 20, MenuPanel, "Scripts/GUI/Button.lua") Button6->SetAlignment(false, false, false, false) } MenuClass::~MenuClass() { Button6->Release(); Button5->Release(); Button4->Release(); Button3->Release(); MenuPanel->Release(); Button2->Release(); Button1->Release(); Button->Release(); Panel->Release(); gui->Release(); } // bool MenuClass::ProcessEvent(Event event) { if (event.id == Event::WidgetAction) { // } return true; } // bool MenuClass::Update() { return true; } next step will be adding stuff like Widget->SetString(), Widget->SetBool(), Widget->SetObject() and list type Widgets. after that i will be adding support for custom widgets.
  13. added loading and saving of current project for easy access to changes.
  14. have you tried context:Clear() ? undocumented somehow... at the start of your loop. context:Clear() in your case lienzo:Clear()
  15. 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.
  16. 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));
  17. 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.
  18. 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 ?
  19. 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.
  20. 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.
  21. move certain variable declarations inside the start() function. since declaring Script.variablename will make them shared across all instances of the script.
  22. tried that but yields same result. tried not deleting/releasing at all yields same result but on the parent Panel of the widget.
  23. 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();
  24. makes sence if the port is in use the Server:Create() returns nil
×
×
  • Create New...