@@ -11,19 +11,19 @@ To create your own service, you have to define a class derived from `ScriptableS
1111``` swift
1212class MyService extends ScriptableService {
1313 private cb func OnLoad () {
14- LogChannel (n " DEBUG " , " Scripts loaded" );
14+ FTLog ( " Scripts loaded" );
1515 }
1616
1717 private cb func OnReload () {
18- LogChannel (n " DEBUG " , " Scripts reloaded" );
18+ FTLog ( " Scripts reloaded" );
1919 }
2020
2121 private cb func OnInitialize () {
22- LogChannel (n " DEBUG " , " Game instance initialized, can access game systems" );
22+ FTLog ( " Game instance initialized, can access game systems" );
2323 }
2424
2525 private cb func OnUninitialize () {
26- LogChannel (n " DEBUG " , " Game is shutting down" );
26+ FTLog ( " Game is shutting down" );
2727 }
2828}
2929```
@@ -59,7 +59,7 @@ class MyService extends ScriptableService {
5959
6060 private cb func OnLoad () {
6161 this.stats .counter += 1 ;
62- LogChannel (n " DEBUG " , s" The game launched \( this.stats .counter ) time(s) since installing the mod" );
62+ FTLog ( s" The game launched \( this.stats .counter ) time(s) since installing the mod" );
6363 }
6464}
6565```
@@ -155,7 +155,7 @@ class MySystem extends ScriptableSystem {
155155 }
156156
157157 private cb func OnPanamFirstSpawn (event : ref<EntityLifecycleEvent>) {
158- LogChannel (n " DEBUG " , " Panam spawned" );
158+ FTLog ( " Panam spawned" );
159159 }
160160}
161161```
@@ -176,7 +176,7 @@ class MySystem extends ScriptableSystem {
176176 }
177177
178178 private cb func OnKeyInput (evt : ref<KeyInputEvent>) {
179- LogChannel (n " DEBUG " , s" Pressed \( evt.GetKey () ) " );
179+ FTLog ( s" Pressed \( evt.GetKey () ) " );
180180 }
181181}
182182```
@@ -223,7 +223,7 @@ class CustomEventListener extends ScriptableService {
223223 }
224224
225225 private cb func OnCustomEvent (event : ref<CustomEvent>) {
226- LogChannel (n " DEBUG " , s" \( event.GetEventName () ) \( event.GetData () ) " );
226+ FTLog ( s" \( event.GetEventName () ) \( event.GetData () ) " );
227227 }
228228}
229229```
@@ -316,11 +316,11 @@ class MySpawnHandler extends ScriptableSystem {
316316 }
317317
318318 private cb func OnEntityAttached (event : ref<EntityLifecycleEvent>) {
319- LogChannel (n " DEBUG " , s" Entity Attached \( EntityID.GetHash (event.GetEntity ().GetEntityID ()) ) " );
319+ FTLog ( s" Entity Attached \( EntityID.GetHash (event.GetEntity ().GetEntityID ()) ) " );
320320 }
321321
322322 private cb func OnEntityDetached (event : ref<EntityLifecycleEvent>) {
323- LogChannel (n " DEBUG " , s" Entity Detached \( EntityID.GetHash (event.GetEntity ().GetEntityID ()) ) " );
323+ FTLog ( s" Entity Detached \( EntityID.GetHash (event.GetEntity ().GetEntityID ()) ) " );
324324 }
325325
326326 private func HandleSpawning () {
@@ -329,21 +329,21 @@ class MySpawnHandler extends ScriptableSystem {
329329
330330 // Simple check if we're in the main menu world.
331331 if GameInstance.GetSystemRequestsHandler ().IsPreGame () {
332- LogChannel (n " DEBUG " , " We're in main menu" );
332+ FTLog ( " We're in main menu" );
333333 return ;
334334 }
335335
336336 // Check if entities with MyMod tag already present in the system.
337337 // Since we spawn persistent entities, they will be restored for a playthrough,
338338 // in which we already spawned our entities once.
339339 if this.m_entitySystem.IsPopulated (n" MyMod" ) {
340- LogChannel (n " DEBUG " , " Entities restored" );
340+ FTLog ( " Entities restored" );
341341 return ;
342342 }
343343
344344 // Extra check if there's enough space in front of the player to spawn our entities.
345345 if ! this.HasSpaceForSpawning () {
346- LogChannel (n " DEBUG " , " Can't create entities, there's no space" );
346+ FTLog ( " Can't create entities, there's no space" );
347347 return ;
348348 }
349349
@@ -377,7 +377,7 @@ class MySpawnHandler extends ScriptableSystem {
377377 this.m_entitySystem .CreateEntity (carSpec);
378378 this.m_entitySystem .CreateEntity (deviceSpec);
379379
380- LogChannel (n " DEBUG " , " Entities created" );
380+ FTLog ( " Entities created" );
381381 }
382382
383383 private func HasSpaceForSpawning () -> Bool {
@@ -529,7 +529,7 @@ You can get path to entity template used to create entity:
529529let player = GetPlayer (GetGameInstance ());
530530let template = entity.GetTemplatePath ();
531531
532- LogChannel (n " DEBUG " , s" Entity Template: \( ResRef.GetHash (template) ) " );
532+ FTLog ( s" Entity Template: \( ResRef.GetHash (template) ) " );
533533```
534534
535535### Components
@@ -541,7 +541,7 @@ let player = GetPlayer(GetGameInstance());
541541let components = player.GetComponents ();
542542
543543for component in components {
544- LogChannel (n " DEBUG " , s" Component: \( component.GetName () ) \( component.GetClassName () ) " );
544+ FTLog ( s" Component: \( component.GetName () ) \( component.GetClassName () ) " );
545545}
546546```
547547
@@ -659,7 +659,7 @@ let inkSystem = GameInstance.GetInkSystem();
659659let layers = inkSystem.GetLayers ();
660660
661661for layer in layers {
662- LogChannel (n " DEBUG " , s" UI Layer: \( layer.GetLayerName () ) \( layer.GetGameController ().GetClassName () ) " );
662+ FTLog ( s" UI Layer: \( layer.GetLayerName () ) \( layer.GetGameController ().GetClassName () ) " );
663663}
664664```
665665
@@ -671,7 +671,7 @@ let layers = inkSystem.GetLayers();
671671
672672for layer in layers {
673673 for controller in layer.GetGameControllers () {
674- LogChannel (n " DEBUG " , s" Game Controller: \( controller.GetClassName () ) " );
674+ FTLog ( s" Game Controller: \( controller.GetClassName () ) " );
675675 }
676676}
677677```
@@ -801,8 +801,8 @@ Reference can be initialized by assigning a resource path using `*=` operator:
801801let weapon = new WeaponObject ();
802802weapon.effect *= r" base\\ gameplay\\ game_effects\\ strongmelee.es" ;
803803
804- LogChannel (n " DEBUG " , s" Hash: \( ResourceRef.GetHash (weapon.effect ) ) " );
805- LogChannel (n " DEBUG " , s" Loaded: \( ResourceRef.IsLoaded (weapon.effect ) ) " );
804+ FTLog ( s" Hash: \( ResourceRef.GetHash (weapon.effect ) ) " );
805+ FTLog ( s" Loaded: \( ResourceRef.IsLoaded (weapon.effect ) ) " );
806806```
807807
808808### Checking resource existence
@@ -814,7 +814,7 @@ For example, you can use to check if mod is intalled correctly:
814814``` swift
815815let depot = GameInstance.GetResourceDepot ();
816816if ! depot.ArchiveExists (" MyMod.archive" ) {
817- LogChannel (n " DEBUG " , " MyMod.archive not found. Did you enable mods?" );
817+ FTLog ( " MyMod.archive not found. Did you enable mods?" );
818818}
819819```
820820
@@ -823,7 +823,7 @@ Or to handle compatibility with another mod:
823823``` swift
824824let depot = GameInstance.GetResourceDepot ();
825825if depot.ResourceExists (r" mod\\ entities\\ vehicle.ent" ) {
826- LogChannel (n " DEBUG " , " Another mod detected" );
826+ FTLog ( " Another mod detected" );
827827}
828828```
829829
@@ -840,10 +840,10 @@ class MySystem extends ScriptableSystem {
840840 private cb func OnResourceReady (token : ref<ResourceToken>) {
841841 let template = token.GetResource () as entEntityTemplate;
842842
843- LogChannel (n " DEBUG " , " Available appearances:" );
843+ FTLog ( " Available appearances:" );
844844
845845 for appearance in template.appearances {
846- LogChannel (n " DEBUG " , s" - \( appearance.name ) " );
846+ FTLog ( s" - \( appearance.name ) " );
847847 }
848848 }
849849}
@@ -985,11 +985,11 @@ You can get various type information using type name or variable:
985985let cls = Reflection.GetClass (n" inkWidget" );
986986
987987if cls.IsNative () {
988- LogChannel (n " DEBUG " , s" \( cls.GetName () ) is native class" );
988+ FTLog ( s" \( cls.GetName () ) is native class" );
989989}
990990
991991for prop in cls.GetProperties () {
992- LogChannel (n " DEBUG " , s" \( prop.GetName () ) : \( prop.GetType ().GetName () ) " );
992+ FTLog ( s" \( prop.GetName () ) : \( prop.GetType ().GetName () ) " );
993993}
994994```
995995
@@ -1009,13 +1009,13 @@ let setter = imageClass.GetFunction(n"SetTexturePart");
10091009let val1 = prop.GetValue (image); // Read property from instance
10101010let val2 = getter.Call (image); // Call getter on instance
10111011
1012- LogChannel (n " DEBUG " , s" Expected type: \( prop.GetType ().GetName () ) " );
1013- LogChannel (n " DEBUG " , s" Value from property: \( FromVariant< CName> (val1) ) " );
1014- LogChannel (n " DEBUG " , s" Value from getter: \( FromVariant< CName> (val2) ) " );
1012+ FTLog ( s" Expected type: \( prop.GetType ().GetName () ) " );
1013+ FTLog ( s" Value from property: \( FromVariant< CName> (val1) ) " );
1014+ FTLog ( s" Value from getter: \( FromVariant< CName> (val2) ) " );
10151015
10161016setter.Call (image, [n" bar" ]); // Change the value using setter
10171017
1018- LogChannel (n " DEBUG " , s" New value: \( image.GetTexturePart () ) " );
1018+ FTLog ( s" New value: \( image.GetTexturePart () ) " );
10191019```
10201020
10211021### Custom callbacks
@@ -1060,12 +1060,12 @@ class MyService {
10601060 let result = callable.Call (target, [data], status);
10611061
10621062 if status {
1063- LogChannel (n " DEBUG " , s" Result: \( VariantTypeName (result)) " );
1063+ FTLog ( s" Result: \( VariantTypeName (result)) " );
10641064 } else {
1065- LogChannel (n " DEBUG " , s" Method \( type.GetName () ) .\( function ) must accept one parameter" );
1065+ FTLog ( s" Method \( type.GetName () ) .\( function ) must accept one parameter" );
10661066 }
10671067 } else {
1068- LogChannel (n " DEBUG " , s" Method \( type.GetName () ) .\( function ) not found" );
1068+ FTLog ( s" Method \( type.GetName () ) .\( function ) not found" );
10691069 }
10701070 }
10711071}
@@ -1076,7 +1076,7 @@ Don't forget to use `cb` modifier for callbacks to be able to use functions shor
10761076``` swift
10771077class MyHandler {
10781078 protected cb func Callback (data : ref<IScriptable>) {
1079- LogChannel (n " DEBUG " , s" It's working! Received \( data.GetClassName () ) ." );
1079+ FTLog ( s" It's working! Received \( data.GetClassName () ) ." );
10801080 }
10811081}
10821082
@@ -1110,23 +1110,23 @@ apply different logic and access it safely.
11101110let name = n" test" ;
11111111let hash = NameToHash (name);
11121112
1113- LogChannel (n " DEBUG " , s" Name: \( name ) -> Hash: \( hash ) " );
1113+ FTLog ( s" Name: \( name ) -> Hash: \( hash ) " );
11141114```
11151115
11161116### NodeRef
11171117
11181118``` swift
11191119let nodeRef = CreateNodeRef (" $/my/new/#node" );
11201120
1121- LogChannel (n " DEBUG " , s" NodeRef: \( NodeRefToHash (nodeRef)) " );
1121+ FTLog ( s" NodeRef: \( NodeRefToHash (nodeRef)) " );
11221122```
11231123
11241124### CRUID
11251125
11261126``` swift
11271127let id = CreateCRUID (1337ul );
11281128
1129- LogChannel (n " DEBUG " , s" CRUID: \( CRUIDToHash (id)) " );
1129+ FTLog ( s" CRUID: \( CRUIDToHash (id)) " );
11301130```
11311131
11321132### Hash functions
0 commit comments