Skip to reading
Eight Adventure Interface Workshops

Make a portrait switch or receive an item

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page

Record ID: transfer_to_mara. Global Script: off. Put this on Mara’s portrait instead of the plain Switch Character behavior.

Code example
extends "res://scripts/runtime/script_base.gd"
Code example
func run(_context: Dictionary = {}) -> Variant:
    var item: String = str(Runtime.get("selected_inventory"))
    if item.is_empty():
        await Runtime.call("switch_player_character", "assistant")
        return true
    await TransferInventory({"fromCharacterId":ActivePlayer(),
        "toCharacterId":"assistant", "itemId":item, "count":1})
    Runtime.call("clear_selected_inventory_item")
    return true

Copy the record for another recipient and change assistant to that character’s ID. Keep ActivePlayer() as the source; hard-coding the source would transfer from the wrong character after a switch.

Add story or ownership checks before Transfer Inventory when needed. A transfer-aware portrait should explain why an unavailable recipient or a forbidden item cannot be used, rather than behaving like a dead Button.

Use the item’s actual selected ID. Its caption, icon and translated name are presentation; they are not reliable transfer keys.

Page 104 of 119Permalink
Go to page