carenalgas / popochiu

Godot plugin to make point n' click games in a similar way to tools like Adventure Game Studio and Power Quest.
MIT License
154 stars 15 forks source link

9 verbs interface: working GIVE command #242

Closed ArturM closed 1 month ago

ArturM commented 1 month ago

On engine level Give is the same as Use, so only few changes to 9_verb_commands.gd and 9_verb_gui.gd and no changes on the main engine. Refactored _show_use_on() to _show_command_on() - one function for USE and GIVE and moved prepositions ('use ON', 'give TO') to one place so we can easy translate it in the future. It calls _on_item_used() just like USE because we often wants to 'Give item to character' and 'Use item on character' to work the same. We can check and differentiate behaviour by testing E.current_command

Like this:

func _on_item_used(item: PopochiuInventoryItem) -> void:
    if E.current_command == NineVerbCommands.Commands.GIVE:
        if item == I.Mushrooms:
            await C.player.say("Give mushroom")
        if item == I.Pumpkin:
            await C.player.say("Give pumpkin")
    else:
        if item == I.Mushrooms:
            await C.player.say("Use mushroom")
        if item == I.Pumpkin:
            await C.player.say("Use pumpkin")