# How do I change Data Table row with an input?

**URL:** <https://forums.unrealengine.com/t/how-do-i-change-data-table-row-with-an-input/471442>\
**Category:** AI\
**Tags:** data, Struct, table, unreal-engine, question\
**Created:** [September 16, 2020, 3:32pm UTC](https://forums.unrealengine.com/t/how-do-i-change-data-table-row-with-an-input/471442 "2020-09-16T15:32:48Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gisbitus](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gisbitus](https://forums.unrealengine.com/u/Gisbitus)\
**Post date:** [September 16, 2020, 3:32pm UTC](https://forums.unrealengine.com/t/how-do-i-change-data-table-row-with-an-input/471442/1 "2020-09-16T15:32:48Z")

</div>

What I’m trying to do is a weapon system where there’s just one weapon blueprint and a structure with all the weapon data. When I change weapon with an input I want to select the correct row in the data table, so I can get the weapon data. If you look at the screenshot, I just need something to plug into the Row Name to change it.

 ![313808-screenshot-2020-09-16-173200.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/2/4/424479fb74915603c047169333f56b130910bf5d.png)

How do I do that?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [September 16, 2020, 5:24pm UTC](https://forums.unrealengine.com/t/how-do-i-change-data-table-row-with-an-input/471442/2 "2020-09-16T17:24:23Z")

</div>

How are we selecting the _right_ weapon? Are you requesting a specific weapon or cycling through the stuff in the DT? How do I know which name to pull?

---

<div class="post-metadata">

**Author:** ![Gisbitus](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gisbitus](https://forums.unrealengine.com/u/Gisbitus)\
**Post date:** [September 16, 2020, 6:06pm UTC](https://forums.unrealengine.com/t/how-do-i-change-data-table-row-with-an-input/471442/3 "2020-09-16T18:06:52Z")

</div>

I wish to select a specific weapon. On input I’d want the row name to change to the other weapon that I have on me.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [September 16, 2020, 6:25pm UTC](https://forums.unrealengine.com/t/how-do-i-change-data-table-row-with-an-input/471442/4 "2020-09-16T18:25:53Z")

</div>

So _the other weapon you have on you_ - it sure has the name you need, right? Pull it out of the weapon and query the DT.

Would that work?

* * *

If in doubt, do explain how the weapons are stored on the player. But most importantly: why do we even need to do this? Wouldn’t it be more logical if every weapon had its own data rather then pull it out of a DT every time you need to use one?

Or is this some kind of advanced mechanics where the weapons are highly customisation and / or modifiable.

* * *

Generally speaking, you query the DT for the name and make an Actor out of that data. Not the other way round…

---

<div class="post-metadata">

**Author:** ![Gisbitus](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gisbitus](https://forums.unrealengine.com/u/Gisbitus)\
**Post date:** [September 16, 2020, 6:34pm UTC](https://forums.unrealengine.com/t/how-do-i-change-data-table-row-with-an-input/471442/5 "2020-09-16T18:34:27Z")

</div>

Alright maybe I haven’t explained myself all too well, sorry, I’m very new to this. I saw people recommend to create a weapon system based on DT from this thread:

> **[Better way to switch weapon : switch BP or meshes ?](https://forums.unrealengine.com/questions/890480/better-way-to-switch-weapon-switch-bp-or-meshes.html)**
>
> Hello, I am doing a multiplayer game and I was wondering what is better between creating a blueprint for each different weapon or creating only one weapon blueprint and change mesh each time we change weapon. First, I thought to create only one...

This is what I’m trying to do, but being that the answer didn’t go in depth as to how to actually implement it, I’ve gone through that on my own, but I’m not even sure if I’m doing the right things. If you think this is an actually decent system to use, then I’ll go ahead and explain what I’ve done so far, so that you can figure out what’s left to do. Otherwise, I’ll just switch to a more optimal system.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [September 16, 2020, 6:46pm UTC](https://forums.unrealengine.com/t/how-do-i-change-data-table-row-with-an-input/471442/6 "2020-09-16T18:46:32Z")

</div>

> I’d want the row name to change to the  
> other weapon that I have on me

So how does the player end with specific weapons in the first place? Each weapons is an actor that gets spawned?

---

<div class="post-metadata">

**Author:** ![Gisbitus](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gisbitus](https://forums.unrealengine.com/u/Gisbitus)\
**Post date:** [September 16, 2020, 6:53pm UTC](https://forums.unrealengine.com/t/how-do-i-change-data-table-row-with-an-input/471442/7 "2020-09-16T18:53:49Z")

</div>

Yes. There’s a master blueprint for how weapons work, a parent class and child blueprints. That way, when you switch weapon, you’re only changing the weapon’s mesh and changing the weapon stats that are contained inside the struct I created. Really cumbersome for 2 weapons, but good for large amounts.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [September 16, 2020, 7:02pm UTC](https://forums.unrealengine.com/t/how-do-i-change-data-table-row-with-an-input/471442/8 "2020-09-16T19:02:38Z")

</div>

Makes sense, so what is stopping you from storing 2 currently equipped weapon names on the player?

[edited for a more relevant screenshot]

 ![313874-screenshot-2020-09-16-200640.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/d/e/9de48cb2dad292dd3ee4004755837da9a22b00e4.jpeg)

---

<div class="post-metadata">

**Author:** ![sling5hot](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@sling5hot](https://forums.unrealengine.com/u/sling5hot)\
**Post date:** [September 16, 2020, 8:16pm UTC](https://forums.unrealengine.com/t/how-do-i-change-data-table-row-with-an-input/471442/9 "2020-09-16T20:16:18Z")

</div>

you could do it like that  
  
get Datatable row names array length  
  
get ref from the the same array and set the index to the previous index+1/-1  
  
plug the ref into row name.

 ![313881-sharedscreenshot.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/a/1/ba12addfa3118698c2794de1a1f32ec36ba89e57.jpeg)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [September 16, 2020, 8:24pm UTC](https://forums.unrealengine.com/t/how-do-i-change-data-table-row-with-an-input/471442/10 "2020-09-16T20:24:14Z")

</div>

OP is switching between 2 weapons they already have. You’re cycling through the entire DT…

---

<div class="post-metadata">

**Author:** ![sling5hot](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@sling5hot](https://forums.unrealengine.com/u/sling5hot)\
**Post date:** [September 16, 2020, 8:30pm UTC](https://forums.unrealengine.com/t/how-do-i-change-data-table-row-with-an-input/471442/11 "2020-09-16T20:30:11Z")

</div>

what if he added a third one?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [September 16, 2020, 8:33pm UTC](https://forums.unrealengine.com/t/how-do-i-change-data-table-row-with-an-input/471442/12 "2020-09-16T20:33:03Z")

</div>

They will _still_ not want to cycle through the _entire_ Data Table, surely (where there can be 50+ guns) but get 1 out of 3 instead. Probably like this:

 ![313882-screenshot-2020-09-16-213751.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/d/8/1d83d9424edef28852754042fe3b797614637487.jpeg)

Besides, the weapon is already equipped, the goal is to search by specific `Name`

You could keep names in a Map; there’s dozens of options here. But why complicate things. 😑

---

<div class="post-metadata">

**Author:** ![sling5hot](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@sling5hot](https://forums.unrealengine.com/u/sling5hot)\
**Post date:** [September 16, 2020, 8:43pm UTC](https://forums.unrealengine.com/t/how-do-i-change-data-table-row-with-an-input/471442/13 "2020-09-16T20:43:48Z")

</div>

ok ,i see.
