[0.8.9][NK] Porting from 0.8.6

johnycilohoklajohnycilohokla REGISTERED Posts: 283 Developer
edited December 2015 in Modding Tutorials

NKGetInstance and .object

NKGetInstance is deprecated and scheduled for removal.
It used to retrieve the lua script instance associated with this GameObject, now this is done automatically.

Using this function will print console warnings (with stacktrace) to aid the removal.

Getting the native object is also deprecated, this used to be done using .object called on an instance of an object and was required when calling engine functions that required a game object (world queries, NKAddChildObject, ...)

Both NKGetInstance and .object and now automated by the engine and the lua versions return self to avoid crashes while porting.

Crafting recipes

Each recipe needs to define a craftingActionName and craftingDisplayName.

craftingActionName combined with craftingDisplayName is used the display the message on the progress bar.
craftingDisplayName is used as a name for the Crafting Journal.

Example:
	Recipe
{
...
LuaData
{
craftingActionName = "Crafting... "
craftingDisplayName = "Recipe"
...
}
}
Registering new crafting recipe file now requires a 2nd parameter (category name):
Eternus.CraftingSystem:ParseRecipeFile( "path/to/file.txt", "CategoryName" )
Crafting Recipes tutorial

Archetypes

The archetype system has changed in 0.8.7.

