Jump to content

Simply updating an old mod (Snapping tills) Need Help!


Recommended Posts

I'm trying to include Wormwood's no-till planting seeds into the Snapping tills mod by surg.

Currently the mod works by detecting if you have a hoe in your hand equip slot and snapping a till when you are aiming at a farm plot. I want to change it to detect if you are holding seeds in "your hand" (can't equip seeds) and snapping a plant placement when aiming at a farm plot (or any plantable tile).

 

First problem (detecting the held item): I think this code in snaptillplacer.lua detects your hand item. I tried changing "GetEquippedItem(EQUIPSLOTS.HANDS)" to "inventoryitem:IsHeld()", but it crashed the game.

Spoiler

local equippeditem = self.inst.replica.inventory:GetEquippedItem(EQUIPSLOTS.HANDS)

    if not equippeditem or (equippeditem and
                            equippeditem.prefab ~= "farm_hoe" and
                            equippeditem.prefab ~= "golden_farm_hoe" and
                            equippeditem.prefab ~= "quagmire_hoe" and
                            equippeditem.prefab ~= "seeds") then
        self:ClearLinked()
        return
    end

 

I also think this code in modmain.lua detects your hand item:

Spoiler

local function IsHandSlotItemHoe(slot)
    return slot ~= nil and slot.equipslot == _G.EQUIPSLOTS.HANDS and slot.tile ~= nil and slot.tile.item ~= nil and
           (slot.tile.item.prefab == "farm_hoe" or
            slot.tile.item.prefab == "golden_farm_hoe" or
            slot.tile.item.prefab == "quagmire_hoe" or
            slot.tile.item.prefab == "seeds")
end

However, I have no idea what to do here other than add "seeds" to the list. And I don't know how to snap planting to the grid. I'm hoping I can still utilize the rest of the code with these small changes.

Please help! I don't know too much about modding and DST components. I'm just a Wormwood main trying to plant 10 farm crops on a tile reliably (Geometric Placement's hexagon tiling doesn't work)

:blue:

Edited by privateal
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...