Jump to content

Recommended Posts

I'm trying to make a mod that lets the player plant mushroom caps. I thought that setting up the ondeploy function with a SpawnPrefab(..."name") to spawn the mushroom based on the cap color would work, but it makes the game crash. How should I set up this part of the function?

I don't get where the ellipsis come from.

SpawnPrefab(..."name") makes no sense whatsoever. Or did you have something like?

local function(...)
	local mushroom = SpawnPrefab(..."name")
end

Well that's not how the ellipsis work.

Info here: http://www.lua.org/pil/5.2.html

 

You can do it like:

local deployed = {
	red_cap = "red_mushroom",
	green_cap = "green_mushroom",
	blue_cap = "blue_mushroom",
}

local mushroom = SpawnPrefab(deployed[inst.prefab])

 

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...