Jump to content

How to change textures of a container on the ground via context menu.


Berdryn

Recommended Posts

I'd like to have my container set down in the world and as game time passes, items would spawn inside it.  How would I go about this? Can it be done with scripts or must it be lua?

For example, a container made to look like a plant such as a crop plot. Set it down, wait 24 hours and check it to find a food item.

 

Edited by Berdryn
Link to comment
Share on other sites

yes would definitely require lua and would be quite complicated.
 But you could use this as a pretty good starting point:

 

It makes items change into other items over time. including items in containers. So its similar to your goal and if your good at manipulated other peoples code into something else then you can probably do it.

Link to comment
Share on other sites

this is really cool thanks! I'll see if I can make it work. I wonder if there is a way to change what an item looks like on the ground without changing it; like I want my container people to have a context menu: Pose> then pick one of 8 angles. Then when selected, the ground item's icon or texture I guess would change. I thought maybe how TIS does their fire, how it runs through frames for animation. I'd like to pose them but also some how get it to run through a series of frames or new icon/textures to show animation.

Link to comment
Share on other sites

On 2016-10-19 at 11:47 AM, Berdryn said:

this is really cool thanks! I'll see if I can make it work. I wonder if there is a way to change what an item looks like on the ground without changing it; like I want my container people to have a context menu: Pose> then pick one of 8 angles. Then when selected, the ground item's icon or texture I guess would change. I thought maybe how TIS does their fire, how it runs through frames for animation. I'd like to pose them but also some how get it to run through a series of frames or new icon/textures to show animation.

Yes you can change the texture. Thats how I change the cars direction in car mod.

 

inventoryItem.setTexture(Texture texture) ;

and use getTexture(filename); to get a texture instance from a image file

Link to comment
Share on other sites

31 minutes ago, nolanri said:

Yes you can change the texture. Thats how I change the cars direction in car mod.

 

inventoryItem.setTexture(Texture texture) ;

and use getTexture(filename); to get a texture instance from a image file

Yeah I figured, that mod is amazing. I've been looking through the code to try and figure it out but its pretty advanced for my lua knowledge. I see some stuff where you work with textures but I guess I just don't understand it yet.

 

Link to comment
Share on other sites

Is it something I must use getModData() for? I assume so as I would need to assign stuff to a container item that should save with that item.  the tutorial on pz-mods.net for getModData() is rather confusing. 

Could you give some advice on how to get started? My first idea of it is that I use OnCreate in the item recipe to maybe give it the base variables? Say for example it OnCreate calls a lua script that sets up the basics of the item's 'stats' as it were, since these are meant to be like a person, I wanted some form of health and figured there is a way to detect if the container is colliding or just surrounded by zombies. This would cause the life to drain while zombies are present?

but for actually changing the texture of it, how would that work? Would it be possible for one script to handle the option to change the graphic to face the angle chosen across multiple instances of the container? Like I make container person 1, set them down, choose angle to face SE. Make another, set them down and set angle to NW. I feel like that would work but I just don't know where to begin lol

Link to comment
Share on other sites

other than the part about "spawing items in a container over time", I really don't have a good idea of what it is you want to do im afraid.  maybe you should update your top post with a more detailed description and perhaps some diagrams or sketches.

Link to comment
Share on other sites

Here is a short overview:

I'm working on a mod that creates people. The goal in this thread was first to find some info on how to spawn items inside a container, for another aspect of the mod. Which @nolanri answered pretty well with an example. It's possible but hard to do.

Now, this thread is focused towards how to change the texture of a container on the ground without simply replacing the container. Of which, nolanri discussed. I just don't understand how to make use of the advice.

Here is what I am looking for.

Take container and have the option to change it's texture (3d model turned 2d art, 1 of 8 angles for iso graphics)

Container Person > Right click for context menu.

                      - Face SE

                      - Face E

                      - Face NE

                      - Face N

                      - Face NW

                      - Face W

                      - Face SW

                      - Face S

Each of those options would check the container's texture I assume then change it to the proper graphic located in the textures folder. As it is a container, I don't want to simply replace the item and as Nolanri said, it can be done. I just don't know how to get it started.

Link to comment
Share on other sites

Ok so you could make an "item" that is a container type. lets say called "ContainerMan"

 

then make recipies that only require ContainerMan as a "keep" ingredient. and set canBeDoneFromFloor: true, so they dont pickup the ContainerMan when doing these face direction recipies.

 

Connect each recipie to a lua function with OnCreate: functionnamehere,

 

eg:

function YourOnCreateFunctionSW(items, result, player)

	for i=0, items:size()-1 do
		if(items:get(i):getType() == "ContainerMan") then
			items:get(i):getType():setTexture(getTexture("ContainerMan_SW.png"));
		end
	end
end

 

But I still dont quite see the point of a mod that has "people" containers that can be rotated at will...lol

Link to comment
Share on other sites

This is just one part of the mod. I am hoping to learn how to do this sorta thing as well as other key elements like movement of a container and more for my mod that I'll use these people as part of a community sim game where you find them, take care of them and use them like tower defense turrets to give a semblance of an npc companion or group in the game. 

Posing them is just a method to give them some variety so they aren't flat 2d graphics copied from google. I'm using blender to make the 3d models then rendering them out, once that system works well enough I don't see why it couldn't be coded to run through animation frames to give the containers more life; an idle stance, if I could figure out how to make it follow the player, it would run through walking/running animations, etc. 

Thank you for the help, I'll see what I can do with it :)

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
×
×
  • Create New...