Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modding Help: How to add an animal Input to a production #6

Open
Z7Seven opened this issue Dec 16, 2022 · 18 comments
Open

Modding Help: How to add an animal Input to a production #6

Z7Seven opened this issue Dec 16, 2022 · 18 comments
Labels
Modding help Some problems with integrating the animal input extension into a mod

Comments

@Z7Seven
Copy link

Z7Seven commented Dec 16, 2022

Hi..

I'm trying to use the script to add Pigs (and also other animals) to a Production chain but having some trouble.

For one, I'm unable to unload the animals at the unload point? I'm not sure how to get this to work?
I tried to copy what you did with the Horse Training mod... I'm sure I created the production and storage the correct way.

I can place the production building, I can see the pig icon in the production chain menus. But I'm not able to unload the animals..

I can see you used a animalInputTrigger for the Horse Training xml but I'm not sure of the correct way it should be used.?

Any help would be appreciated... I struggle a bit with the modding.. ;)
I can find my way around the xml, files but don't really understand the lua scripts so well..

Thank you..

Here's some of the xml info -

<productionPoint>
    <productions>
        <production id="bacon" name="$l10n_fillType_bacon" cyclesPerHour="1000" costsPerActiveHour="1">
            <inputs>
                <input fillType="TOMATO" amount="10" />
	        <input fillType="PIG_LANDRACE" amount="1" />
            </inputs>
            <outputs>
                <output fillType="BACON" amount="100" />
            </outputs>
        </production>
    </productions>

    <storage isExtension="false" fillLevelSyncThreshold="50">
		<!-- inputs-->
                <capacity fillType="TOMATO"     capacity="150000" />
		<capacity fillType="PIG_LANDRACE"      capacity="20000" isAnimalFillType="true" litersPerAnimal="1000" leastAge="1" />
		<capacity fillType="PIG_BLACK_PIED"    capacity="20000" isAnimalFillType="true" litersPerAnimal="1000" leastAge="1" />
		<capacity fillType="PIG_BERKSHIRE"     capacity="20000" isAnimalFillType="true" litersPerAnimal="1000" leastAge="1" />
		<!-- outputs -->
		<capacity fillType="BACON"       capacity="15000" />
    </storage>

    <sellingStation node="sellingStation" appearsOnStats="true" supportsExtension="false">
        <unloadTrigger exactFillRootNode="exactFillRootNode" fillTypes="TOMATO PIG_LANDRACE PIG_BLACK_PIED PIG_BERKSHIRE"/>
    </sellingStation>

    <palletSpawner node="palletSpawner">
        <spawnPlaces>
            <spawnPlace startNode="spawnSpace1start" />
        </spawnPlaces>
    </palletSpawner>

    <playerTrigger node="playerTrigger" />
	<animalInputTrigger node="animalInputTrigger" />

    <sounds>
        <idle template="carpenterIdle" linkNode="0>" />
        <active template="carpenterWork" linkNode="0>" />
    </sounds>
</productionPoint>

<triggerMarkers>
    <triggerMarker node="warningStripes" />
    <triggerMarker node="playerTriggerMarker"         filename="$data/shared/assets/marker/markerIcons.xml" id="WRENCH"           adjustToGround="true" />
    <triggerMarker node="unloadTriggerMarker"         filename="$data/shared/assets/marker/markerIcons.xml" id="UNLOAD"           adjustToGround="true" />
</triggerMarkers>

<hotspots>
    <hotspot type="PRODUCTION_POINT" linkNode="unloadTriggerMarker" teleportNode="unloadTriggerMarker" />
</hotspots>
@Z7Seven
Copy link
Author

Z7Seven commented Dec 17, 2022

Thank you for replying.

I think this might be above my current modding skills though.. ;)

Is this what you mentioned? It's from the Horse Training mod -

this is in the xml file -

    <i3dMapping id="animalInputTrigger" node="0>23" />
    <i3dMapping id="playerTrigger" node="0>24" />

and this is from the i3d file -

    <Shape shapeId="105" name="animalInputTrigger" translation="-15.3289 1.4624 -7.43478" static="true" trigger="true" collisionMask="3145728" clipDistance="300" nodeId="533" materialIds="130" castsShadows="true" receiveShadows="true" nonRenderable="true"/>
    <Shape shapeId="106" name="playerTrigger" translation="9.85712 1.09753 3.27481" static="true" trigger="true" collisionMask="1048576" clipDistance="300" nodeId="534" materialIds="131" nonRenderable="true" distanceBlending="false"/>

Is it only possible to get the unloading to work by using the GiantsEditor? Is that where the nodeId and shapeId are created?
Just copying this to my own mod file does not seem to work, but I'm probably not doing it right.

Should the files from the AnimalInputExtension be loaded as a mod, or be part of my files?
I see in the Horse Training mod they have a lua file as part of the mod, but it's called ObjectFillLevel.lua - so I'm not sure if it has anything to do with just unloading the animals

Thank for your help... I guess I might have to just release my mod as is without this.. going to keep on trying though.. ;)

@tn4799
Copy link
Owner

tn4799 commented Dec 17, 2022

Like sasha said, you need an animalInputTrigger with the right collision mask. the easiest way is to export the animaInputTrigger from the Horse Training Facility and import it into your production. All of that is recommended to be done inside the giants editor.

You then can drive with a animal trailer to the trigger and press R to open the animal transfer menu to put your pigs into the production.

Should the files from the AnimalInputExtension be loaded as a mod, or be part of my files?
I see in the Horse Training mod they have a lua file as part of the mod, but it's called ObjectFillLevel.lua - so I'm not sure if it has anything to do with just unloading the animals

Just add the Animal Input Extension as a dependency in the mod desc and then the game will check automatically for you if the mod is available and if not it will download the mod. So the answer is: The animalInput extension is a mod that delivers the foundation of animal inputs for productions and does NOT need to be integrated into any kind of mod.
The ObjectFillLevel.lua-script is only there to visualize the animals ive put into the production, but it is not needed to make a production with animal input work.

By the way, if you want to use all kind of pig races other than Landrace you need to define own production chains for those since as of right now my script does not enable converting animal sub types from one to another.

@tn4799 tn4799 added the Modding help Some problems with integrating the animal input extension into a mod label Dec 17, 2022
@Z7Seven
Copy link
Author

Z7Seven commented Dec 18, 2022

Thank you so much for replying and the information shared.!

I think I managed to make some progress but I'm still doing something wrong though..

I used the Giants editor to export the animalInputTrigger from the Horse Training production i3d file -
image

I then import the files created by the export back to my Production building-
image

I then see this in the i3d file -

<TransformGroup name="collisions" nodeId="550">
    <Shape shapeId="26" name="collision" visibility="false" static="true" nodeId="551" materialIds="411" castsShadows="true" receiveShadows="true" nonRenderable="true"/>
    <Shape shapeId="27" name="tipCollision" visibility="false" static="true" collisionMask="524288" nodeId="552" materialIds="411" castsShadows="true" receiveShadows="true" nonRenderable="true"/>
  </TransformGroup>
  <Shape shapeId="28" name="animalInputTrigger" translation="-15.3289 1.4624 -7.43478" static="true" trigger="true" collisionMask="3145728" clipDistance="300" nodeId="553" materialIds="411" castsShadows="true" receiveShadows="true" nonRenderable="true"/>

In the Horse Training xml I can see this -

 <i3dMapping id="animalInputTrigger" node="0>23" />

So I add a new line to my production xml -

 <i3dMapping id="animalInputTrigger" node="0>13" />

Is the number at the end just the next number in the sequence, or should I get it from somewhere else?

You will also see that I imported the navigationRootNode to my Production building.
I saw the UserAttributes at the end of the Horse Training i3d file, so I also tried to import this to my building in the hopes that it would work..

     <UserAttributes>
         <UserAttribute nodeId="544">
         <Attribute name="animalType" type="string" value="pig"/>
         </UserAttribute>
     </UserAttributes>

I'm trying to use the CarpentryEU building for my Production building, so not sure if that's the problem?
The building has an exclamation mark icon at the one corner that I'm trying to re-use as the animal icon & trigger

Another thing I noticed is that when I use the following for the SellingStation, I can unload the Tomatoes (tomatoes just part of production recipe to test unloading trigger;) -

  <sellingStation node="sellingStation" supportsExtension="false">
        <unloadTrigger exactFillRootNode="unloadTrigger" aiNode="unloadTriggerAINode" fillTypes="TOMATO PIG_LANDRACE PIG_BLACK_PIED PIG_BERKSHIRE" />
    </sellingStation>

But if I copy from the Horse Training xml I can not unload the Tomatoes anymore -

    <sellingStation node="sellingStation" appearsOnStats="true" supportsExtension="false">
        <!-- All animal types need to be inserted here, otherwise the production won't run-->
	    <unloadTrigger exactFillRootNode="exactFillRootNode" fillTypes="TOMATO PIG_LANDRACE PIG_BLACK_PIED PIG_BERKSHIRE">
            <baleTrigger node="baleTrigger" />
        </unloadTrigger>
    </sellingStation>

So, how badly did I mess it up.? ;)

Is it at all possible to unload the animals at one of the regular production buildings? Or must the building have fences?

I'm just trying to unload the animals and want it to appear in the production menu so it can be used in recipes. Don't need to see or feed it..

Thanks for the tip on the individual production chains for the animal sub types... thought I'd just try and get at least one to work before I do the rest.. ;)

Ah well, will keep on trying... at least I got the blueberries to work..

@tn4799
Copy link
Owner

tn4799 commented Dec 18, 2022

Please attach the .shapes-file of your i3d as well. otherwise i cannot really help you with the i3d file since i cannot see any structures.
In general, instead of copy pasting the files, just attach them. Then it is easier for ne to download them and take a look at it.

@tn4799
Copy link
Owner

tn4799 commented Dec 18, 2022

And you probably have the wrong i3d-Mapping, since your animalInputTrigger is at index 0>28 if i reat it correctly.

Is it at all possible to unload the animals at one of the regular production buildings? Or must the building have fences?

No, unfortunally not, thats why i've written this script to implement the feature.

But if I copy from the Horse Training xml I can not unload the Tomatoes anymore

The reason for that is that you then use another i3d mapping for the exactFillRootNode, which then is not defined.

@tn4799 tn4799 changed the title How to unload animals at production building? Modding Help: How to add an animal Input to a production Dec 18, 2022
@Z7Seven
Copy link
Author

Z7Seven commented Dec 18, 2022

Thanks again for helping..

OK, I understand about a production building not working. I will try and use one of the animal buildings instead.

Can you unload more than one animal type at a single building if there are multiple production chains (so a cow and a pig at the same building)?

It is possible what I'm trying to do? Use animals as food products in production chains... otherwise I should just stick to the vegetarian options.. ;)

Thanks for offering to have a look at the files... let me try this again with the correct building type and I see how far I get..
I don't know why the animalInputTrigger is at index 0>28, so I might get that wrong again..

@tn4799
Copy link
Owner

tn4799 commented Dec 18, 2022

OK, I understand about a production building not working. I will try and use one of the animal buildings instead.

you can use a production puilding. i missunderstood your question. For the game it doesnt matter how a building looks.
I thought you wanted to know if you can input animals into productions in the base game.

Can you unload more than one animal type at a single building if there are multiple production chains (so a cow and a pig at the same building)?

Yes, you can buy more than one animal type. Just add them to the storage and define them as an animalInput.

It is possible what I'm trying to do? Use animals as food products in production chains... otherwise I should just stick to the vegetarian options.. ;)

Yes, of course. you can mix and match any fill type as you want to produce any fill type you want.

@Z7Seven
Copy link
Author

Z7Seven commented Dec 18, 2022

