Jump to content

Help! Mod character portraits not showing


HunterV

Recommended Posts

I'm creating my first character mod and I've run into a problem right off the bat. Not surprising since I'm more of an artist than a coder so I keep tripping up on the scripts.

 

Anyway, here's my issue. The mod isn't using the files I made specifically for its big portrait and screen select. Like so:

1T3A9oh.png

 

The images in the transparent white space were put there for reference of what they should look like.

Now I have no idea where I went wrong because I'm using another completed mod as reference and the coding looks like it should be right. Not to mention the large portrait was working earlier and suddenly it's not.

 

It's probably foolish for me to jump head first into a project that involves so much coding (I want to script a hunger influenced night vision, occasional item dropping, and speed decrease during rain to name a few traits) without help from someone more skilled in scripting, but I really wanted to try.

 

Expect to see me ask more questions here as I get deeper into trying to script. I want to do it on my own, but this stuff is difficult for me.

 

 

Here's a link to what I've got for the mod so far.

Please, point out where I went wrong. This stuff if giving me a major headache fretting over on my own.

Link to comment
Share on other sites

The game fails to load your images in the first place, so add the following in modmain.lua (above the other asset):

 

Asset( "ATLAS", "images/selectscreen_portraits/bhs.xml" ),

 

Also, it appears your images are of the wrong size. Their height and width should be a power of two (2,4,8,16,...) in order to display properly to everyone.

 

EDIT: Is it possible I know that guy from somewhere?

Link to comment
Share on other sites

Ah. I see. I was working from a template that had all the images already included and was just editing them and overwriting the save in hopes that the sizing was correct to begin with. I suppose the template just had incorrectly sized images to start with. Next time I'll reference the game files directly, now that I've started exploring them a bit more, instead of a user-made template.

 

Thank you for the assistance. I've added the asset line and I'm going to see what I can do about fixing the image sizes right now.

 

Also yes, it's possible you recognize the character because Sir Hoots is a very heavy nod to the TF2 Sniper cosmetic item Sir Shootsalot.

By "nod" I mean Sir Hoots is literally bird-head sniper. bhs.xml Haha. I'm clever.

Link to comment
Share on other sites

Ah. I see. I was working from a template that had all the images already included and was just editing them and overwriting the save in hopes that the sizing was correct to begin with. I suppose the template just had incorrectly sized images to start with. Next time I'll reference the game files directly, now that I've started exploring them a bit more, instead of a user-made template.

 

Thank you for the assistance. I've added the asset line and I'm going to see what I can do about fixing the image sizes right now.

 

Also yes, it's possible you recognize the character because Sir Hoots is a very heavy nod to the TF2 Sniper cosmetic item Sir Shootsalot.

By "nod" I mean Sir Hoots is literally bird-head sniper. bhs.xml Haha. I'm clever.

 

I'm glad you got it working. When encountering an issue, it's best to compare to similiar mods or the game code, or asking on the forums ;).

 

I remembered the owl mask from Hotline Miami, acutally. They're both blowing heads off, so I'm not that far off.

Link to comment
Share on other sites

Well, it seems I've gone and made it worse. I was attempting to add instructions to the code for applying night vision only if the character has hunger over a certain point. I was referencing another mod for the night vision and Wolfgang's coding for adding strength when mighty and I'm pretty sure I just hodgepodged it all into a broken mess.

 

When I tried to run the mod it would go back to the title screen, but the game wouldn't respond. Couldn't click or access anything. That brand of broken.

 