The new system is using txt files stored in Data/Archetypes/* to define groups of archetypes.

Example:
Archetypes
{
Cobblestone Clump
{
Cobblestone
Cobblestone Gray Clump
Cobblestone Blue Clump
Cobblestone Green Clump
}
}
The deprecated system used to work by assigning craftingArchetype to an object in it's txt file.
This system is no longer in use.

Archetypes tutorial

World queries

World queries can now use a bitmask instead of just a layer ID.
Physics Tutorial

Other notes

Invalid texture files parsed from txt files will now show an error during loading.

Texture atlas is no longer limited to 1024 icons.

VoxelsModifiedCallback will now get the userdata1, even when no player is specified.
My Blog
jc.png
  yt.png  t.png  

Comments

  • UFIOESUFIOES REGISTERED, Tester Posts: 42 Seed
    You may not have mentioned that:
    CraftingSystem:ParseRecipeFile( filePath, category )
    now requires a category in its arguments
  • CharlockCharlock REGISTERED, Tester Posts: 293 Seed
    If your mod has a repair recipe file, does this also require and index?

    If you have multiple files within the mod, does each recipe in each file require unique, sequential Index values?

    Example:
    File1 Recipes
    {
    	Recipe1
    	{
    		Index = 1
    		...
    	}
    
    File2 Recipes
    {
    	Recipe1
    	{
    		Index = 2
    		...
    	}
    	Recipe2
    	{
    		Index = 3
    		...
    	}
    
    And so on..
    "I’ve been drunk for about a week now, and I thought it might sober me up to sit in a library."
  • johnycilohoklajohnycilohokla REGISTERED Posts: 283 Developer
    edited December 2015
    The index is no longer required, we have removed the need for it with the last update.
    Heh, I thought I have updated this tutorial... (fixed now)
    My Blog
    jc.png
      yt.png  t.png  
  • CharlockCharlock REGISTERED, Tester Posts: 293 Seed
    Thanks for clarifying Johny. I just updated to the latest patch and I'm getting an error with my crafting mods enabled:

    image

    I see @UFIOES mentions a "category" attribute is now necessary in the ParseRecipeFile, which I don't have. Can you help me out with that?

    Eternus.CraftingSystem:ParseRecipeFile("Data/Crafting/WhetstoneRecipe.txt")
    "I’ve been drunk for about a week now, and I thought it might sober me up to sit in a library."
  • CharlockCharlock REGISTERED, Tester Posts: 293 Seed
    Never mind this! I found it in your Crafting tutorial!
    "I’ve been drunk for about a week now, and I thought it might sober me up to sit in a library."
  • johnycilohoklajohnycilohokla REGISTERED Posts: 283 Developer
    Cool.
    I have added the "category" to the Crafting Recipes section and links to the Crafting Recipes tutorial and Archetypes tutorial.
    My Blog
    jc.png
      yt.png  t.png  
  • ekohrmanekohrman REGISTERED Posts: 87 Seed
    Can I create my own category in the crafting journal or do I have to use an existing one?
    Some call me... Terella.

  • johnycilohoklajohnycilohokla REGISTERED Posts: 283 Developer
    You can create new ones or add to existing ones.
    My Blog
    jc.png
      yt.png  t.png  
  • ekohrmanekohrman REGISTERED Posts: 87 Seed

    You can create new ones or add to existing ones.

    Thanks!

    Now if I could just get my crafting recipe to work. I cannot figure out what I'm doing wrong. I was able to add a new object which I can spawn, but the recipe just won't work.

    Here is the lua for my mod, Terrella. Did I miss something here?
    
    -------------------------------------------------------------------------------
    if Terrella == nil then
    	Terrella = EternusEngine.ModScriptClass.Subclass("Terrella")
    end
    
    -------------------------------------------------------------------------------
    -- Called once from C++ at engine initialization time
    function Terrella:Initialize()
        Eternus.CraftingSystem:ParseRecipeFile("Data/Crafting/TerrellaMod_recipes.txt", "Refined Resources")
    end
    
    EntityFramework:RegisterModScript(Terrella)
    Some call me... Terella.

  • johnycilohoklajohnycilohokla REGISTERED Posts: 283 Developer
    Could you post the content of "Data/Crafting/TerrellaMod_recipes.txt"?
    Also do you have console enabled? If you do, did you get any warnings?
    My Blog
    jc.png
      yt.png  t.png  
  • ekohrmanekohrman REGISTERED Posts: 87 Seed
    I didn't have the console turned on. I turned it on and all it said was that the debugger.lua loaded for Lua 5.1.

    This is Data/Crafting/TerrellaMod_recipes.txt
    All Recipes { Glow Corn Meal Recipe { Script = "Scripts/Recipes/DefaultRecipe.lua" LuaData { craftingActionName = "Grinding... " craftingDisplayName = "Glow Corn Meal" #Craft times are below unconsumedDamage = 3 priority = 1.0 Components { Fruit { "Glow Corn" = 1 } } Crafting Tool { category = "Hammer" tier = 1 } Results { "Glow Corn Meal" = 1 } Crafting Stations { Flat Rock { offsetOverride = <0.0, 1.0, 0.0> craftTime = 5.0 } } #Requirements to unlock this recipe in the crafting journal Requirements { #Player has collected one of these 1 { Collected { 1 { name = "Glow Corn" count = 1 } } } } } } }
    Some call me... Terella.

  • johnycilohoklajohnycilohokla REGISTERED Posts: 283 Developer
    Thanks, the crafting file works.

    It might be that you are missing the Script definition in your Manifest.json


    One way to check that would be to add an NKPrint or NKWarn in the Terrella:Initialize function.
    NKWarn("Terrella:Initialize")
    If it will not output to the console when you start the game you will need to add something like this to your Manifest.json:
    	"Script":
    {
    "File": "Scripts/Terrella.lua",
    "Class": "Terrella"
    },
    My Blog
    jc.png
      yt.png  t.png  
  • ekohrmanekohrman REGISTERED Posts: 87 Seed
    I have this for my manifest.txt in my mod folder. Is that not correct?
    Manifest { # Name of the mods. Name = "Terrella" # Description of the mod. Description = "A test of the mod scripting system" # The major version number. MajorVersion = 0.8 # The minor version number. MinorVersion = 0.9 #The file path to the script that is the entry point. //ScriptFile = "Scripts/Terrella.lua" #The script entry point class name //ScriptClass = "Terrella" }
    Some call me... Terella.

  • ekohrmanekohrman REGISTERED Posts: 87 Seed
    NKPrint or NKWarn in the Terrella:Initialize function
    Adding that to my lua didn't get me a notice in the console. So apparently it isn't initiating the script.
    Some call me... Terella.

  • CharlockCharlock REGISTERED, Tester Posts: 293 Seed
    Did you mean to put "//" in front of your script paths? I don't think they will initialize properly with those there.
    "I’ve been drunk for about a week now, and I thought it might sober me up to sit in a library."
  • ekohrmanekohrman REGISTERED Posts: 87 Seed
    D'oh! I knew it had to be something stupid simple that I missed. That worked perfectly. You guys rock so hard you set off seismometers! Thanks for helping an old lady out.
    Some call me... Terella.

  • CharlockCharlock REGISTERED, Tester Posts: 293 Seed
    It's ALWAYS something simple! Just helps to get a second set of eyes.. or third, or fourth.. :smile:
    "I’ve been drunk for about a week now, and I thought it might sober me up to sit in a library."
Sign In or Register to comment.