Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit e4e7402

Browse files
committed
Properly actually fixed attachable scripts running when their parent didn't really exist
Added lua binding for SoundContainer::SelectNextSoundSet
1 parent cdd868d commit e4e7402

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Entities/Attachable.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ void Attachable::Attach(MOSRotating *pParent)
274274
// Reset the attachables timers so things that have been sitting in inventory don't make backed up emissions
275275
ResetAllTimers();
276276

277-
if (m_pParent != NULL && (!m_pParent->HasAnyScripts() || m_pParent->ObjectScriptsInitialized())) {
277+
if (m_pParent != NULL && m_pParent->GetID() != 255) {
278278
RunScriptedFunctionInAppropriateScripts("OnAttach", false, false, {m_pParent});
279279
}
280280
}
@@ -306,7 +306,7 @@ void Attachable::Detach()
306306

307307
m_RestTimer.Reset();
308308

309-
if (temporaryParent != NULL && (!temporaryParent->HasAnyScripts() || temporaryParent->ObjectScriptsInitialized())) {
309+
if (temporaryParent != NULL && temporaryParent->GetID() != 255) {
310310
RunScriptedFunctionInAppropriateScripts("OnDetach", false, false, {temporaryParent});
311311
}
312312
}
@@ -554,7 +554,7 @@ void Attachable::Update()
554554
MOSRotating::Update();
555555

556556
// If we're attached to something, MoveableMan doesn't own us, and therefore isn't calling our ScriptUpdate (and our parent isn't calling it either), so we should here
557-
if (m_pParent != NULL && (!m_pParent->HasAnyScripts() || m_pParent->ObjectScriptsInitialized())) { UpdateScripts(); }
557+
if (m_pParent != NULL && m_pParent->GetID() != 255) { UpdateScripts(); }
558558
}
559559

560560

Managers/LuaMan.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ int LuaMan::Create()
568568
.def("AddSound", (void (SoundContainer:: *)(std::string const &soundFilePath, const Vector &offset, float attenuationStartDistance, bool abortGameForInvalidSound)) &SoundContainer::AddSound)
569569
.def("AddSound", (void (SoundContainer:: *)(std::string const &soundFilePath, unsigned int soundSetIndex, const Vector &offset, float minimumAudibleDistance, float attenuationStartDistance, bool abortGameForInvalidSound)) &SoundContainer::AddSound)
570570
.def("SetPosition", &SoundContainer::SetPosition)
571+
.def("SelectNextSoundSet", &SoundContainer::SelectNextSoundSet)
571572
.property("Loops", &SoundContainer::GetLoopSetting, &SoundContainer::SetLoopSetting)
572573
.property("Priority", &SoundContainer::GetPriority, &SoundContainer::SetPriority)
573574
.property("AffectedByGlobalPitch", &SoundContainer::IsAffectedByGlobalPitch, &SoundContainer::SetAffectedByGlobalPitch),

0 commit comments

Comments
 (0)