Check out our latest project ✨ OpenChapter.io: free ebooks the way its meant to be πŸ“–

Legends of Learning SDK Integration Plugin for Godot

An asset by The Digital Spell
The page banner background of a mountain and forest
Legends of Learning SDK Integration Plugin for Godot hero image

Quick Information

0 ratings
Legends of Learning SDK Integration Plugin for Godot icon image
The Digital Spell
Legends of Learning SDK Integration Plugin for Godot

The Legends of Learning SDK Integration Plugin for Godot 4 is the essential tool for connecting your game to the LoL platform. It automatically provides a global LoLApi Singleton, abstracting the complex JavaScript communication into simple Godot Signals and Methods. Easily handle save states, score reporting, and language changes to ensure your educational game runs smoothly and meets all platform requirements.

Supported Engine Version
4.4
Version String
1.0.0
License Version
MIT
Support Level
community
Modified Date
12 hours ago
Git URL
Issue URL

Legends of Learning SDK Integration Plugin for Godot

Overview

The Legends of Learning SDK Integration Plugin for Godot is an essential Godot addon designed to simplify communication between your game and the Legends of Learning (LoL) platform environment.

It automatically provides a global Singleton called LoLApi which handles all low-level JavaScriptBridge messaging, allowing you to focus on game development.


πŸš€ Installation

  1. Install Plugin: Download or install the asset. Copy the addons/lolapi folder into the addons/ directory of your Godot 4 project.
  2. Enable Plugin: Go to Project > Project Settings > Plugins and check the status of the Legends of Learning SDK Integration Plugin is set to Enable.
  3. Export Feature: For export targeting the LoL platform, go to Project > Export > HTML5 (LoL) and add LoLApi feature in your export preset.
  4. Translation Requirement (Crucial) 🌐: The plugin relies on the TranslationsLoader utility class to manage in-game language changes requested by the LoL platform. This utility interacts with Godot's TranslationServer. You must have a primary translation file named translations.json located in the root of your project (res://translations.json). This file is required for the TranslationsLoader.load_translations() function to properly initialize Godot's translation system before the SDK sends a language change.

πŸ”Œ Core Usage

The wrapper uses the standard Godot Signals and Methods pattern.

  • Signals: For incoming messages from the LoL SDK to your game (e.g., "Pause," "Load Data").
  • Methods: For outgoing messages from your game to LoL SDK (e.g., "Save Data," "Complete Game").

The LoLApi Singleton is available globally; you don't need to load it manually.

Step 1: Initialize Communication

In your main game script (e.g., World.gd or GameManager.gd), use the OS.has_feature() check to ensure the LoLApi is only initialized when running in the required web environment.

func _ready():
    # ... your game initialization logic ...

    # Godot 4: Check for the HTML5 feature which indicates LoL web environment
    if OS.has_feature("LoLApi"): 
        # Start the communication handshake
        _init_LoL()
    else:
        print("Running in local mode. LoL SDK features disabled.")
        # Run your local load/initialization logic here

func _on_savedata_loaded():
    # ... your game continue here ...

Step 2: Respond and Send the Ready Signal

The _init_LoL method is the key starting point. Use its callback to request save data, and finally, notify the SDK that your game is fully ready.

func _on_LoL_init_message_received(_payload: Dictionary):
    # Send the START message (as per your implementation)
    LoLApi.send_start_message() 

func _on_LoL_start_message_received(payload: Dictionary):
    # The platform has provided settings/language. Now request save data.
    LoLApi.send_saves_request_message()
    
func _on_LoL_load_state_message_received(payload: Dictionary):
    # 1. Use the payload.data to load the game state.
    # SaveData.load_game(payload.data)
    
    # 2. Once your game is fully initialized and loaded, 
    # send the final ready signal.
    LoLApi.send_ready_message()
#region LOL
func _init_LoL():
    _set_LoL_connection()
    LolApi.send_init_message()

func _set_LoL_connection():
    LolApi.init_message_received.connect(_on_LoL_init_message_received)
    LolApi.start_message_received.connect(_on_LoL_start_message_received)
    LolApi.translation_message_received.connect(_on_LoL_translation_message_received)
    LolApi.load_state_message_received.connect(_on_LoL_load_state_message_received)
    LolApi.save_state_result_message_received.connect(_on_LoL_save_state_result_message_received)
    # ... See demo script for more examples

func _on_LoL_init_message_received(_payload: Dictionary):
    LolApi.send_start_message()

func _on_LoL_start_message_received(payload: Dictionary):
    # '{"languageCode":"en","awkAutoSpeak":false,"awkMusicOn":false,"awkSfxOn":false}'}
    LolApi.send_saves_request_message()

func _on_LoL_translation_message_received(payload: Dictionary):
    TranslationsLoader.set_locale(payload.language)
    # ... Refresh language here ...
    
func _on_LoL_load_state_message_received(payload: Dictionary):
    if not payload.is_empty() and payload.has("data"):
        # ... load_game with payload.data ...
        if payload.has("currentProgress"):
            # ... you can save currentProgress with payload.currentProgress to increase it ...
    else:
        # ... load_game with default data ...
    await get_tree().process_frame
    # Force save in next frame
    # ... save_game ...
#endregion

πŸ“Š Essential Outgoing Methods

Use these methods on the global LoLApi Singleton to communicate key game events back to the LoL SDK:

Method Purpose
LoLApi.send_save_state_message(current_progress, max_progress, data) Saves the current state. data is a Dictionary that is converted to JSON.
LoLApi.send_progress_and_score_message(current_progress, max_progress, score) Sends the player's progress and score for tracking.
LoLApi.send_complete_message() Notifies the platform that the game has finished.
LoLApi.send_text_to_speech_message(text, code) Sends text to be read aloud by the platform's Text-to-Speech service.
LoLApi.send_pause_message() Tells the platform that the game is pausing (less common, usually managed by the platform).

The Legends of Learning SDK Integration Plugin for Godot 4 is the essential tool for connecting your game to the LoL platform. It automatically provides a global LoLApi Singleton, abstracting the complex JavaScript communication into simple Godot Signals and Methods. Easily handle save states, score reporting, and language changes to ensure your educational game runs smoothly and meets all platform requirements.

Reviews

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
Legends of Learning SDK Integration Plugin for Godot icon image
The Digital Spell
Legends of Learning SDK Integration Plugin for Godot

The Legends of Learning SDK Integration Plugin for Godot 4 is the essential tool for connecting your game to the LoL platform. It automatically provides a global LoLApi Singleton, abstracting the complex JavaScript communication into simple Godot Signals and Methods. Easily handle save states, score reporting, and language changes to ensure your educational game runs smoothly and meets all platform requirements.

Supported Engine Version
4.4
Version String
1.0.0
License Version
MIT
Support Level
community
Modified Date
12 hours ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers