Smorg Posted October 20, 2006 Share Posted October 20, 2006 (edited) Look at this function... expandcollapse popupFunc GetLife($Direction, ByRef $Timer ) Select Case $Direction = "up" For $Search = $HealthPixel - $Top To 0 Step - 1 $HealthColor = PixelGetColor($HealthX, $Search + $Top) If ($HealthColor <> $HealthRef[$Search]) And ($HealthColor <> $PsnRef[$Search]) Or $Search = 0 Then $LifePercent = Round(100 * (($Bottom - ($Search + $Top)) / ($Bottom - $Top))) If $Search = 0 Then Return $Top Else Return $Search + $Top + 1 EndIf ExitLoop EndIf Next Case $Direction = "down" For $Search = $HealthPixel - $Top To $Bottom - $Top $HealthColor = PixelGetColor($HealthX, $Search + $Top) If ($HealthColor = $HealthRef[$Search]) Or ($HealthColor = $PsnRef[$Search]) Or $Search = $Bottom Then $LifePercent = Round(100 * (($Bottom - ($Search + $Top)) / ($Bottom - $Top))) If $Search = $Bottom - $Top Then Return $Bottom Else Return $Search + $Top EndIf ExitLoop EndIf Next EndSelect msgbox(0, "blubby", "blub") Exit If $Timer = 1 Then If TimerDiff($Sleep) > $DrinkDelay Then $Timer = 0 EndIf If $Timer = 0 Then If ($LifePercent < $LifeRpotDrinkPercent) And ($LifePercent > $LifeFpotDrinkPercent) Then msgbox(0, "blubby", "blub") ;debug Exit ;debug Drink(1) $Timer = 1 $Sleep = TimerInit() ElseIf $LifePercent < $LifeFpotDrinkPercent Then Drink(0) $Timer = 1 $Sleep = TimerInit() EndIf EndIf If $LifePercent < $ChickenPercent Then Chicken() EndFunc ;==>GetLife Notice where i put the debugging message box... nothing below that ever gets executed. I execute the function, but after the EndSelect, it exits the function. Why?!? it should show the message box, then close the script. Instead it continues as normal without showing the box. Edited October 20, 2006 by Smorg Link to comment Share on other sites More sharing options...
cppman Posted October 20, 2006 Share Posted October 20, 2006 (edited) hmm... that message box comes up for me.. It could be possible because of those "returns" that you have in it, beause if those if statements are true, it returns from the function. Edited October 20, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
Smorg Posted October 20, 2006 Author Share Posted October 20, 2006 (edited) hm, maybe it has to do with my timer... still trying to figure it out. EndSelect doens't end the function though right? aah you are probably right. Return exits a function? I'll try byref instead of return. It returns a var called $HealthRef. I wanted to try to do this so that i can make that not a global var. I wish there was a way to do this without globals. Edited October 20, 2006 by Smorg Link to comment Share on other sites More sharing options...
jinxter Posted October 20, 2006 Share Posted October 20, 2006 (edited) EndSelect msgbox(0, "blubby", "blub") Exit exit means exit. Edited October 20, 2006 by jinxter > there are 10 types of people in the world, those who understand binary and those who don't. Link to comment Share on other sites More sharing options...
Smorg Posted October 20, 2006 Author Share Posted October 20, 2006 Yes, thats just there so it doesn't continue for debugging. (it would have to reactivate the window i'm working with) Link to comment Share on other sites More sharing options...
jinxter Posted October 20, 2006 Share Posted October 20, 2006 aha... sowwy the problem is that it doesn't show the dialog box, or ? how do you call the function ? > there are 10 types of people in the world, those who understand binary and those who don't. Link to comment Share on other sites More sharing options...
Smorg Posted October 20, 2006 Author Share Posted October 20, 2006 (edited) haha thanks guys i'm an idiot... return doesn't just return something, it leaves the func at the same time. Edited October 20, 2006 by Smorg Link to comment 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