How would I carry over a network value through a duplication?

Hello, I’ve been working on coding a large addon for the past week and have been plowing along, but I’ve become stumped recently and was wondering if anyone here could help me.

In my addon I can link my gun, ammo, etc entities to engine entities with a custom linking stool i coded up. It works by setting the gun/ammo/etc’s engine network var to the engine i select with the tool.

Its been quite fine until I realized that those network vars don’t carry over when I duplicate the entity and spawn another, making me have to relink everything, which I’d like to avoid that being a requirement.

I’ve tried looking up issues like this on this site already but search results bring up information that isn’t very relevant and I haven’t been able to find what I’m looking for in the wikia. I’ve also been coding two days at a time then sleeping half a day so my brain is rather fried and could use your help.

I’ve seen that function but I can’t figure out how to properly use it for the variables I’m storing.

Look up how default tools use the function and figure it out.

None of the default tools have any network variables like I’m trying to use, which is why I’m here asking if anyone has come up with things on their own or has ideas to brainstorm with me. I have been and will continue to try and figure it out myself, but more heads, especially ones with more than a week of LUA experience like me, should be helpful.

If you can’t put the two and two together, I am afraid I cannot help you. You are not looking at this the right way, it’s not about the fact that what you are trying to save are “network vars”. You can save whatever you want. Just look how the color/trail tools save the stuff and how they restore the stuff.

I think he wants to know which table the network/dtvars are stored in for an entity, rather than making a copy of the value and using another variable for the sole purpose of saving it.

NetworkVars/DTVars are saved automatically for you.

The problem has been solved. I asked one of my friends who worked on ACF about the linking setup and he told me to check in their entity files to see how they stored the links.

I needed the PreEntityCopy and PostEntityPaste functions. In the pre copy function I got the ent ID of the linked entity and stored it as an entity modifier. In the post paste function I went through CreatedEntities to find the new entity that reflected the saved ID then set that entity to be set as the duped entity’s networked entity variable.

The network variables were saved, of course, but needed to be set again when the entity was recreated.