Giews Posted March 15, 2025 Share Posted March 15, 2025 What I Need I'm trying to create a simple mod that adds a hotkey (R) to feed your beefalo while riding it, without having to use the mouse to select food and click on the beefalo. Current Progress I have a basic mod structure that doesn't crash the game anymore, but the feeding action isn't working correctly. The mod can detect when I press R while riding a beefalo and even displays the "Eat it!" message, but it doesn't actually feed the beefalo. Code I Have So Far lua Copiar -- modinfo.lua name = "Beefalo Feed Hotkey" description = "Adds a hotkey (default: R) to feed your Beefalo while riding." author = "Giews" version = "1.0.0" api_version = 10 icon_atlas = "modicon.xml" icon = "modicon.tex" dst_compatible = true all_clients_require_mod = false client_only_mod = true lua Copiar -- modmain.lua local TUNING = GLOBAL.TUNING local ACTIONS = GLOBAL.ACTIONS local TheInput = GLOBAL.TheInput local SendRPCToServer = GLOBAL.SendRPCToServer local FEED_HOTKEY = GLOBAL.KEY_R -- Define common beefalo foods local BEEFALO_FOODS = { lightbulb = true, carrot = true, berries = true, berries_juicy = true, cutgrass = true } local function FindBeefaloFood(player) if not player or not player.replica.inventory then return nil end local inventory = player.replica.inventory for _, item in pairs(inventory:GetItems()) do if item and BEEFALO_FOODS[item.prefab] then return item end end return nil end local function FeedBeefalo() local player = GLOBAL.ThePlayer if not player then return false end local rider = player.replica.rider if rider and rider:IsRiding() then local mount = rider:GetMount() if mount and mount.prefab == "beefalo" then local food_item = FindBeefaloFood(player) if food_item then SendRPCToServer(GLOBAL.RPC.UseItemFromInvTile, GLOBAL.ACTIONS.FEED.code, food_item, mount) if player.components and player.components.talker then player.components.talker:Say("Eat it!") end return true else if player.components and player.components.talker then player.components.talker:Say("I need food for my beefalo!") end return false end end end return false end GLOBAL.TheInput:AddKeyDownHandler(FEED_HOTKEY, function() if InGame() then FeedBeefalo() end end) function InGame() return GLOBAL.ThePlayer and GLOBAL.ThePlayer.HUD and not GLOBAL.ThePlayer.HUD:HasInputFocus() and not GLOBAL.ThePlayer:HasTag("playerghost") and GLOBAL.ThePlayer.entity:IsVisible() end The Problem I need help figuring out what RPC action is actually used when manually feeding a beefalo while riding it. The mod shows the "Eat it!" text when pressing R, but no actual feeding happens. Can You Help? If anyone knows the correct action/RPC to feed a beefalo while riding it, or could build a working version of this mod, I would be extremely grateful! I'm not an experienced Lua coder and just want this simple quality-of-life feature. Thanks in advance to anyone who can help! Link to comment https://forums.kleientertainment.com/forums/topic/164891-mod-request-beefalo-feed-hotkey-while-riding/ Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now