I need help with code

Hello everyone,

Recently i’ve decided to try to make a mod for this unholy, yet beautiful game.
Its my first mod in this game and i am not a very skilled coder,but i had an idea and a lot of coffeine to achieve my goal.

What ive done is ive taken the Mini helpers mod from the steam workshop and decided to create my a version that id enjoy more, Ive moved the crafting recipies to the engineer class and changed the recipies to what id desire, but here starts the issue.

I wanted to limit the ammount of golem, either by tagging them as “Traps” or a new tag, however this is where my limited coding ability begins.

What ive done is add:

“stonehearth:item_placement_limit”: {
“tag”: “trap”,
“default”: 0
}

to the golem.json file which does work, however once a second passes the trap counter goes down from 1/x to 0/x, which im guessing means that the “block” form of the golem is a trap but the “entity” isnt.

Ive no clue how to fix this, any advice or help will be very much welcome, ty.

The iconic is the small version of the item. That is not where you want your code.

Stonehearth’s Modding Guide

Ive not modified the iconic file, ive modified the root version.

i also tried modifying the root and ghost version but that results in errors.

Tried moving the item placement limit code block around the file too but it didnt seem to change anything.

Also tried messing with the “default” parameter but that didnt do anything.

The issue stays the same, the moment it turns from the ghost version to the root version it lowers the trap counter, even though the code is in the root .json file

Hey there!

Moving it around won’t make a lot of difference because it’s just an entity JSON, it’s not really code - so it doesn’t have an order of running/reading things.
JSONs only store data that is read by actual code.

I don’t know how the mini-helpers mod works or how their golems are changed in comparison to the vanilla golems, but I could have a few guesses of why it doesn’t work.

My first guess is that the mod golems do not have the siege_weapon component on the root file. This is the component that, for golems and traps, call the functions that will read placement tags and such. So you could try adding to your golems, inside the components part of the file:

      "stonehearth:siege_weapon": {
         "max_uses": 0
      }

That could be the solution. Let me know if they already have that component, however, in which case I can think of other possibilities!

Thank you!
that solved the issue, now to create models and upload :slight_smile:
once again thank you both for help, id never even come up with the siege_weapon thing :stuck_out_tongue: