How to incorporate non-resource items into costList

Started by jpwrunyan, April 29, 2014, 03:51:32 PM

Previous topic - Next topic

jpwrunyan

I wanted to ask if it is at all possible to have a non-resource item be part of the costList for a building. For example, I was thinking of trying to make the Minigun item be a necessary component of an automated minigun turret. Currently this doesn't appear to be supported. Is the only option to modify the core minigun so that it is a resource and not a weapon? :-(

I know another person on here had the same idea, but that thread died.

Currently the best solution appears to be making a minigun resource (eg: "minigun barrel") and preserve the original minigun item as-is. But I'm hoping there might be a better way since having an item be a necessary component to making another item would be awesome.

Architect

You should be able to add non-resource items to a cost list,  at least I always thought you could. I'll try it in a sec and get back to you.
Check out BetterPower+ and all its derivatives by clicking the picture below.

It adds many new methods of power generation and uses for it, as well as other things such as incidents.


Architect

Just tested, it does work, however it throws an error whenever you go to look at the item in the menu, so I am surprised it actually works XD I'll pry further for you, see if I can clear up the error problem.
Check out BetterPower+ and all its derivatives by clicking the picture below.

It adds many new methods of power generation and uses for it, as well as other things such as incidents.


jpwrunyan

#3
Thank you. I got the error message on start-up and just assumed I messed up the game. I was about to post a suggestion for this on the suggestions thread but will wait to see what you find. By the way, this is how I implemented it:

<costList>
  <li>
    <thingDef>Gun_Minigun</thingDef>
    <count>1</count>
  </li>
  <li>
    <thingDef>Metal</thingDef>
    <count>160</count>
  </li>
</costList>


edit: By golly, you're right! It totally does work! From now on I will be more skeptical of thrown errors. This made my day!

Architect

And you implemented it spot on :P copy the minigun def into your mod, along with the base gun it inherits, then put: <resourceCountPriority>Middle</resourceCountPriority> somewhere in the minigun def. That should solve your errors, and allow your thing of choice to cost the minigun :D
Check out BetterPower+ and all its derivatives by clicking the picture below.

It adds many new methods of power generation and uses for it, as well as other things such as incidents.


jpwrunyan

OMG That's wonderful! It removes the error! And now I'm starting to grasp the big picture. I'll have to put this knowledge on the wiki!

Architect

Quote from: jpwrunyan on April 29, 2014, 05:24:45 PM
OMG That's wonderful! It removes the error! And now I'm starting to grasp the big picture. I'll have to put this knowledge on the wiki!

Aye do that! the more information on the wiki, the easier modding will become for people :D
Check out BetterPower+ and all its derivatives by clicking the picture below.

It adds many new methods of power generation and uses for it, as well as other things such as incidents.


Austupaio


Tynan

Can you guys post the error message it throws? I can fix this.
Tynan Sylvester - @TynanSylvester - Tynan's Blog

Architect

#9
Quote from: Tynan on April 30, 2014, 01:02:16 PM
Can you guys post the error message it throws? I can fix this.

The error is:
Looked for nonexistent key Gun_Pistol in counted resources.
Check out BetterPower+ and all its derivatives by clicking the picture below.

It adds many new methods of power generation and uses for it, as well as other things such as incidents.


Tynan

Tynan Sylvester - @TynanSylvester - Tynan's Blog

Tynan

Tynan Sylvester - @TynanSylvester - Tynan's Blog

Architect

Check out BetterPower+ and all its derivatives by clicking the picture below.

It adds many new methods of power generation and uses for it, as well as other things such as incidents.


jpwrunyan

Quote from: Tynan on April 30, 2014, 02:42:50 PM
This should be fixed up in next build.

I'm guessing that "resourceCountPriority" will have a silent default? When I (or someone else) writes a tutorial for this it can be left out for simplicity's sake then. Or better, explained alongside information about resources in general.

Tynan

It just affects the ordering of the resources as they're counted on the top left of the screen. The bug was with the fact that the global resource counter doesn't count things which don't have a count priority, but when you build something the UI code queries the global count to see if the cost number should be red as it is displayed next to your mouse. It queried, found no record, threw exception.
Tynan Sylvester - @TynanSylvester - Tynan's Blog