I am attempting to add a R&D research item to the game without using UltimateLib. Better yet, I would like to hijack one of the in-game researches and then add to it, but even though I have successfully hijacked many other methods, I just cannot seem to hijack a R&D researchable.
Instead of making thread after thread about different coding questions I have, I’ll just add to this one.
What is the best way to make a custom Javascript/jQuery template, similar to the ones for GDT.addEvent and GDT.addResearchItem, in GDT? I tried using various libraries like Handlebars, but I’m having some trouble implementing it without errors.
I apologize for any confusion I may have engendered. When adding a research item in GDT, there is a template to follow:
> GDT.addResearchItem(
{
id: "Swift Loading",
name: "Swift loading".localize(),
v: 4,
canResearch: function (company) {
return LevelCalculator.getMissionLevel('Level Design') > 5 //The 'Level Design' level has to 6 or higher
},
category: "Level Design",
categoryDisplayName: "Level Design".localize()
});
I wish to know how to create my own template with custom “members,” which are the id, name, category, etc. UltimateLib gave the ability to add items to the R&D Lab by creating it’s own template for people to use. I would like to create my own as well.
Basically, I am just asking how to create my own template for my own function in GDT:
Well the “template” you are referring to is just you creating an object with all the properties you define in it.
After that it’s the function you pass this object to which uses this data in any way it wishes, I’m not that good at explaining things hope you kinda understand.
Here’s an example:
var Example = {};
(function () {
var itemList = [];
Example.AddCustomItem = function(item){
if(item.id == "MultiPlatformOptimized"){
//do something
}
//do something.. example:
alert("added item: " + item.name);
itemList.push(item);
}
var runCode = function(){
Example.AddCustomItem({
id : "MultiPlatformOptimized",
name : "Multi-Platform optimized",
category: "Level Design"
});
}
runCode();
}
The key thing to adding / modifying the UI is not adding the elements to the DOM it’s making them visible when you want them to be visible. For example the code now will add a new div to the body, but that div will always be there even on the startup screen ect…
You’ll need to add components that are invisible to start with something like css: display:none, after that you’ll need to hook a function that will make your div visible. For example cheatmod adds an invisible div containing the cheat menu to the body on start up. Then I hook the GDT context menu and add my cheatbutton, when that button is pressed the cheatmenu div is put to visible.
It’s far from done. Addtionally, I started with practically no JS knowledge (I have been teaching myself since the beginning), so don’t be startled by incredibly bad JS coding.
That link in the thread is also old. I have changed a lot of the code since I moved over to Atom.
So I have come across another thing that is beyond my substandard jQ and JS knowledge. I do not wish to give away what I am working, so I will try to provide a sufficient example.
Does anyone know how to implement save-specific data? Specifically, how can I save whether or not a div is shown through save-specific data. I’ve messed around with DataStore, and it just doesn’t seem to work for me.
In a mod I am creating, various divs are appended (I show/hide all the main divs). I need to make it so that a div that is appended in one save wouldn’t be available in separate save or new game.
GDT.getDataStore(“modname”).data is used to save save-specific data. However, from what I understand, you’re trying to save data which you want to recall in other saves, in which case you’re better off using GDT.getDataStore(“modname”).settings.