Skip to content

Commit

Permalink
Merge pull request #449 from Sombra0xCC/script_ref
Browse files Browse the repository at this point in the history
implicit casting ClassReference to script_ref
  • Loading branch information
Yamashi authored Jan 30, 2021
2 parents 90b8595 + ba2f1ae commit 44bb8de
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/scripting/Scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,18 @@ RED4ext::CStackType Scripting::ToRED(sol::object aObject, RED4ext::IRTTIType* ap

result.value = pMemory;
}
else if (apRttiType->GetType() == RED4ext::ERTTIType::ScriptReference)
{
if (aObject.is<ClassReference>())
{
auto* pClassRef = aObject.as<ClassReference*>();
auto* pScriptRef = apAllocator->New<RED4ext::ScriptRef<void>>();
pScriptRef->innerType = pClassRef->m_pType;
pScriptRef->ref = pClassRef->GetHandle();
apRttiType->GetName(pScriptRef->hash);
result.value = pScriptRef;
}
}
else
{
return Converter::ToRED(aObject, apRttiType, apAllocator);
Expand Down
3 changes: 2 additions & 1 deletion src/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
#include <RED4ext/CString.hpp>
#include <RED4ext/ISerializable.hpp>
#include <RED4ext/Types/InstanceType.hpp>
#include <RED4ext/Types/SimpleTypes.hpp>
#include <RED4ext/Types/CharacterCustomization.hpp>
#include <RED4ext/RTTISystem.hpp>
#include <RED4ext/RTTITypes.hpp>
#include <RED4ext/GameEngine.hpp>
#include <RED4ext/Scripting/Stack.hpp>
#include <RED4ext/Scripting/CProperty.hpp>
#include <RED4ext/Scripting/Functions.hpp>
#include <RED4ext/Types/CharacterCustomization.hpp>
#include <RED4ext/IMemoryAllocator.hpp>

#include <filesystem>
Expand Down

0 comments on commit 44bb8de

Please sign in to comment.