Jump to content

[solved] custom item: cigar


Recommended Posts

So I made this guy http://steamcommunity.com/sharedfiles/filedetails/?id=1327870383

And I would love for him to refuse to eat specific items only. Lets say for instance he refuses to eat ratatouille, the way all characters refuse to eat the Eternal Fruitcake.

 

Now onto the hard one. I want to give him a cigar. I found an amazing character that already has a cigar http://steamcommunity.com/sharedfiles/filedetails/?id=950167662&searchtext=cigar

I've been trying to gather what it is I'll have to do to get something similar for my character but I'm quite lost and everything I've tried makes it crash. 

 

Any help would be greatly appreciated. 

Edited by DevilsRoost
Link to comment
Share on other sites

Spoiler

local meh = {
   ratatouille = true,
  --add more items in a list format
}	
local _PrefersToEat = inst.components.eater.PrefersToEat
inst.components.eater.PrefersToEat = function(self, food)
	return _PrefersToEat(self, food) and not meh[food.prefab]
end

add to your master_postinit of your character

As for the cigar, I will need to know what you are doing wrong. I do know that the other mod's cigar only allows that particular character to use it. So if you are copying it you would need to update your version to either be exclusive or remove that part of the code.

Link to comment
Share on other sites

According to client_log your missing the actual files(zip files in the anim folder) for the cigar, i think your missing a asset in the modmain. Otherwise judging from the coding and preview on that link looks like it came from this mod:

All in all creating your cigar from this mod is a bit easier at least in my opinion than what you were trying to do.

Link to comment
Share on other sites

I've been trying to follow making the hat from scratch, which is great! Before I began the game I wanted to see what the hat would look like in game so I could figure out where to position the cigar, but even this hat, with no tweaking at all, makes the game crash. 

I've been trying to follow this tutorial, but it looks like I keep running into problems with the anim file as I've been fiddling about? I don't know how to fix this as I thought it just auto compiled as it did with the EscTemplate character mod.

image.thumb.png.1fb7059e69a0e849f376f19c15788e5f.png

Link to comment
Share on other sites

The error listed is saying inside of your modmain.lua file on line 6 there's an issue. If it's attempting to index nil that means it's being given a piece of code that doesn't seem to exist. If you can share your modmain.lua file then we'll be able to troubleshoot it further.

Edited by RedHairedHero
Link to comment
Share on other sites

This tutorial is not really updated for don't starve together, its missing important parts like

    if not TheWorld.ismastersim then
        return inst
    end

    inst.entity:SetPristine()

Honestly, it is much better in general to grab properly coded lua files from other people's mods or the games and modify them to your design and you can still use the spriter files for the hat template from the tutorial.

One other thing your spriter files folder structure doesn't match the spriter files code structure, you can easily edit this by opening spriter in a text editor and renaming the swap_hat to match your folders if desired. Not really a big concern unless the objects symbols are important.

Also it isn't really neccessary to make a swap spriter file as they are identical to each other.

You'll probably also not want to hide symbols like a conventional hat as this is more like the earmuffs where it doesn't really hide anything. I updated the code to better match the earmuffs version as it is wierd seeing the top of a characters head getting chopped off or their hair vanishing because they smoked a cigar. lols

Attached below is a fixed version of your mod, if you want to test it just use c_give("cigar", 1) in the console.

You'll probably eventually want to add smoke/flame at the tip so I recommend you check out how torches/lighters do it.

 

hat cigar.rar

Edited by IronHunter
typographical errors
Link to comment
Share on other sites

As predicted, I return. Attached is the thing I'm very pleased with it, (as you did most of the work to fix it!? Thank you)

 

But the lighter fire prefab I assume sticks to the arm animation. How would I get it to be on the hat animation? I also would like to ad smoke more than I would a flame, I suppose that will comne with fiddling between the torchfire and lighterfire things. 

hat cigar.rar

Link to comment
Share on other sites

Fixed your CIGAR string, cleaned up your file, created a smoke particle effect for your cigar, added a follower symbol for your cigar lols...

Also repositioned the cigar so it looks nice when is wilson's mouth.

This is good practice for my own particle stuff.

I commented out the flame aspect of the thing(not sure if it works didn't test the flame part) probably needs some tweaks. But you got smoke for sure.

Screenshot

Left some comments so you can adjust its position etc to your liking.

hat cigar.rar

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...