# Primary charge check for tools

**URL:** <https://discourse.cataclysmdda.org/t/primary-charge-check-for-tools/5937>\
**Category:** The Toolbox\
**Created:** [April 23, 2014, 7:53pm UTC](https://discourse.cataclysmdda.org/t/primary-charge-check-for-tools/5937 "2014-04-23T19:53:38Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![BeigeSand](https://avatars.discourse-cdn.com/v4/letter/b/a3d4f5/32.png) [@BeigeSand](https://discourse.cataclysmdda.org/u/BeigeSand)\
**Post date:** [April 23, 2014, 7:53pm UTC](https://discourse.cataclysmdda.org/t/primary-charge-check-for-tools/5937/1 "2014-04-23T19:53:38Z")

</div>

I’m trying to add a mod to tools that allows them to run off of a UPS. There appears to be a generic call for all tools that checks if they have enough charges to perform their function, one being called outside of iuse. I, however cannot find it. I have searched with both the github repository and data files for multiple terms and yet it still eludes me. T\_T (This has happened on multiple occasions)  
If someone could point me towards the correct function/file, I would greatly appreciate it.

---

<div class="post-metadata">

**Author:** ![i2amroy](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/i2amroy/32/909_2.png) [@i2amroy](https://discourse.cataclysmdda.org/u/i2amroy)\
**Post date:** [April 23, 2014, 8:17pm UTC](https://discourse.cataclysmdda.org/t/primary-charge-check-for-tools/5937/2 "2014-04-23T20:17:21Z")

</div>

Do a search for “use.call(”. That should highlight all of the times where an item use function is called, some of which should be where you need to make your changes at.

---

<div class="post-metadata">

**Author:** ![BeigeSand](https://avatars.discourse-cdn.com/v4/letter/b/a3d4f5/32.png) [@BeigeSand](https://discourse.cataclysmdda.org/u/BeigeSand)\
**Post date:** [April 23, 2014, 10:12pm UTC](https://discourse.cataclysmdda.org/t/primary-charge-check-for-tools/5937/3 "2014-04-23T22:12:25Z")

</div>

Still no luck. I found an iuse\_transform method that seemed promising but it still appears to be called after the game checks for charges.

---

<div class="post-metadata">

**Author:** ![i2amroy](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/i2amroy/32/909_2.png) [@i2amroy](https://discourse.cataclysmdda.org/u/i2amroy)\
**Post date:** [April 23, 2014, 11:32pm UTC](https://discourse.cataclysmdda.org/t/primary-charge-check-for-tools/5937/4 "2014-04-23T23:32:32Z")

</div>

So what exactly are the side effects that you are having that are leading you to believe said check exists somewhere in the code?

---

<div class="post-metadata">

**Author:** ![BeigeSand](https://avatars.discourse-cdn.com/v4/letter/b/a3d4f5/32.png) [@BeigeSand](https://discourse.cataclysmdda.org/u/BeigeSand)\
**Post date:** [April 24, 2014, 1:40am UTC](https://discourse.cataclysmdda.org/t/primary-charge-check-for-tools/5937/5 "2014-04-24T01:40:41Z")

</div>

When I go to use an electrical object that I have my mod equipped too, I still get a " your item has 0 charges but needs 1". Even though I have added or checks to all the respective if’s. I’ve even changed the message posted at all the suspect places, but still get this same message.

---

<div class="post-metadata">

**Author:** ![KA101](https://avatars.discourse-cdn.com/v4/letter/k/278dde/32.png) [@KA101](https://discourse.cataclysmdda.org/u/KA101)\
**Post date:** [April 24, 2014, 1:44am UTC](https://discourse.cataclysmdda.org/t/primary-charge-check-for-tools/5937/6 "2014-04-24T01:44:47Z")

</div>

> [@BeigeSand](#):
>
> When I go to use an electrical object that I have my mod equipped too, I still get a " your item has 0 charges but needs 1". Even though I have added or checks to all the respective if’s. I’ve even changed the message posted at all the suspect places, but still get this same message.

Most immediate idea is to search for “charges but needs”. That should give you the message, and from there the check that triggers it?

---

<div class="post-metadata">

**Author:** ![BeigeSand](https://avatars.discourse-cdn.com/v4/letter/b/a3d4f5/32.png) [@BeigeSand](https://discourse.cataclysmdda.org/u/BeigeSand)\
**Post date:** [April 24, 2014, 2:17am UTC](https://discourse.cataclysmdda.org/t/primary-charge-check-for-tools/5937/7 "2014-04-24T02:17:36Z")

</div>

I would assume so, but github search function apparently can’t find those three words side-by-side in all of the code.

---

<div class="post-metadata">

**Author:** ![elauminx](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/elauminx/32/283_2.png) [@elauminx](https://discourse.cataclysmdda.org/u/elauminx)\
**Post date:** [April 24, 2014, 4:10am UTC](https://discourse.cataclysmdda.org/t/primary-charge-check-for-tools/5937/8 "2014-04-24T04:10:28Z")

</div>

```auto
src/player.cpp:8718: "Your %s has %d charges but needs %d.",
```

helpfully useless,  
eai

p.s. player::use function…

---

<div class="post-metadata">

**Author:** ![i2amroy](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/i2amroy/32/909_2.png) [@i2amroy](https://discourse.cataclysmdda.org/u/i2amroy)\
**Post date:** [April 24, 2014, 6:08am UTC](https://discourse.cataclysmdda.org/t/primary-charge-check-for-tools/5937/9 "2014-04-24T06:08:11Z")

</div>

> [@BeigeSand](#):
>
> I would assume so, but github search function apparently can’t find those three words side-by-side in all of the code.

Ah yeah, the github search is horrible. My general method is to just open up all the files in Notepad++ and then do a “find in all open files”, since the github online editor isn’t that great either compared to editing it locally and then pushing your changes through one of the various github-compatible apps.

---

<div class="post-metadata">

**Author:** ![BeigeSand](https://avatars.discourse-cdn.com/v4/letter/b/a3d4f5/32.png) [@BeigeSand](https://discourse.cataclysmdda.org/u/BeigeSand)\
**Post date:** [April 24, 2014, 11:23am UTC](https://discourse.cataclysmdda.org/t/primary-charge-check-for-tools/5937/10 "2014-04-24T11:23:03Z")

</div>

[quote=“elauminx, post:8, topic:5937”]`
src/player.cpp:8718: "Your %s has %d charges but needs %d.",
`

helpfully useless,  
eai

p.s. player::use function…[/quote]  
That… Is exactly what I was looking for. Bless your face, sir.