Oh, and on top of that, before I attempted to add the night vision code I had applied the size change to the big portrait (referencing Wilson's portrait size in the game files) as well as the asset line to the code, but I didn't change the image size for the select screen image. When I tested it, the select screen image worked, but the big portrait still didn't. I get the feeling that changing the big portrait back to the original size I had it might fix the issue, but I can't test it now since I went and broke everything.

 

And again, here's my files if anyone wants to help me out.

 

Sir Hoots.zip

 

Log.text

 

Oh man, I have Hotline Miami, but I haven't played it yet. Now knowing there's an owl mask in it makes me feel like I should get around to that so I can make some references to it in this mod. I love me some references.

Link to comment
Share on other sites

Well, it seems I've gone and made it worse. I was attempting to add instructions to the code for applying night vision only if the character has hunger over a certain point. I was referencing another mod for the night vision and Wolfgang's coding for adding strength when mighty and I'm pretty sure I just hodgepodged it all into a broken mess.

 

When I tried to run the mod it would go back to the title screen, but the game wouldn't respond. Couldn't click or access anything. That brand of broken.

 

Oh, and on top of that, before I attempted to add the night vision code I had applied the size change to the big portrait (referencing Wilson's portrait size in the game files) as well as the asset line to the code, but I didn't change the image size for the select screen image. When I tested it, the select screen image worked, but the big portrait still didn't. I get the feeling that changing the big portrait back to the original size I had it might fix the issue, but I can't test it now since I went and broke everything.

 

Here's why it's crashing: inst.components.hungerrate: (TUNING.WILSON_HUNGER_RATE * 2)

It should be: inst.components.hunger.hungerrate = TUNING.WILSON_HUNGER_RATE * 2

 

EDIT: Also, I changed the night vision block a bit:

--Night vision	inst.entity:AddLight()	inst.Light:SetRadius(10)	inst.Light:SetFalloff(.5)	inst.Light:SetIntensity(.9)	inst.Light:SetColour(245/255,255/255,245/255)	inst:ListenForEvent( "nighttime", function()		if inst.components.hunger.current > (200) then --when fed, you see at night			inst.Light:Enable(true)		else if			inst.components.hunger.current < (200) then			inst.Light:Enable(false)		end	end, GetWorld() )	--Day vision	inst:ListenForEvent( "daytime", function()		inst.Light:Enable(false)	end, GetWorld() )

Link to comment
Share on other sites

Hmm, I tried changing the hunger rate line like you suggested and it didn't help. I tried completely replacing the hunger and health lines with code from another mod that I know is working and it still crashed. I also tried removing my attempt at speed decrease during rain and still no fix. There must be another error I made somewhere.

 

Also thank you for the revised night vision script!

 

 

Edit:
I attempted rebuilding the mod from scratch and it's still crashing. I have no idea what to do to fix this issue. I might need to seek out someone to take over the scripting for me as I can't seem to find any fixes.

 

Edit 2:

I backtracked to the version provided a couple posts ago as a zip file and looked back over the changes you suggested and figured out a way to keep it from crashing, but still the big profile image isn't loading.

 

Good news though! I learned how to read the error codes in the log.txt

It took me a while, but I'm starting to understand them!

 

Tried adding in the new night vision again and it crashed.

 

According to the error crashing the game there's something wrong with the night vision code.

" lua:72: unexpected symbol near ',' "

    inst:ListenForEvent( "nighttime", function()        if inst.components.hunger.current > (200) then --when fed, you see at night            inst.Light:Enable(true)        else if            inst.components.hunger.current < (200) then            inst.Light:Enable(false)        end    end, GetWorld() )

    end, GetWorld() ) is line 72

 

I looked really hard at the code because I didn't understand why it was breaking. But I figured it out. The line was missing another "end" above the "end, GetWorld() )" line

 

I thought I had it fixed, but now the mod causes the game to just close out when attempting to load into a new world.

 

So the problem now is big portrait not showing and instead borrowing from the neighboring character and the game closing out when trying to run the mod

 

Going to keep trying to fix the issue on my own, but if I can't I'll post a new .zip with the files I'm using before I head off to bed.

 

Edit 3:

 

I still can't figure out whatever is causing the issue so I'm going to put the files up again for help.

 

Sirhoots 0-3.zip

 

Log.text

Link to comment
Share on other sites

First off, you don't need the second day vision block.

 

The crash from your log is because there is no "Wilson_Damage_Multiplier". Try this:
inst.components.combat.damagemultiplier = 1.1

 

Furthermore, that rain bit isn't going to work, mostly because it'd never un-do. Try:

    inst::ListenForEvent( "rainstart", function()    	inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 0.7)    	inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 0.8)    end, GetSeasonManager() )	    inst:ListenForEvent( "rainstop", function()    	inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.25)    	inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.15)    end, GetSeasonManager() )
Link to comment
Share on other sites

Oh man, thank you so much! That one damn line. I swear I had pulled it right from another mod that was using the damage multiplier line just fine, but ah well. Your correction fixed it!

 

As for the daylight thing, my bad, I stayed up too late trying to re-work the script and must has put it in twice. I probably would have caught it, but I'm glad you pointed it out so I could fix it right away. And the freaken rain thing, I should have known that before. RPG maker does the same thing with added events and I feel foolish for not remembering that game scripts are like genie wishes in that it can do anything but it needs to be super dang specific.

 

Now I can go on to try to add a damage induced item drop script.

 

Before I try, is there any specific line for taking damage? Like when a player is injured by anything and loses health?

 

I want to try to write an event that causes Sir Hoots to drop a random type of feather when taking damage and to make it a small chance to happen. I think the Link character mod has a loot drop script for when killing a mob, I might reference that for the feather chance percentages, but I'm not sure what line might indicate taking damage.

Link to comment
Share on other sites

Before I try, is there any specific line for taking damage? Like when a player is injured by anything and loses health?

 

Yes, you can set a function for that:

 

local function OnHit(inst, attacker, dmg)

--I recommend using if math.random() < CHANCE then for a random chance

[...]

end

 

Somewhere under the other components.combat stuff, write this:

 

inst.components.combat.onhitfn = OnHit

Link to comment
Share on other sites

Hmm, I can't figure out how to script the feather drop correctly. I think I'll leave that out for now and just work on fixing the more important features before creating more issues.

 

Aside from the random feather drop I still have two things that need to be done/fixed.

 

- Creating a nocturnal script making the character lose sanity during the day and gain it back during dusk and the night.

 

- and fixing this

tumblr_nfz1etjpwu1qepok7o1_1280.png

I'm not sure what's going on with save slot not using the image I've provided. I triple checked that its the right size, but it's still either blank or shows Wilson.

I assume I'm missing code somewhere for it.

Link to comment
Share on other sites

I'm having problems with getting the select screen portrait to work sort of like you did at the top of this post. every time I put in my own file that is the same size as the sample mod's portrait file that does in fact work and show up in the game, my game crashes when I go to scroll over to select my character when I have loaded in my own art work rather then the sample mod's. I named everything correctly and this is the only thing that is not working for my mod. Its really starting to annoy me. any help would be greatly appreciated as in what is the exact size the portrait has to be and can I have any part of the image outside of the red outline that is provided in the sample select screen portrait file?

sorry I don't know where else to post this question that has active people using a forum.

Anyways thanks in advance.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...