SciGuy42 Posted November 5, 2021 Report Share Posted November 5, 2021 I am trying to upgrade my campaign to a25 and have found that OnRange triggers must have changed somehow. I first defined the trigger using the following code: cmpTrigger.RegisterTrigger("OnRange", "RangeAction", { "entities": cmpTrigger.GetTriggerPoints("A"), // central points to calculate the range circles "players": [1], // only count entities of player 1 "maxRange": 40, "requiredComponent": IID_UnitAI, // only count units in range "enabled": true, }); I have a simple RangeAction defined as: Trigger.prototype.RangeAction = function(data) { warn("The OnRange event happened with the following data:"); warn(uneval(data)); }; When I load the scenario I get no errors upon loading but then when I move the unit close to the trigger point, I get the following error: WARNING: Trigger.js: called a trigger 'RangeAction' for event 'OnRange' that wasn't found Note that I am following the example in: /maps/scenarios/trigger_demo.js I cannot spot any difference between how the trigger_demo.js uses the OnRange trigger and mine. Any clues? I am also including the .js file here. Macedonia_2.js Quote Link to comment Share on other sites More sharing options...
SciGuy42 Posted November 5, 2021 Author Report Share Posted November 5, 2021 Unfortunately I am also having trouble with the simple IntervalAction trigger. I register the trigger as per the tutorial with no issues: cmpTrigger.RegisterTrigger("OnInterval", "IntervalAction", { "enabled": true, "delay": 10 * 1000, "interval": 5 * 1000, }); The action is defined as: Trigger.prototype.IntervalAction = function(data) { warn("The OnInterval event happened with the following data:"); warn(uneval(data)); }; Then 10 seconds in the game, I get this error: WARNING: Trigger.js: called a trigger action 'undefined' that wasn't found I think I followed everything from the trigger_demo.js example to the tee as before. Quote Link to comment Share on other sites More sharing options...
Stan` Posted November 5, 2021 Report Share Posted November 5, 2021 There was https://code.wildfiregames.com/D3979 https://code.wildfiregames.com/D3904 Does it work if you remove Action from IntervalAction? I suppose wraitii may have forgotten to update the maps... Quote Link to comment Share on other sites More sharing options...
Silier Posted November 5, 2021 Report Share Posted November 5, 2021 Reproduced, thnx Quote Link to comment Share on other sites More sharing options...
Silier Posted November 5, 2021 Report Share Posted November 5, 2021 https://code.wildfiregames.com/D4335 1 Quote Link to comment Share on other sites More sharing options...
nwtour Posted November 5, 2021 Report Share Posted November 5, 2021 (edited) @SciGuy42 FYI You need to put the new version in the mod folder (To make it work in the release version) simulation/components/Trigger.js Trigger.js Edited November 5, 2021 by nwtour Quote Link to comment Share on other sites More sharing options...
SciGuy42 Posted November 5, 2021 Author Report Share Posted November 5, 2021 24 minutes ago, nwtour said: @SciGuy42 FYI You need to put the new version in the mod folder (To make it work in the release version) simulation/components/Trigger.js Trigger.js 10 kB · 0 downloads Thanks, the interval action now seems to be working as expected. However, the OnRange trigger is still giving me the same error once the unit gets close to the trigger point: WARNING: Trigger.js: called a trigger 'RangeAction' for event 'OnRange' that wasn't found!!! I added the !!! at the end just to verify that it is using the new file. Quote Link to comment Share on other sites More sharing options...
SciGuy42 Posted November 5, 2021 Author Report Share Posted November 5, 2021 I also tested the trigger demo scenario. Before I replaced the Trigger.js file, I was getting errors, now the errors are gone except for the OnRange trigger in that example scenario. Quote Link to comment Share on other sites More sharing options...
SciGuy42 Posted November 5, 2021 Author Report Share Posted November 5, 2021 1 hour ago, Stan` said: There was https://code.wildfiregames.com/D3979 https://code.wildfiregames.com/D3904 Does it work if you remove Action from IntervalAction? I suppose wraitii may have forgotten to update the maps... Do you mean remove the word Action when registering the trigger but still keep the function as RangeAction? Or remove Action from both the name when registering the trigger as well as from the function name? Quote Link to comment Share on other sites More sharing options...
Silier Posted November 5, 2021 Report Share Posted November 5, 2021 14 minutes ago, SciGuy42 said: I also tested the trigger demo scenario. Before I replaced the Trigger.js file, I was getting errors, now the errors are gone except for the OnRange trigger in that example scenario. Fixed https://code.wildfiregames.com/D4335 Quote Link to comment Share on other sites More sharing options...
SciGuy42 Posted November 5, 2021 Author Report Share Posted November 5, 2021 7 minutes ago, Silier said: Fixed https://code.wildfiregames.com/D4335 I assume I had to replace with the file on the right. After I did that, I am now getting the following error when a unit gets close to the trigger point, tested with both my scenario and the Trigger Demo: ERROR: JavaScript error: simulation/components/Trigger.js line 346 this.triggers.triggers is undefined Trigger.prototype.CallTrigger@simulation/components/Trigger.js:346:6 TriggerPoint.prototype.OnRangeUpdate@simulation/components/TriggerPoint.js:75:13 Quote Link to comment Share on other sites More sharing options...
Silier Posted November 5, 2021 Report Share Posted November 5, 2021 Can you change line 346 like this? if (!this.triggers[event]?.[name]) 1 Quote Link to comment Share on other sites More sharing options...
SciGuy42 Posted November 5, 2021 Author Report Share Posted November 5, 2021 (edited) 5 minutes ago, Silier said: Can you change line 346 like this? if (!this.triggers[event]?.[name]) Great, it now works! Now back to the conversion, will report any other bugs if I encounter them. Edited November 5, 2021 by SciGuy42 1 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.