Aphid98 Posted March 31, 2015 Author Share Posted March 31, 2015 @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.txti opened it and i had no idea where to look for the messed up code... Any ideas? Link to comment Share on other sites More sharing options...
Aphid98 Posted March 31, 2015 Author Share Posted March 31, 2015 wait... How do you mean component?because, i put all of the fire breathing code in the special powers place edit: Not all of it, just the attack/add fire projectile and sound p.s: I'm really sorry, I am a bad programmer. Link to comment Share on other sites More sharing options...
Blueberrys Posted March 31, 2015 Share Posted March 31, 2015 @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:Wots The DiffAPI docs - ComponentsEverything in your "..\scripts\components" folder Link to comment Share on other sites More sharing options...
Aphid98 Posted March 31, 2015 Author Share Posted March 31, 2015 Information on components:Wots The DiffAPI docs - ComponentsEverything in your "..\scripts\components" folder Ok I am really not sure what to do, I will provide my component file. Would you tell me if it is right?firebreath.luaI made a components folder by the prefabs folder, Is that right? Link to comment Share on other sites More sharing options...
Aphid98 Posted March 31, 2015 Author Share Posted March 31, 2015 if that is a good components file, how do i reference it? Link to comment Share on other sites More sharing options...
Aphid98 Posted April 3, 2015 Author Share Posted April 3, 2015 Does anyone know? Link to comment Share on other sites More sharing options...
Blueberrys Posted April 3, 2015 Share Posted April 3, 2015 @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. Link to comment Share on other sites More sharing options...
Aphid98 Posted April 4, 2015 Author Share Posted April 4, 2015 @BlueberrysOK, i'll try Link to comment Share on other sites More sharing options...
TheOoKiller Posted April 6, 2015 Share Posted April 6, 2015 @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 it2nd 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. Link to comment Share on other sites More sharing options...
Mobbstar Posted April 6, 2015 Share Posted April 6, 2015 @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 it2nd 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 endend inst:ListenForEvent("oneat",BerryDeath) Link to comment Share on other sites More sharing options...
TheOoKiller Posted April 6, 2015 Share Posted April 6, 2015 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 endend 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? Link to comment Share on other sites More sharing options...
Mobbstar Posted April 6, 2015 Share Posted April 6, 2015 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 Link to comment Share on other sites More sharing options...
Aphid98 Posted April 6, 2015 Author Share Posted April 6, 2015 @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 thatOk, 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.luai think it has problems with it not specifying that it is a special power? Idk... Link to comment Share on other sites More sharing options...
Blueberrys Posted April 6, 2015 Share Posted April 6, 2015 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. Link to comment Share on other sites More sharing options...
TheOoKiller Posted April 7, 2015 Share Posted April 7, 2015 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 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! shaman.lua Link to comment Share on other sites More sharing options...
TheOoKiller Posted April 7, 2015 Share Posted April 7, 2015 hey guys me gme froze after I enabled the mod in the mods section, any idea why?? Log is below.log.txt Link to comment Share on other sites More sharing options...
Blueberrys Posted April 7, 2015 Share Posted April 7, 2015 @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 Link to comment Share on other sites More sharing options...
Aphid98 Posted April 7, 2015 Author Share Posted April 7, 2015 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 Link to comment Share on other sites More sharing options...
Blueberrys Posted April 7, 2015 Share Posted April 7, 2015 @Aphid98Your log says:...nt_starve/data/../mods/Cole/scripts/prefabs/cole.lua:52: variable 'firebreath' is not declaredThe 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. Link to comment Share on other sites More sharing options...
Aphid98 Posted April 7, 2015 Author Share Posted April 7, 2015 @Aphid98Your log says:...nt_starve/data/../mods/Cole/scripts/prefabs/cole.lua:52: variable 'firebreath' is not declaredThe 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? Link to comment Share on other sites More sharing options...
Blueberrys Posted April 7, 2015 Share Posted April 7, 2015 @Aphid98 See how the other prefabs do it.For example, "houndstooth.lua":inst:AddComponent("stackable")inst.components.stackable.maxsize = TUNING.STACK_SIZE_SMALLITEM Link to comment Share on other sites More sharing options...
Aphid98 Posted April 8, 2015 Author Share Posted April 8, 2015 @Aphid98 See how the other prefabs do it.For example, "houndstooth.lua":inst:AddComponent("stackable")inst.components.stackable.maxsize = TUNING.STACK_SIZE_SMALLITEMIt 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 playinst.soundsname = "maxwell" -- a minimap icon must be specifiedinst.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 Link to comment Share on other sites More sharing options...
Blueberrys Posted April 8, 2015 Share Posted April 8, 2015 @Aphid98 Did you put firebreath.lua in "..\your_mod\scripts\components"? Link to comment Share on other sites More sharing options...
Aphid98 Posted April 8, 2015 Author Share Posted April 8, 2015 @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 Link to comment Share on other sites More sharing options...
Blueberrys Posted April 8, 2015 Share Posted April 8, 2015 @Aphid98 Something is wrong with the key binding. Provide that code please. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
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.