- This topic has 1 reply, 2 voices, and was last updated 9 years, 8 months ago by Vaughn “Drathy” Royko.
-
AuthorPosts
-
April 8, 2015 at 4:29 pm #5382AnonymousInactive
In its current state, Wayward is not suitable for modding – everything is beautifully hand-stitched together, and so there’s no room for ‘outside sources’ since everything is within the javascript itself.
That’s not to say it’s impossible – it’s all JS annyway – but in order to mod this piece of art, one needs to have a THOROUGH knowledge of javascript, and to go over hundreds of line of core project code. That’s not very modder friendly.
And so I present a (currently skimpy) base mod, in order to help enable future modders to do their stuff with less of the grittiness associated.
For now, we have the creation of items (relatively simple) and assigning them URLs to load the images from (not so simple). Since this required modding of the rendering function, it’s a longer file than I can just shove here, so link:
Modder’s modEquipment, crafting, throwing, everything works as it should, no surprises.
When you pick up an item, you get a brief overlay of a larger image, wasn’t able to figure out where that’s from but I do know it reads the x and y values of the item, so that’s something that should be dealt with as well. But it’s much less important to me now.Example of use:
newItems = { ForkOfTruth: { inventoryImageUrl: 'http://1.gravatar.com/avatar/de5e7e1f548175398920033bf4520d04', mapImageUrl: 'http://1.gravatar.com/avatar/de5e7e1f548175398920033bf4520d04?s=14&d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D14&r=G', x: 0, 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"], recipe: { requires: [ ["polelike", 1, 1] ], skill: "blacksmithing", level: "intermediate" } } } InitMod(newItems)
Those of you familiar with the current items.js will see that it’s exactly the same format, but with the addition of the inventoryImageUrl and the mapImageUrl properties, the second of which was a real pain to do.
Hope this gets people up and running! Any mishmash of current items (except for uniques like the raft) is possible! Should get complex crafting trees up and running easily.
However, this is limited to inventory items, and does not take into account environment items like the walls and such. That’s the next thing to do =)
After that’s done, I hope to get my crafting table up and running, with personalized crappy graphics to boot – this is a very specific modding, however, and so it won’t go into the base mod..
All the REALLY cool stuff, like the growing and such, is hardcoded and therefore not really available for easy modding… but everything’s generalizable with enough effort 😉
Note that while everything will work during the first playthrough, if you want to do this in multiple playthroughs then you will need to load the code through the browser’s command line (f12 – console for most browsers) BEFORE you click ‘load game’, otherwise the game won’t recognize the new items and won’t load.
If you want to revert the game to a non-modded state, I’ve provided the WeWasNeverHere function to delete all the ‘new’ items in your inventory – simply run WeWasNeverHere().
Hope to see this game grow! ^_^
April 13, 2015 at 1:20 pm #5384Vaughn “Drathy” RoykoKeymasterReally cool work here. I hate to say it, but your hard work here won’t be transferable over to 2.0. The good news though, is that what you want to do should be available without all the hardship.
Spacetech, one of our programmers has spent a couple days working directly with modding and has implemented an API for Wayward mods with all the hooks you would need to customize most portions of the game. It won’t be 100%, but we hope to continually work on getting everything easy to mod. Here’s an example of a new item mod:
class ArgusMod extends Mods.BaseMod implements Mods.IMod { public getName(): string { return "Argus"; } public getVersion(): string { return "1.0.0"; } public getCompatibleMinorVersions(): number[] { return [0]; } public getReleaseDate(): string { return "4/11/2015"; } public getAuthor(): string { return "Spacetech"; } public getDescription(): string { return "Adds a new item called Argus into the game"; } public getHooks(): Mods.Hook[] { return null; } public onLoad(): void { this.addItem({ tX: 33, tY: 1, description: "The all seeing eye.", name: "Argus", weight: 2, attack: 1, damageType: DamageType.Blunt, equip: EquipType.Held, onEquip: this.onEquip, onUnequip: this.onUnequip, recipe: { requires: [ [ObjectType.SharpenedItem, 1, 0], [ObjectType.Lens, 2, 2, 2], [ObjectType.Log, 1, 1, 1], [ObjectType.String, 1, 1, 1] ], skill: SkillType.Tinkering, level: RecipeLevel.Advanced }, disassemble: true, durability: 500 }); } public onUnload(): void { } public onEquip(invId: number, item: IItem) { game.fov.disabled = true; game.fov.compute(); game.updateGame(); } public onUnequip(invId: number, item: IItem) { game.fov.disabled = false; game.fov.compute(); game.updateGame(); } }
-
AuthorPosts
- You must be logged in to reply to this topic.