kilenator Posted December 7, 2013 Share Posted December 7, 2013 hey guys, im making a character of my own, im great at art but im so bad at coding (well not bad just not into it that much) so before i made the art i wanted to get the code first. started few days ago, coded the character, gave him a book (like maxwells) and bound another monster to the book instead of maxwells shadows. everything is working fine, i can summon the monster using the book and it is friendly, attacks when i do follows me, everything is fine. its almost finished i just have 2 more issues left that i dont know how to deal with.1. after i summon the first monster i need to make the book not spawn anymore of them when i click it until the summoned one dies2.i would like to remove the standard nightmare fuel and sanity/hp cost and replace it with half the character hp costi cant seem to get those right, i just dont know the code for it, i can remove the nightmare fuel cost but that just keeps spawning them while im keeping clicking, the first problem i have i think has something to do with "if TUNING.MONSTER_ALIVE" but i dont know how to use it. please help, if you can write me the code for those or just point me to the right path that would mean so much to methank you guys in advance1000000000 times! Link to comment https://forums.kleientertainment.com/forums/topic/30240-code-help-please/ Share on other sites More sharing options...
Rosten Posted December 7, 2013 Share Posted December 7, 2013 Just throwing an idea out, maybe you could add a tag to the summoned monster and have a check if any monsters with that tag were alive then don't summon anymore. Link to comment https://forums.kleientertainment.com/forums/topic/30240-code-help-please/#findComment-385679 Share on other sites More sharing options...
kilenator Posted December 7, 2013 Author Share Posted December 7, 2013 Just throwing an idea out, maybe you could add a tag to the summoned monster and have a check if any monsters with that tag were alive then don't summon anymore. oh, that could work, then it would be something like this local function Update(inst) if TUNING.MONSTER_ALIVE == 1 then local monster = TheSim:FindFirstEntityWithTag("monster") if not monster then monster = Spawnmonster(inst) is that corect?but how do i "tag" the monster? which would be the code?sorry i still dont understand the coding language enough Link to comment https://forums.kleientertainment.com/forums/topic/30240-code-help-please/#findComment-385710 Share on other sites More sharing options...
TheDanaAddams Posted December 8, 2013 Share Posted December 8, 2013 oh, that could work, then it would be something like this local function Update(inst) if TUNING.MONSTER_ALIVE == 1 then local monster = TheSim:FindFirstEntityWithTag("monster") if not monster then monster = Spawnmonster(inst) is that corect?but how do i "tag" the monster? which would be the code?sorry i still dont understand the coding language enough All you need to do isinst:AddTag("TAGNAME")to the spawned monster. TAGNAME can be anything you want - but try to make sure it's unique, so you don't clash with existing tags. Link to comment https://forums.kleientertainment.com/forums/topic/30240-code-help-please/#findComment-386024 Share on other sites More sharing options...
kilenator Posted December 8, 2013 Author Share Posted December 8, 2013 All you need to do isinst:AddTag("TAGNAME")to the spawned monster. TAGNAME can be anything you want - but try to make sure it's unique, so you don't clash with existing tags.ty for the info, now i get it a little more, but i cant get it to work i tried it with my mod andi tried it with the original maxwell, i opened waxwelljournall.lua and added local function Update(inst) if TUNING.SHADOWWAXWELL_ALIVE == 1 then local shadowwaxwell = TheSim:FindFirstEntityWithTag("waxwax") if not shadowwaxwell then shadowwaxwell = Spawnshadowwaxwell(inst) inst.shadowwaxwell = shadowwaxwell AddLeader(shadowwaxwell) end endendlocal function StartUpdating(inst) if not inst.loop then inst.loop = {} end inst.loop.amount = 0 inst.loop.period = 0.1 if not inst.loop.task then inst.loop.task = inst:DoPeriodicTask(inst.loop.period, function() Update(inst) end) endend i even tried local function onread(inst, reader) if TUNING.SHADOWWAXWELL_ALIVE == 1 then local shadowwaxwell = TheSim:FindFirstEntityWithTag("waxwax") if not shadowwaxwell then shadowwaxwell = Spawnshadowwaxwell(inst) inst.shadowwaxwell = shadowwaxwell AddLeader(shadowwaxwell) end endend and in the shaddowwaxwell.lua i added under local function local function fn() local inst = CreateEntity() local trans = inst.entity:AddTransform() local anim = inst.entity:AddAnimState() local sound = inst.entity:AddSoundEmitter() inst.Transform:SetFourFaced(inst) MakeGhostPhysics(inst, 1, .5) anim:SetBank("wilson") anim:SetBuild("waxwell_shadow_mod") anim:PlayAnimation("idle") anim:Hide("ARM_carry") anim:Hide("hat") anim:Hide("hat_hair") inst:AddTag("scarytoprey") inst:AddTag("NOCLICK") inst:AddTag("waxwax") <---this is the tag name i added i must be missing something, that is everything i changed, maybe in the modmain.lua i have to add something?sorry if im hard to work with Link to comment https://forums.kleientertainment.com/forums/topic/30240-code-help-please/#findComment-386153 Share on other sites More sharing options...
kilenator Posted December 8, 2013 Author Share Posted December 8, 2013 All you need to do isinst:AddTag("TAGNAME")to the spawned monster. TAGNAME can be anything you want - but try to make sure it's unique, so you don't clash with existing tags.couldnt do it, but i changed it so when i use the book it spawns 1 monster and consumes the book as a reagent, and when the monster dies it drops the book so it can be used again i wanted to ask you can you help me with the second thing, i need to make the character lose half his health or sanity when i use the book, it doesnt need to be half exactly, it can be 50, 60, any number now the book uses up healt and sanity, i can remove the use of health and sanity both but i just want to change itwhat code do i write in the book.lua to make it consume, lets say 100 sanity?is that posible? i have seen local function onread(inst, reader) GetPlayer().components.sanity:DoDelta(-TUNING.SANITY_HUGE) that uses 50 sanity i think, how do i set it to 100? Link to comment https://forums.kleientertainment.com/forums/topic/30240-code-help-please/#findComment-386194 Share on other sites More sharing options...
TheDanaAddams Posted December 8, 2013 Share Posted December 8, 2013 couldnt do it, but i changed it so when i use the book it spawns 1 monster and consumes the book as a reagent, and when the monster dies it drops the book so it can be used again i wanted to ask you can you help me with the second thing, i need to make the character lose half his health or sanity when i use the book, it doesnt need to be half exactly, it can be 50, 60, any number now the book uses up healt and sanity, i can remove the use of health and sanity both but i just want to change itwhat code do i write in the book.lua to make it consume, lets say 100 sanity?is that posible? i have seen local function onread(inst, reader) GetPlayer().components.sanity:DoDelta(-TUNING.SANITY_HUGE) that uses 50 sanity i think, how do i set it to 100?I'm really not the most coding-knowledgeable here. And I've been out of commission for so long I'm getting a bit rusty on what code I had familiarised myself with... sorry I can't be more help...That said, you don't need to point it to a TUNING.WHATEVER value. Like, you can just use (-100) - or, alternatively, you can make it do math. Things like -TUNING.SANITY_HUGE*2 and -TUNING.SANITY_HUGE/2 will work. Link to comment https://forums.kleientertainment.com/forums/topic/30240-code-help-please/#findComment-386237 Share on other sites More sharing options...
kilenator Posted December 9, 2013 Author Share Posted December 9, 2013 I'm really not the most coding-knowledgeable here. And I've been out of commission for so long I'm getting a bit rusty on what code I had familiarised myself with... sorry I can't be more help...That said, you don't need to point it to a TUNING.WHATEVER value. Like, you can just use (-100) - or, alternatively, you can make it do math. Things like -TUNING.SANITY_HUGE*2 and -TUNING.SANITY_HUGE/2 will work. -TUNING.SANITY_HUGE*2 worked perfectly! thank you!requesting lock Link to comment https://forums.kleientertainment.com/forums/topic/30240-code-help-please/#findComment-386720 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now