Jump to content

Recommended Posts

@Crestonia, change these lines:

AddPlayerPostInit( function()local player_pos = GLOBAL.ThePlayer():GetPosition() 

to:

AddPlayerPostInit( function(inst)local player_pos = inst.Transform:GetPosition()

It should work after that.

 

A reason your code doesn't work is because ThePlayer is a variable not a function. You shouldn't use () with it. Use a . with it.

Edited by Kzisor

@Crestonia, by giving you the answer you will not learn. Your variable hat is a nil value, it means that wherever you are initializing the variable something is going wrong making it a nil or nonexistent variable. You will need to look at your code and determine why it's a nil value.

 

Some questions to ask yourself:

  • Is my prefab/item really being loaded properly?
  • Should I add additional prints to the log file to see exactly where the code malfunctions?
  • Should I comment out the mod main code and use the console to spawn it to see if it works?

Debugging is part of coding in general and is something you should get familiar with if you plan on creating more mods.

 

@Kzisor

AddPlayerPostInit( function()
local player_pos = GLOBAL.ThePlayer():GetPosition()
local hat = GLOBAL.SpawnPrefab('hat_bee_bw')
hat.Transform:SetPosition(player_pos.x, player_pos.y, player_pos.z)
end)
In the modinfo

 

 

You know I'm terrible at coding many things but... @Kzisor did you notice Crestonia said it's in the modinfo?

@Crestonia, Well, of course it's a lost cause if you give up so easily.

Try what Kzisor suggested. Try spawning the hat using console commands, like c_give("hat_bee_bw").

The console is opened using the ~ key on a QWERTY keyboard.

 

We can't help you if you don't try things for yourself and always expect us to magically solve all your problems!

@Jjmarco, the problem lies in the tutorial in which they used originally to create their mod.

 

@Crestonia, here is an updated tutorial. The original was created for Don't Starve, however, the modified tutorial is created for Don't Starve Together.

 

 

How do you obtain the hat? Use the command c_give("hat_bee_bw") in the console.

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