DreadHeadMafia Posted April 11, 2015 Share Posted April 11, 2015 I borrowed some code from the wilk mod that seemed pretty simple; however, the bad part of the mod was that it only worked for one transformation state when im trying to make it to two states. I tried to make one state for the angel, and one state for the demon, I made the components for them and it didn't crash. The problem was even though it didn't crash, every time my character changed to angel or demon state, he didn't change back to ether the normal state or the other state. can someone look at my prefab lua file and tell me why my character doesn't change to different states onces hes already become one p.s: he transforms due to where sanity is placewpi.lua Link to comment Share on other sites More sharing options...
Blueberrys Posted April 11, 2015 Share Posted April 11, 2015 @DreadHeadMafia Oh.. where to start. Erm, all those toggle variables and if statements aren't really needed. Why not just have one sanity check? And uh.. one variable that determines which state you're in.local min_sanity = { demon = 0, wilk = 125, angel = 240,}local states = { demon = 1, wilk = 2, angel = 3,}local current_statelocal function sanity_check(inst) local sanity_cur = inst.components.sanity.current if sanity_cur >= min_sanity.angel and current_state ~= states.angel then BecomeAngel(inst) current_state = states.angel elseif sanity_cur >= min_sanity.wilk and current_state ~= states.wilk then BecomeWilk(inst) current_state = states.wilk elseif sanity_cur >= min_sanity.demon and current_state ~= states.demon then BecomeDemon(inst) current_state = states.demon endend-- ...-- Run once to initialize first time-- Where inst is the player instancesanity_check(inst) Link to comment Share on other sites More sharing options...
DreadHeadMafia Posted April 11, 2015 Author Share Posted April 11, 2015 tried that but he still didn't change states back to any other once changed, ill make it again and show you when im done, cause I did sadly delete it Link to comment Share on other sites More sharing options...
Corrosive Posted April 11, 2015 Share Posted April 11, 2015 Exactly 0 sanity is an awful harsh cutoff -- you may want to make it something like <12 or accidentally picking a flower will undemonify you. Which is a pretty weak demon if you ask me. Real demons need to pick THREE flowers!Edit: You seem to be referring to the sanity variable two different ways: inst.components.sanity.currentsanity = 124 local Sanitycurr = inst.components.sanity.currentsanity.current is the correct one.There are some other oddities as well... registering to handle the same event with 4 different functions is a 'wee bit excessive'. I don't know exactly what's going on there cause you didn't post your stategraph, but I would try to stuff most of that into a single OnSanityDelta function. Edit2: Oh, Blueberrys literally said just that hah. Disregard. Link to comment Share on other sites More sharing options...
DreadHeadMafia Posted April 11, 2015 Author Share Posted April 11, 2015 @DreadHeadMafia Oh.. where to start. Erm, all those toggle variables and if statements aren't really needed. Why not just have one sanity check? And uh.. one variable that determines which state you're in. Not taking classes for learning coding yet so im just messing around with it for now. In the meantime I used the coding way you mentioned and the new problem now is that the character now flashes (literally flashes back and forth) between demon form and normal form. ( although it was really hilarious) I would like you to tell me what I did wrong again. Heres the new lua again wpi.lua Link to comment Share on other sites More sharing options...
Blueberrys Posted April 11, 2015 Share Posted April 11, 2015 @DreadHeadMafia Whooops. My mistake. I joined multiple checks with "and"s which messes up the elseif format I used. Fixed:local function sanity_check(inst) local sanity_cur = inst.components.sanity.current if sanity_cur >= min_sanity.angel then if current_state ~= states.angel then BecomeAngel(inst) current_state = states.angel end elseif sanity_cur >= min_sanity.wilk then if current_state ~= states.wilk then BecomeWilk(inst) current_state = states.wilk end elseif sanity_cur >= min_sanity.demon then if current_state ~= states.demon then BecomeDemon(inst) current_state = states.demon end endend Link to comment Share on other sites More sharing options...
DreadHeadMafia Posted April 11, 2015 Author Share Posted April 11, 2015 @DreadHeadMafia Whooops. My mistake. I joined multiple checks with "and"s which messes up the elseif format I used. Fixed: lol aww man I was up all night trying stuff to fix it, I thought I messed it up badly somehow, anyway thanks a lot mate, that's exactly what I wanted, now im going to fix it up, give some speech in transformation and ill be nearly done with the update for Isaac mod. thanks a ton mate! 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.