Tomb-Editor icon indicating copy to clipboard operation
Tomb-Editor copied to clipboard

TEN/LUA - Hub data / OnEnd issues

Open AkyV opened this issue 5 months ago • 2 comments

Hello! I’ve made some tests with GameVars variables value to understand that how OnEnd works exactly. I’ve got numerous awful test results…

ENDREASON TEST

Test1.lua:

  • GameVars.testVar value set in an OnLoop moment. (Moment is defined as „a” value, based on a = a + 1 loop operation.)
  • Another GameVars.testVar value set in OnEnd, also using TEN.Logic.EndReason constants (if… then) to change OnLoop variable value.

Test2.lua:

  • ShowString (in loop callback) to print GameVars.testVar value.

Title.lua:

  • ShowString (in loop „ControlPhase” callback) to print GameVars.testVar value.

Tested situations, on Test1:

  • Finish trigger to Test2
  • Savegame load to Test2
  • Finish trigger to title
  • From Pause menu to title
  • Lara’s death to title

Results:

  • EndReason.LEVELCOMPLETE: After Finish trigger, Test1 OnEnd value is printed in Test2. (Passed.)
  • EndReason.LOADGAME: After Finish trigger, Test1 OnLoop value is printed in Test2. (Passed.) Now I save SaveX. Then Finish of Test2 loads back to Test 1. Now I load Save X, back to Test2, still Test1 OnLoop value is printed. (If I understand LOADGAME exactly, then it is a failed test then. I mean, under any other circumstances, it seems logical that the saved Test1 OnLoop value is loaded – except now, Test1 OnEnd value should be printed. Which means if LOADGAME would work well, then I shouldn’t run OnEnd without an EndReason constant, otherwise I may ruin saved values unintentionally.) Maybe it also connected to HUB DATA TEST (see below).
  • EndReason.EXITTOTITLE: After Finish trigger/Pause menu, there is no value printed in title. Log says: „[error] Could not execute function: ../../Scripts\Levels\title.lua:21: attempt to call a nil value (global 'toString')” (Failed.)
  • EndReason.DEATH: After Lara’s death and loading title, there is no value printed in title. Log says: „[error] Could not execute function: ../../Scripts\Levels\title.lua:21: attempt to call a nil value (global 'toString')” (Failed.)
  • EndReason.OTHER: it must be a custom value, I cannot get it now.

HUB DATA TEST Test1.lua:

  • GameVars.testVar value set at a=1 OnLoop moment. (Moment is defined as „a” value, based on a = a + 1 loop operation.)
  • Another GameVars.testVar value set at a=100 OnLoop moment. (Moment is defined as „a” value, based on a = a + 1 loop operation.) 100 is random now.

Test2.lua:

  • ShowString (in loop callback) to print GameVars.testVar value.

Tested situation, from Test1: Some moments after starting Test1 (so when a=100 value is just set) a Finish trigger loads to Test2. This a=100 value is printed now. (Passed.) Then a Finish of this level loads back to Test1. OnLoop a=1 moment changes the value. Very fast (so when the value is still at a=1 value) I load back to Test2, with the same Finish as before. I expect that a=1 value will be printed, but still a=100 value printed instead. (Failed.) (I tried with both Lara and Lara_Start_Pos, when loading back to Test1.)

Conclusion (I think): You can't take over a GameVars variable value from Level A to Level B if Level B already has a value for that variable from a previous visit of Lara there. However, you can still change that variable value on Level B. (And, as you see above, I can't take a GameVars variable value into the title, at all. Or, vice verse, anyway, from title to level.)


Maybe it is all connected to this issue: https://github.com/MontyTRC89/Tomb-Editor/issues/855

AkyV avatar Aug 30 '24 19:08 AkyV