# Code Help (Currently Solved)

**URL:** <https://discourse.cataclysmdda.org/t/code-help-currently-solved/1394>\
**Category:** The Toolbox\
**Created:** [May 23, 2013, 2:43am UTC](https://discourse.cataclysmdda.org/t/code-help-currently-solved/1394 "2013-05-23T02:43:09Z")\
**Posts on this page:** 9\
**Page:** 1

<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:** [May 23, 2013, 2:43am UTC](https://discourse.cataclysmdda.org/t/code-help-currently-solved/1394/1 "2013-05-23T02:43:09Z")

</div>

So right now I’m working on a small light rework so that flags like LIGHT\_4 actually have an effect without needing to be hacked into the game, but I’ve run into a small problem.

Here is the important part of my code right now:

[code] std::vector\<item\*\> inv\_active = inv.active\_items();  
for (std::vector\<item\*\>::iterator iter = inv\_active.begin(); iter != inv\_active.end(); ++iter)  
{  
item \*tmp\_it = \*iter;  
temp\_lumination = 0;

```
    if (tmp_it->has_flag("LIGHT_4")) {temp_lumination = 20;}

    int charges = active_item_charges("flashlight_on");
    if (tmp_it->has_flag("LIGHT_CHARGES_5") && charges * 5 < temp_lumination) {temp_lumination = charges * 5;}

    if (temp_lumination > lumination) {lumination = temp_lumination;}
}[/code]

```

The code above should iterate through a list of all of the active items, determine the current light value based on the iteration item, and then if that is above the current maximum it sets it as the new maximum. The problem comes in: `active_item_charges("flashlight_on");` This line should use the current iteration item’s id, however I am unable to figure out how to retrieve the iteration item’s id. If anybody has a pointer method that will solve this problem (or an alternate method to get the charges of the iteration item) I would be very grateful for some advice.

---

<div class="post-metadata">

**Author:** ![Soron](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/soron/32/885_2.png) [@Soron](https://discourse.cataclysmdda.org/u/Soron)\
**Post date:** [May 23, 2013, 2:46am UTC](https://discourse.cataclysmdda.org/t/code-help-currently-solved/1394/2 "2013-05-23T02:46:20Z")

</div>

```auto

That should do the trick.
```

That should do the trick.

---

<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:** [May 23, 2013, 2:52am UTC](https://discourse.cataclysmdda.org/t/code-help-currently-solved/1394/3 "2013-05-23T02:52:56Z")

</div>

Sweet, Thank you.

---

<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:** [June 5, 2013, 6:48am UTC](https://discourse.cataclysmdda.org/t/code-help-currently-solved/1394/4 "2013-06-05T06:48:15Z")

</div>

New question!  
In C++ are you allowed to call non-void functions without having something to store the returned value in?

For example:

[code]int bob()  
{  
return 2  
}

void main()  
{  
bob()  
}[/code]  
Or would that last line need to be something like “temp = bob()”?

---

<div class="post-metadata">

**Author:** ![utunnels](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/utunnels/32/81_2.png) [@utunnels](https://discourse.cataclysmdda.org/u/utunnels)\
**Post date:** [June 5, 2013, 6:52am UTC](https://discourse.cataclysmdda.org/t/code-help-currently-solved/1394/5 "2013-06-05T06:52:11Z")

</div>

Yes.

---

<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:** [June 5, 2013, 6:54am UTC](https://discourse.cataclysmdda.org/t/code-help-currently-solved/1394/6 "2013-06-05T06:54:40Z")

</div>

Yes I can call it without storing the value? Or yes I need to store the value?

---

<div class="post-metadata">

**Author:** ![utunnels](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/utunnels/32/81_2.png) [@utunnels](https://discourse.cataclysmdda.org/u/utunnels)\
**Post date:** [June 5, 2013, 6:56am UTC](https://discourse.cataclysmdda.org/t/code-help-currently-solved/1394/7 "2013-06-05T06:56:57Z")

</div>

I mean no, you don’t need to.  
😛

---

<div class="post-metadata">

**Author:** ![Soron](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/soron/32/885_2.png) [@Soron](https://discourse.cataclysmdda.org/u/Soron)\
**Post date:** [June 5, 2013, 6:57am UTC](https://discourse.cataclysmdda.org/t/code-help-currently-solved/1394/8 "2013-06-05T06:57:38Z")

</div>

It’s very common to call non-void functions by themselves, since often times the return value isn’t something you need to care about.

---

<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:** [June 5, 2013, 6:58am UTC](https://discourse.cataclysmdda.org/t/code-help-currently-solved/1394/9 "2013-06-05T06:58:28Z")

</div>

> [@Soron](#):
>
> It’s very common to call non-void functions by themselves, since often times the return value isn’t something you need to care about.

Ok cool, makes fixing the “gets deep bite wound when armor absorbs all the damage” much easier. 🙂
