[MOD] Miner mod

Hi…

Features:

Add a new jobs: miner.

Add a miner_outfit and Miner’s cap.

Miner’s pick carft of mason(?).

Add torch and torch light.(fire effect)
Add wooden_frame wooden_carrage.

[Only allow miners mining (you think should cancel this?)]

Miner’s cap have light effect!(night)
Future Features:

Add some ore.

Whatever takes YOUR fancy. So let me know what you would like to see in the game and I’ll see what I can do!

Tell me your idea, but I don’t know “Lua”, I need your help.

Miner mod version 1.1(2015.2.15)
downlinks: here

8 Likes

nice outfit, maybe too modern for the setings of stonehearth, but i like the idea. what ore did you add?

2 Likes

Outfit is indeed very modern, ha ha. I think I’ll join the “sand” and “stone”, although they are temporarily useless, “sand” may be used to synthesize the “glass”. :stuck_out_tongue_closed_eyes:

@law Good Work, :slight_smile: Glad to see another modder.

Edit :
@law please ignore this, while it’s a good tutorial for adding other classes that don’t exist, it is not needed for your miner :wink: . It came down to another mod that was causing the errors, sorry for any confusion :wink:

I was unable to promote a worker to the miner during my testing, this I believe this has to do with the fact you haven’t made your miner entity visible to the game, and haven’t mixedinto the jobs index.

You’ve aliased out the miners equipment and such but not the miner himself, you will need to add an alias to your manifest.json

"aliases" : {
    "jobs:miner" : "file(jobs/miner"),

Then in /miner/jobs/miner/miner_description.json change

"alias": "stonehearth:jobs:miner",

to

"alias": "miner:jobs:miner",

Next take a look at /stonehearth/jobs/index.json, it’s a listing of all professions in the game, you need to mixin your miners alias into that list. I am guessing I don’t need to explain this as you’ve done the carpenter recipe mixins and such

Finally comes the tricky part to all of this, the promotion screen. As of now the promotion screen has hard coded positions for all the icons you use to promote citizens to professions. Your profession doesn’t exist in the list so it will error when trying to find the position for your miner icon. You have a few options here.

  1. override /stonehearth/ui/game/promotion_tree/promotion_tree.js, and edit

     self._layout = {
       'stonehearth:jobs:worker' : {x: 372 , y: 244},
       'stonehearth:jobs:carpenter' : {x: 542 , y: 159},
       'stonehearth:jobs:mason' : {x: 542 , y: 244},
       'stonehearth:jobs:blacksmith' : {x: 542 , y: 329},
       'stonehearth:jobs:weaponsmith' : {x: 542 , y: 414},
       ....
       'miner:jobs:miner', : {x:542 , y:265},
    

    Play around with x,y values to get it into the right position.
    While doing things this way might be easy, it will lead to compatibility problems with other mods that are adding classes.

  2. Use Jelly. Jelly does the base game modfications to allow for multiple mods to add professions to the game.Download here. you’ll have to rename the download to just, jelly. It’s a SH mod so put it in your mods folder. You will also have to extract it out of the .zip, SH will not load .zip.

    If you choose to go this route, you will need to add a .js file to your mod. Add this to that file…

     $(top).on('jelly.PromotionTreeLayout', function (e, layout) {
       layout['mymod:jobs:myclass'] = {
    	    x:375, y: 500
       };
     });
    

    Change mymod:jobs:myclass to alias your miner.

    Jelly creates an event 'jelly.PromotionTreeLayout. The idea here is listen in on the event, then modify _layout to include a definition for your profession.

    Last step here would be to reference the .js in your manifest.

     "ui" : {
          "js" : [
             "file(ui/add_to_promotion_tree.js)"
        ]
     }
    

This might be a bit much to understand, let me know if you need further explanations.
Again great work… :slight_smile:

5 Likes

miner do exists in stonehearth jobs

1 Like

You know that didn’t even come to mind lol… :wink:

So this got me thinking… it should work then… why doesn’t it work for me. Turned out I had another mod that was causing all the trouble.

So just to be clear @law your mod seems to work just fine as it is. In the future before I test out someone else’s mod I’ll remove other mods in my mods folder.

Thanks @flpsantoss for pointing this out :slight_smile:

Oh my God, what a paragraph, I will have finished reading, I will revise, thank you for your advice. (my mod in game test, it seems no problem?)

@honestabelink look here!As you said, I mean, modified, but wrong, I do not know where the mistake, can you help me?(“qb”change“zip”)miner.qb (127.7 KB)

I would say make all workers be able to mine, just make them mine slower.

Hi @law,

There has been a few changes to StoneHearth… and there were a few errors in your mod.

In particular the errors in your mod, you removed stonehearth:jobs:miner from the promotion tree, while adding yours to the .js would make yours show up, the game was still looking for the normal miner, not finding it the game errored.

There has also been some recent changes to StoneHearth’s job_component. Which changes the way (job)_description.json’s are written.

Basically we used to declare job abilities under the equipment key… they are now declared in there own.

in your miner_description.json

 "equipment" : {
      "abilities" : "file(miner_abilities)",
      "torso" : "file(miner_outfit)",
      "mainhand" : [
	     "stonehearth:mining_pick"
      ]
 },

changes to

"abilities" : "file(miner_abilities)",

"equipment" : {
      "torso" : "file(miner_outfit)",
      "mainhand" : [
         "stonehearth:mining_pick"
      ]
   },

This was also true with your override to worker_description.json.

I had to do testing anyway to make sure it worked… here’s my files. Continue to work off them or use them as a reference :wink:

Main differences in my mod to yours

  • I followed @flpsantoss advice and just overroad the default miner. (this avoids the promotion_tree nonsense :slight_smile: , this was also what you were initially doing, sorry for any confusion)
  • I removed the copies of the workers models and such, instead just referenced them from the mod.

https://drive.google.com/file/d/0BynmPA83eY4PMkdaN0dOdG82R2M/view?usp=sharing

Good luck with your mod :wink:

2 Likes