Yurtiel Posted March 10, 2014 Share Posted March 10, 2014 I don't know if I'm just being retarded and missing something super obvious or what but I seem to be having a problem in a dice roller I'm making that it won't switch states. What I want to happen: The script recieves a message from a script in a linked prim (Via llmessagelinked and link_message)When the message is recieved, I want it to run through the if's as listed, and then switch to the appropriate state for what the message might be, below is the code as I have it now, and yes I know it can be condensed but I did it this way because I can't figure this problem out and I was trying to get it to work. What it is actually doing: It gets the message from the other script from the linked prim named "Class" it then rolls like it's supposed to for state ftr_st, however, if class is changed to "Scout" it is still rolling as if it were in state ftr_st.Please if you know, what the hell am I missing? I've been at this for two hours now and it's getting infuriating. string nOwn; string gOwn; string dOwn; default { state_entry() { dOwn = llDetectedKey(0); gOwn = llGetOwner(); nOwn = llKey2Name(gOwn); } link_message(integer class, integer number, string msg, key id) { if (msg = "Fighter") { state ftr_st; return; } else if (msg = "Scout") { state sct_st; return; } } } state ftr_st { touch_start(integer ftr) { integer roll = (integer)(llFrand(21)); integer r = roll; integer ttl = r += 4; integer ttl2= r += 3; integer ttl3= r += 2; integer ttl4= r += 1; integer ttl5= r += 0; if (roll == 0) roll = 1; if (roll == 1) { llSay (0, "Critical Fail! " + nOwn + " Rolled a Str Check of " + (string)roll + " + 4 equaling " + (string)ttl); state ftr_st; } if (roll == 21) roll = 20; if (roll == 20) { llSay (0, "Critical Success! " + nOwn + " Rolled a Str Check of " + (string)roll + " + 4 equaling " + (string)ttl); state ftr_st; } else { llSay(0, nOwn + " Rolled a Str Check of " + (string)roll + " + 4 equaling " + (string)ttl); state ftr_st; } } } state sct_st { touch_start(integer sct) { integer roll = (integer)(llFrand(21)); integer r = roll; integer ttl = r += 4; integer ttl2= r += 3; integer ttl3= r += 2; integer ttl4= r += 1; integer ttl5= r += 0; if (roll == 0) roll = 1; if (roll == 1) { llSay (0, "Critical Fail! " + nOwn + " Rolled a Str Check of " + (string)roll + " + 1 equaling " + (string)ttl4); state sct_st; } if (roll == 21) roll = 20; if (roll == 20) { llSay (0, "Critical Success! " + nOwn + " Rolled a Str Check of " + (string)roll + " + 1 equaling " + (string)ttl4); state sct_st; } else { llSay(0, nOwn + " Rolled a Str Check of " + (string)roll + " + 1 equaling " + (string)ttl4); state sct_st; } } } Link to comment Share on other sites More sharing options...
Jenny Siddeley Posted March 10, 2014 Share Posted March 10, 2014 A common mistake we all do from time to time. You just forgot an "=" in your if conditions. It should be : if (msg == "Fighter") and else if (msg == "Scout") 1 Link to comment Share on other sites More sharing options...
Yurtiel Posted March 10, 2014 Author Share Posted March 10, 2014 Thanks I missed that part, I amended it but I'm still having the same problem. [13:43] Lifestream Character Sheet HUD: Yurtiel Resident set class to Fighter [13:43] Lifestream Character Sheet HUD: Yurtiel Resident Rolled a Str Check of 14 + 4 equaling 18 ^ This part is correct, that's how it's supposed to work when set to fighter. [13:43] Lifestream Character Sheet HUD: Yurtiel Resident set class to Scout [13:43] Lifestream Character Sheet HUD: Yurtiel Resident Rolled a Str Check of 2 + 4 equaling 6 ^ This is the part I'm having a headache over, when the class is set to scout (Via the Class prim/button) it's supposed to switch it to "Yurtiel Resident rolled a Str check of (num) + 1 equalling (total) But it doesn't seem to be switching the state to state sct_st when it recieves that message, and from what I see the code is perfect (With the addition of that extra equal sign that is) and it should switch between the two states and be fine. But it's like it's getting the message from the llMessageLinked and instead of going through if (msg=="Scout") It's going If(msg=="Fighter") setting the state to fighter (When it's not supposed to) and then won't go forward in the script. Or like it's misinterpretting if(msg=="Scout") as if(msg=="Fighter") Link to comment Share on other sites More sharing options...
Ron Khondji Posted March 10, 2014 Share Posted March 10, 2014 If there's no link_message event in a state then the script can not receive any linked messages while in that state. You need to have a link_message event in every state. 1 Link to comment Share on other sites More sharing options...
Yurtiel Posted March 10, 2014 Author Share Posted March 10, 2014 Sorry I think I'm missing something with that? Why do I need one in each state if the first state is switching it to the other state and already has the link_message handle? Also how would I even code that? state sct_st { link_message(integer class, integer number, string msg, key id) {} touch start is apparently acceptable for the script but it leaves me with the same problem I've been having. link_message(integer class, integer number, string msg, key id) { * if(msg == "Scout") { touch_start gives me an error message at *. Link to comment Share on other sites More sharing options...
Yurtiel Posted March 10, 2014 Author Share Posted March 10, 2014 NVM I figured it out good sir, you are indeed correct, thank you very much for the help. I also had to add if(msg == (string) state (state integer) in each state as well under the link_message. Much thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now