Jump to content

is there a command in game to spawn a weapon with custom stats?

Recommended Posts

i know how to spawn a weapon with custom damage, but i dont know if there is a way to spawn a weapon that gives you 2000 max health or to spawn a spear that on hit freezes you, i just want to know if there is a way to this happens

and if you know how to put 2 components too will be very useful because i want to do this code and i dont know how to make these 2 components work, normally just one of them work: c_spawn("spider")ThePlayer.Transform:SetScale(5, 5, 5).components.health:SetMaxHealth(1)
the command works alone but when i put the maxhealth component only the size works and the health keeps the same

Link to comment
Share on other sites

You can select an object in the world by mousing over it and using


in a local world, or


 in a dedicated one.

For setting damage, you need to use the weapon component's SetDamage(amount) function.  E.g.:


You can also mess around with the weapon's durability like this:




Making it freeze things is, er.... not so simple, judging by the blue staff's code in staff.lua.  Looks like it has to check if the target's still alive and freezable, wake it up, put out any fires, and add coldness to its freezable component.  Probably better just to make a mod that puts most of the ice staff's attack logic into a new freezingweapon component with a SetColdness(amount) function.  Klei probably didn't do this already because there's only the one cold weapon.

As for manipulating multiple components, you'll either need to do it in multiple steps or make a local variable for the object you're manipulating.  See the instructions for spawning wormholes and beefalo on the wiki.  Which method you should use depends on how often you expect to do it.  If you're only going to do it once, you won't need to define a custom function.

myspider = c_spawn("spider"); myspider.Transform:SetScale(5, 5, 5); myspider.components.health:SetMaxHealth(1)


Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

  • Create New...