lynxcali Posted February 25, 2011 Author Share Posted February 25, 2011 (edited) No problem about your code dude. And ughh still not working. Heres my code right now:scn aaPrisonMessageTest short controlvar short button Begin ScriptEffectStart if ( controlvar == 0 ) MessageBox "Which cell would you like the prisoner to be sent to?", "Cell 1", "Cell 2", "Cell 3", "Cancel" set controlvar to 1 endif end Begin GameMode if ( controlvar == 1 ) set button to GetButtonPressed if ( button == 0 ) moveto PrisonCell1 set controlvar to 0 elseIf ( button == 1) moveto PrisonCell2 set controlvar to 0 elseif ( button == 2) moveto PrisonCell3 set controlvar to 0 elseif ( button == -1 ) return set controlvar to 0 endif endif end Edited February 25, 2011 by lynxcali Link to comment Share on other sites More sharing options...
fg109 Posted February 25, 2011 Share Posted February 25, 2011 Well I just went into my game and tested my code. It worked just fine for me... I even used it on 3 different NPCs. When you made the spell, did you remember to set the duration? If you leave it at 0, it will never get the choice you made, not unless you're so fast you can click the menu button in the same frame you cast the spell. Set it to something like 5 seconds. If that's not the problem, maybe it's actually working and you just don't know it. When I tried it out, the one of the NPCs disappeared for 1 second and then reappeared, probably because his AI packages told him he had to be in his house at that time of day... Anyway, try this code: scriptname aaPrison short menushown short choice Begin ScriptEffectStart MessageBox "Which cell do you send the prisoner?" "Cell 1" "Cell 2" "Cell 3" "Cancel" set menushown to 1 set choice to -1 End Begin ScriptEffectUpdate if menushown == 1 set choice to GetButtonPressed if choice == -1 Return elseif choice == 0 RemoveScriptPackage AddScriptPackage "name of your stay-in-prison package" MoveTo PrisonCell1 elseif choice == 1 RemoveScriptPackage AddScriptPackage "name of your stay-in-prison package" MoveTo PrisonCell2 elseif choice == 2 RemoveScriptPackage AddScriptPackage "name of your stay-in-prison package" MoveTo PrisonCell3 endif set menushown to 0 endif End Link to comment Share on other sites More sharing options...
lynxcali Posted February 25, 2011 Author Share Posted February 25, 2011 Well I just went into my game and tested my code. It worked just fine for me... I even used it on 3 different NPCs. When you made the spell, did you remember to set the duration? If you leave it at 0, it will never get the choice you made, not unless you're so fast you can click the menu button in the same frame you cast the spell. Set it to something like 5 seconds. If that's not the problem, maybe it's actually working and you just don't know it. When I tried it out, the one of the NPCs disappeared for 1 second and then reappeared, probably because his AI packages told him he had to be in his house at that time of day... Anyway, try this code: scriptname aaPrison short menushown short choice Begin ScriptEffectStart MessageBox "Which cell do you send the prisoner?" "Cell 1" "Cell 2" "Cell 3" "Cancel" set menushown to 1 set choice to -1 End Begin ScriptEffectUpdate if menushown == 1 set choice to GetButtonPressed if choice == -1 Return elseif choice == 0 RemoveScriptPackage AddScriptPackage "name of your stay-in-prison package" MoveTo PrisonCell1 elseif choice == 1 RemoveScriptPackage AddScriptPackage "name of your stay-in-prison package" MoveTo PrisonCell2 elseif choice == 2 RemoveScriptPackage AddScriptPackage "name of your stay-in-prison package" MoveTo PrisonCell3 endif set menushown to 0 endif End Ahhh wow that was the problem....the duration was at 0...I changed it to 5, thank you so much my code works now. I will add you to the credits of my mod as soon as I upload it. Link to comment Share on other sites More sharing options...
fore Posted February 25, 2011 Share Posted February 25, 2011 No problem about your code dude. And ughh still not working. Heres my code right now:scn aaPrisonMessageTest short controlvar short button Begin ScriptEffectStart if ( controlvar == 0 ) MessageBox "Which cell would you like the prisoner to be sent to?", "Cell 1", "Cell 2", "Cell 3", "Cancel" set controlvar to 1 endif end Begin GameMode if ( controlvar == 1 ) set button to GetButtonPressed if ( button == 0 ) moveto PrisonCell1 set controlvar to 0 elseIf ( button == 1) moveto PrisonCell2 set controlvar to 0 elseif ( button == 2) moveto PrisonCell3 set controlvar to 0 elseif ( button == -1 ) return set controlvar to 0 endif endif end 2 Problems I see in your code right away:The 2nd block in a magic effect script is called ScriptEffectUpdate, not Gamemode moveto has no reference. You have to assign the target of the magic effect in the ScriptEffectStart Block (Set target to getself) and then use it for for the movetos (target.moveto ...)Hope that helps. Link to comment Share on other sites More sharing options...
lynxcali Posted February 25, 2011 Author Share Posted February 25, 2011 No problem about your code dude. And ughh still not working. Heres my code right now:scn aaPrisonMessageTest short controlvar short button Begin ScriptEffectStart if ( controlvar == 0 ) MessageBox "Which cell would you like the prisoner to be sent to?", "Cell 1", "Cell 2", "Cell 3", "Cancel" set controlvar to 1 endif end Begin GameMode if ( controlvar == 1 ) set button to GetButtonPressed if ( button == 0 ) moveto PrisonCell1 set controlvar to 0 elseIf ( button == 1) moveto PrisonCell2 set controlvar to 0 elseif ( button == 2) moveto PrisonCell3 set controlvar to 0 elseif ( button == -1 ) return set controlvar to 0 endif endif end 2 Problems I see in your code right away:The 2nd block in a magic effect script is called ScriptEffectUpdate, not Gamemode moveto has no reference. You have to assign the target of the magic effect in the ScriptEffectStart Block (Set target to getself) and then use it for for the movetos (target.moveto ...)Hope that helps. Can you explain number 2 a bit more please? Lost me there. Link to comment Share on other sites More sharing options...
fore Posted February 25, 2011 Share Posted February 25, 2011 Can you explain number 2 a bit more please? Lost me there. No, sorry, I take this back. I was under the impression that you can omit a reference for a command (like in '[reference].moveto') only in scripts which are attached to an object. But apparently this also works for MagicEffect scripts. The Wiki doesn't list MagicEffect scripts as ReferenceScripts, so I was alwasy using a ref variable for the target. Never stop learning. :wink: Link to comment Share on other sites More sharing options...
lynxcali Posted February 25, 2011 Author Share Posted February 25, 2011 Can you explain number 2 a bit more please? Lost me there. No, sorry, I take this back. I was under the impression that you can omit a reference for a command (like in '[reference].moveto') only in scripts which are attached to an object. But apparently this also works for MagicEffect scripts. The Wiki doesn't list MagicEffect scripts as ReferenceScripts, so I was alwasy using a ref variable for the target. Never stop learning. :wink: So I dont need to do this then? Sweet :) Link to comment Share on other sites More sharing options...
Recommended Posts