Is there a way to create MODS for a game ? (.pck added on the fly)

urieluriel Posts: 56Member

Hi, i hope the title is explicit enough, but i cant get an answer to this question.

i would like to publish a game, that will have some "extensions" plugins without exporting again the game, just by adding a pck file next to the exe file (or into a dedicated folder).
i would like to know if someone has even been able to do this, and if there is some exemples available.

thoses "plugin pck" can be new textures for the game, new levels, etc...
thanks for your answer :)
Have a great day

uriel

Comments

  • TwistedTwiglegTwistedTwigleg Posts: 1,608Admin

    Have you seen Exporting packs, patches, and mods on the Godot documentation? It covers how you can load .pck files at run time in Godot.

    I do not know of any tutorials or other resources right off, but searching "Godot load .pck files" in a search engine might yield some helpful results.

  • urieluriel Posts: 56Member

    Hi Twistedtwigleg,
    thanks for your answer :)
    yes i did read it and more or less, it gives me an idea of doing this, but i cant find an exemple that works !
    right now, i am trying to get my sample working, lets see ;)

    Now, you are right, the way it is shown in the doc, let me thinking that what i want to archieve is clearly possible (good point)...

    if anyone got a demo .. please share the link ;)
    Haver a great day !

    uriel

  • urieluriel Posts: 56Member
    edited October 8

    Hi,
    i still got some problems loading .pck files :(
    Here is what i am doing:

    i created 2 projects:

    • main app
    • mod

    and i have a created a third folder for export...

    in my main scene i have a VBoxcontainer that will get the mod scene as a child (wich is a simple panel with a label), here is the code for the VBoxContainer script:

    func _ready() -> void:
        ProjectSettings.load_resource_pack("res://mod.pck")
        var imported_scene = load("res://mod_scene.tscn").get_instance_id()
        add_child(imported_scene)
    

    Then i had exported the main project as app.exe and app.pck, and the mod project as mod.pck, within the same folder... i dont know what i am missing but it doesnt work.

    Export folder:

    • app.exe
    • app.pck
    • mod.pck (which include only mod_scene.tscn)
  • TwistedTwiglegTwistedTwigleg Posts: 1,608Admin

    Does the code work in the Godot editor?

    The issue is likely that due to res:// being the project's resource path, which is not necessarily the path to the folder containing the executable. You'll probably need to use something like globalize_path("res://") (documentation) to get the path to the executable, and then use that to get a path to the mod.pck file.
    That said, I haven't tried it myself so I am mainly guessing.

    If you place the mod.pck file in the user:// folder, you should be able to load it using ProjectSettings.load_resource_pack("user://mod.pck") in both the exported game and in the Godot editor.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file