Jump to content

Recommended Posts

Hi all,

 

Just started playing a week ago and now I want to try making my own mods for fun. I was looking at some sample code on how to spawn monsters when a new game is started

function SpawnCreature(player)        --[NEW] Get the player's current position.    local x, y, z = player.Transform:GetWorldPosition()    --[NEW] Spawn a 'Beefalo' prefab at the world origin.  Prefabs are basically a fancy game development term for objects.  Every     --      creature, item and character in 'Don't Starve' is a prefab.    local creature = GLOBAL.SpawnPrefab("forest/animals/beefalo")    --[NEW] Move the creature to the player's position.    creature.Transform:SetPosition( x, y, z )   end--[NEW] Tell the engine to run the function "SpawnCreature" as soon as the player spawns in the world.AddSimPostInit(SpawnCreature)

Are these "functions" (GetWorldPosition(), SpawnPrefab(), AddSimPostInit()) defined anywhere? I cannot seem to find it as it is not as obvious where to look compared to

inst.components.inventory:GiveItem(GLOBAL.SpawnPrefab(v))

for example.

 

Appreciate any help! :-)

Link to comment
https://forums.kleientertainment.com/forums/topic/55360-function-definitions/
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...