Jump to content

Hoze

Community Members
  • Posts

    11
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Hoze's Achievements

Discens

Discens (2/14)

7

Reputation

  1. I believe DoctorOrgans is already muted in lobby, if we don't want to play with him, we shouldn't/don't have to. The current moderation for this player seems adequate.
  2. I think I have better understanding now (after ~15hours of debugging ). In CounterManager.js, the onPress method must be defined to handle onPress events. The event seems to be triggered even prior to any GUI interactions after the game loads because it prints uninformative errors all over when onPress is not defined. The onPress mehtod from CounterManager.js overwrites the one I would define in CounterResources.js I try to make the resource icon / counter a button that would make a simple chat message: Engine.SendNetworkChat("I have " + this.count + " of " + this.resCode + "!"); I tried to bind variables resCode and count in various ways. I tried to make a renamed method in CounterResource like: class CounterResource { constructor(resCode, panel, icon, count, stats) { //... this.onResourcePress = this.onResourcePress.bind(this); } onResourcePress() { Engine.SendNetworkChat("I have " + this.count + " of " + this.resCode + "!"); } } For it to be callable in the CounterManager: class CounterManager { constructor(playerViewControl) { //... this.counters = []; //... for (let resCode of g_ResourceData.GetCodes()) { let counter = this.addCounter(resCode, CounterResource); counter.onPress = counter.onResourcePress.bind(counter); } //... } //... onPress(counter) { counter.onResourcePress(); } } I don't know how much syntaxes I've tried... I feel like sorry I can't make this seemingly simple thing to work. If you have any clues of what I'm missing, please tell me!
  3. Hello! I tried to make a simple addition to the interface where by clicking a resource on the top panel, it will send a message to notify allies how much of this particular resource you have. The idea is that in multiplayer games, you like to ask for resource you need and offer the ones you have a lot of. Sounded simple and in my reach . Little did I know how little I know... I first tried the simplest thing, I added an attribut to the object tag in \gui\session\top_panel\Counters.xml onPress="Engine.SendNetworkChat(resource[n])" But just adding the "onPress" attribut here seems to break everything; the top panel, and other unrelated things like music. Next I looked into CounterManager.js to add to the existing onPress method of the class, but the class doesn't provide a way to identify the exact ressource I'm clicking on. Last CounterResource.js seemed more promising as "rescode" that provide the names in a string ("food"..) is defined in the constructor. But here, I can't make an onPress method that would work just by naming it. I was just trying to do just this : onPress() { Engine.SendNetworkChat("I have " + this.count + " of " this.resCode + "!"); } Any ideas of what am I missing, please?
  4. Is there any mods playing around with the quick group feature? I'm having hard time finding what files make it work/displayed. If you feel like you have any tip to get me started, it can help! I will try to make a variant of it duplicated on right, to help with building controls. How could I go about it? --Off-- I love tactics and town-building strategies! I'm trying modding enhanced unit controls for tactical moves on GUI. Maybe an overlay for managing building productions could be fun, even if it means less screen space.
  5. Wow thanks @nani! I had the list of files to modify right, as they are listed in the modding guide. But I wasn't realizing the original selection_panel.js would still be executed! I was taking the therm "overwrite the file" literally, when actually you are just redefining the the stuff in it. This was causing me to not understand the errors popping up. Now I can get it to work thanks to you, and it's fun! Thanks you so much! I'm grateful 0AD is that good of a game and project.
  6. If I overwrite the whole file, is this expected to cause issues? 1. If I overwrite the whole file (with a unmodified copy of itself for simplicity) I get errors: "redeclaration of 'let g_panelsOrder'." In short I'm doing just that: putting the "selection_panels.js" unmodified into /MyMod/gui/session/ So It must be something about it I'm missing... 2. If I remove the declaration of 'let g_PanelsOrder' as only modification in "selection_panels.js" I get new js errors, of undeclared methods, such as: "getRequirementsTooltip is not defined" I'm just trying to add a new button on the game's alert panel, and I feel stuck on it! I haven't found any mods that do something similar that I can check on. The modding guide has an exemple where a ressource is added to the Batter Panel, but following it didn't help me understand what am I doing wrong above.
  7. Thanks! I did try to put the file in my mod folder: /MyMod/gui/session/selection_panels.js Like it is in the public folder of the game: /public/gui/session/selection_panels.js But I was getting js errors (the file selection_panels.js HASN'T been edited yet from the source, and the error won't occur when I remove the file again) ERROR: Error calling component script function ScriptCall ERROR: Errors executing script event "SimulationUpdate" ERROR: JavaScript error: gui/session/selection_panels.js line 1051 getRequirementsTooltip is not defined setupButton@gui/session/selection_panels.js:1051:1 setupUnitPanel@gui/session/unit_commands.js:94:35 updateUnitCommands@gui/session/unit_commands.js:152:18 updateSelectionDetails@gui/session/selection_details.js:537:20 updateGUIObjects@gui/session/session.js:730:2 onSimulationUpdate@gui/session/session.js:680:2 __eventhandler54 (SimulationUpdate)@session SimulationUpdate:1:1 So my guess was that I still have to do something special because it's a file in /public?
  8. Hi! The modding guide explains that public components can be changed by re-defining it's functions in the prototype global objects. ModdingGuiAndSimulation Autociv is a mod that seems to modify public components, but it isn't clear for me what it's doing. I couldn't find the matching functions, in the game's public components, that Autociv is redefining. I hoped to learn from an example as my attempts with the syntax gathered no useful informations. I try to mod g_SelectionPanels.Alert mods/public/gui/session/selection_panels.js that starts like this: // Cache some formation info // Available formations per player var g_AvailableFormations = new Map(); var g_FormationsInfo = new Map(); var g_SelectionPanels = {}; var g_SelectionPanelBarterButtonManager; g_SelectionPanels.Alert = { "getMaxNumberOfItems": function() { return 2; }, [...] How should I go about it?
  9. Thanks to your explanations, I had fun modding components! Juste in case, for archives, I wanted to customize the Alert system to filter out or in specific buildings, I could modify the component: simulation/components/AlertRaiser.js let holder = cmpRangeManager.ExecuteQuery(unit, 0, +this.template.SearchRange, mutualAllies, IID_GarrisonHolder, true).find(ent => { const classes = Engine.QueryInterface(ent, IID_Identity).GetClassesList(); //Filter only buildings from a class if (classes.indexOf("House") === -1) return false; [Other conditions...] let cmpGarrisonHolder = Engine.QueryInterface(ent, IID_GarrisonHolder); if (!reserved.has(ent)) reserved.set(ent, cmpGarrisonHolder.GetCapacity() - cmpGarrisonHolder.OccupiedSlots()); return cmpGarrisonHolder.IsAllowedToGarrison(unit) && reserved.get(ent) >= size; });
  10. Thanks Stan for your detailed reply. And since I have the opportunity, thanks for your work on 0ad! So many compliments to say about the game! You hinted me in the right direction. It doesn't work as is, and I can't figure out where I should look for details on the methods like: engine.GetClassesList(); Where can I find the code where they are defined and how does one usually get the list of methods available? I may have missed something obvious in the documentation, if so, sorry, I'm clueless.
  11. Hello, I'd like to make a condition that checks if a unit is a specific building. From looking into source code and previous issues, I guess I'm trying to do somthing like this: for (let unit of units){ let house = Engine.QueryInterface(unit, IID_TemplateManager); if (house.type() != "template_structure_civic_house") continue; } But I have very limited understanding of the code structure. How should I re-write the above? And where can I learn about Engine.QueryInterface?
×
×
  • Create New...