Jump to content

Recommended Posts

@Aphid98 Binding the key is probably the easiest part. See if you can make the component first.

Ideally, you would also have a modified or custom stategraph that can play a firebreathing animation when the fireball is launched, or it would just come out of nowhere.

 

To bind a key, use one of the AddKey_Handler's in TheInput. (See input.lua)

Example:

TheInput = GLOBAL.TheInputlocal key = GLOBAL.KEY_G -- See constants.lua for all keys/codeslocal function PrintHi()    print("hi")endTheInput:AddKeyDownHandler(key, PrintHi)

This prints "hi" to the console when you press "g".

So i have added the code I think i need, but now whenever i open the character in a world the game crashes... Here is the log:log.txt

i opened it and i had no idea where to look for the messed up code... Any ideas?

wait... How do you mean component?

because, i put all of the fire breathing code in the special powers place  :wilson_smile:

edit: Not all of it, just the attack/add fire projectile and sound 

 p.s: I'm really sorry, I am a bad programmer.

Edited by Aphid98

@Aphid98

 

In your log:

cole.lua:123: attempt to index global 'TheInput' (a nil value)
In prefabs/scripts, you don't need TheInput = GLOBAL.TheInput because global variables are already available. You only need it in modmain.

 

See this guide for more information on reading log files.

 

Information on components:

Edited by Blueberrys

 

Information on components:

 

Ok I am really not sure what to do, I will provide my component file. Would you tell me if it is right?

firebreath.lua

I made a components folder by the prefabs folder, Is that right?

@Aphid98 Have you read about components from either of the links? If so, please have a look at any component's code (in "..\scripts\components", then compare the general structure with your code (just the first and last ~20 lines). Your code is attempting to make a prefab, not a component. If you don't want to write the code from scratch, I suggest finding a component that is very similar to what you need and modifying that.

@Blueberrys I need help with a special power (2 to be exact)

 

1 of them is a perk that innocents (rabbits, bird etc.) won't run away when the palyer gets close to it

2nd one will be a perk (more like a downside) is that the character will take 100 damage when eating berries, roasted ones and also fist      full of jam (only)

 

If you can give me a head start or at least a direction to start with will be most helpful. Thanks. :wickerbottomthanks:

@Blueberrys I need help with a special power (2 to be exact)

 

1 of them is a perk that innocents (rabbits, bird etc.) won't run away when the palyer gets close to it

2nd one will be a perk (more like a downside) is that the character will take 100 damage when eating berries, roasted ones and also fist      full of jam (only)

 

If you can give me a head start or at least a direction to start with will be most helpful. Thanks.

 

both go to the part in your characters file that has the other player abilities

 

1)

inst:RemoveTag("scarytoprey")

 

2)

local function BerryDeath(inst, data)

  if data.food then

    if data.food.prefab == "berries" or data.food.prefab == "WHATEVER" then --you can continue on the "or ... = ..."

      inst.components.health:DoDelta(-100)

    end

  end

end

 

inst:ListenForEvent("oneat",BerryDeath)

both go to the part in your characters file that has the other player abilities

 

1)

inst:RemoveTag("scarytoprey")

 

2)

local function BerryDeath(inst, data)

  if data.food then

    if data.food.prefab == "berries" or data.food.prefab == "WHATEVER" then --you can continue on the "or ... = ..."

      inst.components.health:DoDelta(-100)

    end

  end

end

 

inst:ListenForEvent("oneat",BerryDeath)

Thanks a lot! 

But I don't get the file you are talking about...

Or do I need to create another prefab or something?

Thanks a lot! 

But I don't get the file you are talking about...

Or do I need to create another prefab or something?

 

Have you used a template? It should have a bit saying "add powers here" or alike. That's where you put the code.

 

Also, keep in mind that WHATEVER isn't an actual prefab, but a placeholder. I got bored :p

@Aphid98 Have you read about components from either of the links? If so, please have a look at any component's code (in "..\scripts\components", then compare the general structure with your code (just the first and last ~20 lines). Your code is attempting to make a prefab, not a component. If you don't want to write the code from scratch, I suggest finding a component that is very similar to what you need and modifying that

Ok, I am having a lot of trouble making the component file.  I still crashes every time i run it, (probably because of the bad component file)

I have attached the file here: firebreath.lua

i think it has problems with it not specifying that it is a special power? Idk...

I don't get the file you are talking about...

Your character's prefab file "..\your_mod\scripts\your_character_prefab.lua".

You need to put those inside the create function (named "fn" usually) because "inst" refers to the player.

 

@Aphid98 That one looks a lot better, well done. If you post your log, we can point out what's causing the problem.

Have you used a template? It should have a bit saying "add powers here" or alike. That's where you put the code.

 

Also, keep in mind that WHATEVER isn't an actual prefab, but a placeholder. I got bored :razz:

 

 

Your character's prefab file "..\your_mod\scripts\your_character_prefab.lua".

You need to put those inside the create function (named "fn" usually) because "inst" refers to the player.

 

@Aphid98 That one looks a lot better, well done. If you post your log, we can point out what's causing the problem.

So do I put it in : local common_postinit = function(inst)   (or in the)   local master_postinit = function(inst)

 

thanks again guys...Probably gonna credit you guys if the mod gets onto the workshop! :kiwi:

 

shaman.lua

Edited by TheOoKiller

@TheOoKiller

 

Hmm. Common post init, I think. The information we provided before now has been DS oriented, so it might not work the same in DST. If you're making the mod for DST, you might want to check out the DST modding section.

 

 

Your log says:

[string "../mods/Shaman/scripts/prefabs/shaman.lua"]:67: variable 'inst' is not declared
Edited by Blueberrys

Your character's prefab file "..\your_mod\scripts\your_character_prefab.lua".

You need to put those inside the create function (named "fn" usually) because "inst" refers to the player.

 

@Aphid98 That one looks a lot better, well done. If you post your log, we can point out what's causing the problem.

Awesome! Here is the log:log.txt

@Aphid98

Your log says:

...nt_starve/data/../mods/Cole/scripts/prefabs/cole.lua:52: variable 'firebreath' is not declared

The problem is in cole.lua. Check around line 52, see if you can figure it out. Provide the file's content if you get stuck.

@Aphid98

Your log says:

...nt_starve/data/../mods/Cole/scripts/prefabs/cole.lua:52: variable 'firebreath' is not declared

The problem is in cole.lua. Check around line 52, see if you can figure it out. Provide the file's content if you get stuck.

I don't actually know how to reference my component correctly, How should i tell it to look for the file?

 

@Aphid98 See how the other prefabs do it.

For example, "houndstooth.lua":

inst:AddComponent("stackable")inst.components.stackable.maxsize = TUNING.STACK_SIZE_SMALLITEM

It seems that the problem is my firebreath variable is not declared, this is the code:

local prefabs = {}
 
local fn = function(inst)
 
-- choose which sounds this character will play
inst.soundsname = "maxwell"
 
-- a minimap icon must be specified
inst.MiniMapEntity:SetIcon( "wolfgang.png" )
 
-- todo: Add an example special power here.
inst:AddComponent("firebreath")
local key = GLOBAL.KEY_LCTRL -- See constants.lua for all keys/codes
 
TheInput:AddKeyDownHandler(key, firebreath)
end

@Aphid98 Did you put firebreath.lua in "..\your_mod\scripts\components"?

I fixed that problem just a second ago, but now it says:

...steamapps/common/dont_starve/data/scripts/events.lua:21: table index is nil

 

here is my component, what is wrong?

firebreath.lua

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