Jump to content

Recommended Posts

At one point I had been a working creature, since then I went way to deep into errors, and decided it would more likely be best if I started all over. In saying that, I'm repeating some mistakes, I know I've corrected before, but can't seem to find the exact mistake i am remaking now. 

The errors I know are going to be in the prefab, and I know that they are more then likely due to me not writing the script for the game to know I am wanting to create my creature, if it even knows it exists at all. So I think I have to add a line "create_mycreature" somewhere. But I dont know where, And im unsure of the right context.

my modmain.lua looks like this:

 

--[NEW] This is how we tell the game we've created a new prefab.
PrefabFiles = {knuckles}
 
 
--This function spawns the creature at the player's position.
function SpawnCreature(player)
 
--Get the player's current position.
local x, y, z = player.Transform:GetWorldPosition()
 
--[NEW] Spawn our new creature at the world origin.
local creature = GLOBAL.SpawnPrefab("knuckles")
 
--Move the creature to the player's position.
creature.Transform:SetPosition( x, y, z )
end
 
--Tell the engine to run the function "SpawnCreature" as soon as the player spawns in the world.
AddSimPostInit(SpawnCreature)

 

while the prefab is here:

 

--[NEW] Here we list any assets required by our prefab.
local assets=
{
--[NEW] this is the name of the Spriter file.
Asset("ANIM", "anim/knuckles.zip"),
}
 
--[NEW] This function creates a new entity based on a prefab.
local function init_prefab()
 
--[NEW] First we create an entity.
local inst = CreateEntity()
 
--[NEW] Then we add a transform component se we can place this entity in the world.
local trans = inst.entity:AddTransform()
 
--[NEW] Then we add an animation component which allows us to animate our entity.
local anim = inst.entity:AddAnimState()
 
--[NEW] The bankarrow-10x10.png name is the name of the Spriter file.
    anim:SetBank("knuckles")
 
    --[NEW] The build name is the name of the animation folder in spriter.
    anim:SetBuild("knuckles")
 
    --[NEW] Here we start playing the 'idle' animation and tell it to loop.
    anim:PlayAnimation("idle", true )
 
    --[NEW] return our new entity so that it can be added to the world.
    return inst
end
 
--[NEW] Here we registerarrow-10x10.png our new prefab so that it can be used in game.
return Prefab( "monsters/knuckles", init_prefab, assets, nil)
 

 

 

I know I have posted something like this before somewhere, when I made the exact same mistake last time. 

Matter of fact , with this tutorial, I think I'm just going to make a few creature mods, just so I can start getting the hang of the scripting.  I know I am telling the game to look for an asset that it cant find, I just cant seem to find this damned simple error. 

 

Guest
This topic is now closed to further replies.
×
  • Create New...