OK, thank you very much.

Now I have a question again... sorry about all the back and forth.. I'm now a bit confused....

I've been trying to use this building (attached) as the butcher production building.
But I've been unable to unload any animals. I tried to import the animalInputTrigger in previous attempts, but did not get it to work.

Is it at all possible to use this building for what I'm trying to do?
Or should I use one of the animal pens/buildings as a base and work from there.?

butcherTestFiles.zip

@Z7Seven
Copy link
Author

Z7Seven commented Dec 19, 2022

OK.. thank you very much..

I don't know what's going on.. I get the feeling it something really simple but I'm not seeing it..

I only made a few changes to the original xml.

I made changes to the Productions, the Storage and the fillTypes for the Selling station.
I also added the following -

 <animalInputTrigger node="animalInputTrigger" />

and also this -

  <i3dMapping id="animalInputTrigger" node="3>0" />

This is what I see in the Editor -
image

I attached the files again... Not sure what I'm doing wrong - but probably a lot.. ;)

butcherTest2k.zip

@tn4799
Copy link
Owner

tn4799 commented Dec 19, 2022

have you ever started the game and taken a look into your log.txt? there should be a couple of errors

@Z7Seven
Copy link
Author

Z7Seven commented Dec 19, 2022

OK.. we might be in business now.! I finally made some progress -
image

Managed to unload the animals.. also managed to break another part of the building.. ;)
Going to try and create it again from scratch.. will give feedback..

Thank you both very much for helping.!!

@Z7Seven
Copy link
Author

Z7Seven commented Dec 20, 2022

Great... I recreated the building and it's all working now!

Was an issue with the node. It was saved incorrectly after importing. Saved it as a new node and not as part of the existing path... fixed that and learned a few things along the way.

Thank you so much for helping.!!

I will give credit if I ever get to release the mod.. It's gotten a bit out of hand now.. ;)

@Z7Seven
Copy link
Author

Z7Seven commented Jan 4, 2023

Hi.. just wanted to ask something quickly..

I unload animals at the building, then go and get more from the pen. When I arrive back at the building I can open the Animal Dialogue, but the Select and Confirm buttons only appear after I hit Enter, or X on the the controller.
Is this something I messed up with the trigger?
Once the buttons appear the animals can be unloaded, and no error about the trigger in the log. It works as it should..

And then about the amount of liters you get versus animal age

At 12 months you get 200 liters per sheep, at 24 you get 400, and so on. I unloaded a 60 month old sheep and got 1000 liters.
I did not test with anything older than 60 months..

Is there a max threshold for this number or will it just keep on growing?
I guess that in-game one will not hold on to the animal for so long though..

@tn4799
Copy link
Owner

tn4799 commented Jan 9, 2023

I unload animals at the building, then go and get more from the pen. When I arrive back at the building I can open the Animal Dialogue, but the Select and Confirm buttons only appear after I hit Enter, or X on the the controller.
Is this something I messed up with the trigger?
Once the buttons appear the animals can be unloaded, and no error about the trigger in the log. It works as it should..

With the buttons i have to take a look at it again, as some are not completly correct shown. I will take a look at it if I got some spare time.

And then about the amount of liters you get versus animal age
At 12 months you get 200 liters per sheep, at 24 you get 400, and so on. I unloaded a 60 month old sheep and got 1000 liters.
I did not test with anything older than 60 months..
Is there a max threshold for this number or will it just keep on growing?
I guess that in-game one will not hold on to the animal for so long though..

60 Months should be the cap since that is the cap of giants. i just use giants calculation of the age and health factor. So yes, there is a max cap. And you can define how much you can get at most per animal.
And keep in mind. If your animals are healthier, you get more liters per animal.

@Z7Seven
Copy link
Author

Z7Seven commented Jan 11, 2023

ok, thank you for the info..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Modding help Some problems with integrating the animal input extension into a mod
Projects
None yet
Development

No branches or pull requests

3 participants
@tn4799 @Z7Seven and others