How do you ReflectType on a string?

#1

Code: Select all

struct SGeneralProperties { //Allow items to be compared with if statements inline bool operator==(const SGeneralProperties& rhs) const { return 0 == memcmp(this, &rhs, sizeof(rhs)); } inline bool operator!=(const SGeneralProperties& rhs) const { return 0 != memcmp(this, &rhs, sizeof(rhs)); } string sItemName, sItemDesc, sPickupMsg; }; static void ReflectType(Schematyc::CTypeDesc<SGeneralProperties>& desc) { desc.SetGUID("{D6309FAC-0129-4558-B0D8-403B779517F0}"_cry_guid); desc.SetLabel("General Properties"); desc.SetDescription("General properties"); desc.AddMember(&SGeneralProperties::sItemName, 'inam', "ItemName", "Item Name", "Name of this item.", ""); desc.AddMember(&SGeneralProperties::sItemDesc, 'ides', "ItemDesc", "Item Desc", "Description of this item.", ""); desc.AddMember(&SGeneralProperties::sPickupMsg, 'pmsg', "PickupMsg", "Pickup Message", "Message shown when an item can be picked up.", ""); }
Doesn't work because the sItemName, sItemDesc and sPickupMsg are strings. If I change them to int's for example the code compiles fine. When I try and compile them as strings I get this error

Reflection/TypeDesc.h(563): error C2338: Type must be reflected, see TypeDesc.h for details!
1>c:\users\test\documents\cryengine projects\survival\code\components\ItemProperties.h(75): note: see reference to function template instantiation 'Schematyc::CClassMemberDesc &Schematyc::CClassDescInterface<TYPE,Schematyc::CClassDesc>::AddMember<string,char[1],SGeneralProperties>(MEMBER_TYPE SGeneralProperties::* ,uint32,const char *,const char *,const char *,const MEMBER_DEFAULT_VALUE_TYPE (&))' being compiled
with
[
TYPE=SGeneralProperties,
MEMBER_TYPE=string,
MEMBER_DEFAULT_VALUE_TYPE=char [1]
]

Re: How do you ReflectType on a string?

#4
There is no possibility to do that. I tried everything, and stting won't work. But with the item name, you should change name of your item component simply in schematyc, and them in c++ go


CYourComponent *pointer = m_pEntity->GetComponent <CYourComponent>();

pointer->GetName ();
Hey Fury I'm actually watching your tutorials on building an RPG! Great work by the way I'm loving them so far.

I'll just stick with the method you use in your video for now!

Thanks for your help.

Who is online

Users browsing this forum: No registered users and 2 guests