Reply To: New items in mods currently impossible

Home Forums Wayward New items in mods currently impossible Reply To: New items in mods currently impossible


Since I’m on a roll here anyway, I’ll put the generic pseudo-mod code here:

If you load it at the title screen through the browser console, then you can successfully load and save the game.

Hope this helps get some mods on the road later, if the API isn’t completely different by then, that is.

Note: if we use multiple mods, then each one needs to save its own so that we can ‘unload’ each mod seperately and not have to wipe the slate clean. Probably should be a Mods object which contains mods keyed by name, each with its own items and skills, for easier loading and unloading.

InitMod = function(){
 newItems = { // All the items we'll want to add will need to be saved, at least by name, in order to unload them later
 MyNewItem:  {
   x: 0,
   y: 0,
   name: "My first item",
   weight: 0.5
  MyFirstOverpoweredSword: {
        x: 24,
        y: 0,
        name: "Totally Not A Golden Sword At All",
        weight: 3,
        durability: 1500,
        equip: "held",
        attack: 50,
        damageType: ['piercing', 'slashing'],
        use: ["carve"],
        group: ["sharpeneditem", "treasure"],
	recipe: {
            requires: [
                 ["polelike", 1, 1]
            skill: "blacksmithing",
            level: "intermediate"

 for(i in newItems){
  items[i] = newItems[i]
  items[i].id = Object.keys(items).length  // This will allow us to load MULTIPLE mods, and in a different order each time! Since the id gets assigned dynamically

WeWasNeverHere = function(){  // For deleting all 'new' items on the player, so that the save file can load normally even without the mod. Does not delete items in environment though.
  for(i in player.invItems){
   if(newItems[player.invItems[i].type]){cont=true; removeItem(i, 'INV', false); break;}