bull.04 Posted September 5, 2011 Share Posted September 5, 2011 Is the player's health variable considered and integer or a float? I've been having problems with that. Link to comment Share on other sites More sharing options...
UNRATED69 Posted September 5, 2011 Share Posted September 5, 2011 I believe it's an integer. Link to comment Share on other sites More sharing options...
bull.04 Posted September 5, 2011 Author Share Posted September 5, 2011 Alright cool, thanks. Also, how would I go about drawing it in numbered text? I have a small script maybe you could diagnose. {$CLEO .cs}thread 'TXTHLTH'[email protected] = 1:TXTHLTH_1wait 0ifPlayer.Defined($PLAYER_CHAR)jf @TXTHLTH_1ifPlayer.Controllable($PLAYER_CHAR)jf @[email protected] = Actor.Health($PLAYER_ACTOR)0092: [email protected] = float [email protected] to_integer 0095: make [email protected] absolute_integerjump @TXTHLTH_3:TXTHLTH_2wait 0if0062: [email protected] -= [email protected] // (int) jf @TXTHLTH_6 jump @TXTHLTH_3:TXTHLTH_6wait 0if005A: [email protected] += [email protected] // (int) jf @TXTHLTH_2jump @TXTHLTH_4:TXTHLTH_3wait [email protected] >= 20jf @TXTHLTH_40512: show_permanent_text_box 'HLTH2' // Player's Health if it gets below 20.jump @TXTHLTH_2:TXTHLTH_4wait [email protected] <= 20jf @TXTHLTH_503E6: remove_text_box0512: show_permanent_text_box 'HLTH1' // Player's Health if it gets above 20.jump @TXTHLTH_2:TXTHLTH_5wait 0ifActor.Dead($PLAYER_ACTOR)jf @TXTHLTH_403E6: remove_text_box 0512: show_permanent_text_box 'HLTH3' // Player's Health if he dies.jump @TXTHLTH_2 And here is my GXT: HLTH1 ~g~HEALTH: ~1~~w~HLTH2 ~r~HEALTH: ~1~~w~HLTH3 ~b~HEALTH: ~1~~w~ Anyways, if you can't thats fine. Just wondering and trying to get some learning about integers and floats. Link to comment Share on other sites More sharing options...
UNRATED69 Posted September 5, 2011 Share Posted September 5, 2011 Try this. {$CLEO .cs}thread 'TXTHLTH' :TXTHLTH_11wait 0 if Player.Defined($PLAYER_CHAR)else_jump @TXTHLTH_11 [email protected] = Actor.Health($PLAYER_ACTOR)if not [email protected] > 20 else_jump @TXTHLTH_106 if [email protected] > 1 else_jump @TXTHLTH_137 045A: draw_text_1number 50.0 50.0 GXT 'HLTH3' number [email protected] jump @TXTHLTH_11 :TXTHLTH_106045A: draw_text_1number 50.0 50.0 GXT 'HLTH1' number [email protected] jump @TXTHLTH_11 :TXTHLTH_137045A: draw_text_1number 50.0 50.0 GXT 'HLTH2' number [email protected] jump @TXTHLTH_11 Link to comment Share on other sites More sharing options...
bull.04 Posted September 5, 2011 Author Share Posted September 5, 2011 (edited) It worked but it crashes after about 5 seconds in game. Don't know whats causing it but it's weird... UPDATE: I got the loops working, now it isn't counting changes in health. When it meets the [email protected] < 20 check it crashes, instead of displaying my health. Edited September 5, 2011 by bull.04 Link to comment Share on other sites More sharing options...
spaceeinstein Posted September 6, 2011 Share Posted September 6, 2011 Always check the original script. Surely the game has done this before. An integer value is returned when reading your health. If you want to use UNRADTED's code, don't use 045A. Link to comment Share on other sites More sharing options...
bull.04 Posted September 6, 2011 Author Share Posted September 6, 2011 (edited) What opcode should I use for it? EDIT: I stored the health to an integer and changed the text drawing. But it still crashes. {$CLEO .cs}thread 'TXTHLTH'[email protected] = 1 :TXTHLTH_1wait 0 if Player.Defined($PLAYER_CHAR)jf @TXTHLTH_1ifPlayer.Controllable($PLAYER_CHAR)jf @[email protected] = Actor.Health($PLAYER_ACTOR)0084: [email protected] = [email protected] // (int)jump @TXTHLTH_4:TXTHLTH_4 wait 0if0184: actor $PLAYER_ACTOR health >= 20jf @TXTHLTH_5033F: set_text_draw_letter_size 0.6 2.6 033E: set_draw_text_position 550.0 350.0 GXT 'HLTH1' // HEALTH: 045A: draw_text_1number 550.0 375.0 GXT 'HLTH4' number [email protected] // ~1~%jump @TXTHLTH_4:TXTHLTH_5wait 0if8184: not actor $PLAYER_ACTOR health >= 20jf @TXTHLTH_6033F: set_text_draw_letter_size 0.6 2.6 033E: set_draw_text_position 550.0 350.0 GXT 'HLTH2' // HEALTH: 045A: draw_text_1number 550.0 375.0 GXT 'HLTH5' number [email protected] // ~1~%jump @TXTHLTH_4:TXTHLTH_6wait 0if8184: not actor $PLAYER_ACTOR health >= 1jf @TXTHLTH_4033F: set_text_draw_letter_size 0.6 2.6 033E: set_draw_text_position 550.0 350.0 GXT 'HLTH3' // HEALTH: 045A: draw_text_1number 550.0 375.0 GXT 'HLTH6' number [email protected] // ~1~%jump @TXTHLTH_4 Edited September 6, 2011 by bull.04 Link to comment Share on other sites More sharing options...
bull.04 Posted September 6, 2011 Author Share Posted September 6, 2011 Now all I need is a way to update an integer. I tried opcode 0627 but it didn't yield results. I declared [email protected] as the Players health, then transferred [email protected] to [email protected] through an integer and now I need a way to update the integer. EDIT: CRAP! Sorry I accidentally double posted. Meant to edit. Link to comment Share on other sites More sharing options...
spaceeinstein Posted September 6, 2011 Share Posted September 6, 2011 (edited) Use 01E5. Text_high/lowpriority opcodes are easier to use than draw_text. This makes no sense: [email protected] = Actor.Health($PLAYER_ACTOR)0084: [email protected] = [email protected] // (int) You're setting [email protected] as equal to [email protected], which is not defined anywhere, so you'll always get "0" in return. If you want [email protected] = [email protected], it is redundant. You're not using [email protected] anywhere else, only in this code. So just use [email protected] Edited September 6, 2011 by spaceeinstein Link to comment Share on other sites More sharing options...
bull.04 Posted September 6, 2011 Author Share Posted September 6, 2011 Use 01E5. Text_high/lowpriority opcodes are easier to use than draw_text. This makes no sense: [email protected] = Actor.Health($PLAYER_ACTOR)0084: [email protected] = [email protected] // (int) You're setting [email protected] as equal to [email protected], which is not defined anywhere, so you'll always get "0" in return. If you want [email protected] = [email protected], it is redundant. You're not using [email protected] anywhere else, only in this code. So just use [email protected] Oh I thought I was transferring [email protected] to [email protected] aka converting it into an integer, so I guess it has always been an integer. Also, I declared [email protected] as 100 in the beginning, but that also didn't work so yeah. Also, it looks as if 01E5 doesn't have text positioning. Is there a way to position that text? Link to comment Share on other sites More sharing options...
spaceeinstein Posted September 6, 2011 Share Posted September 6, 2011 (edited) Oh, I didn't know that you wanted custom text. Here's a working code: {$CLEO .cs}constHEALTH = [email protected] // reading a variable as a word is better than as a numberend0000:while true wait 0 if Player.Defined($PLAYER_CHAR) then if Player.Controllable($PLAYER_CHAR) then HEALTH = Actor.Health($PLAYER_ACTOR) // stores an integer value of the player's health if HEALTH >= 20 // if the value (your health) is greater than 20 then 033F: set_text_draw_letter_size 0.6 2.6 033E: set_draw_text_position 550.0 350.0 GXT 'HLTH1' // HEALTH: 045A: draw_text_1number 550.0 375.0 GXT 'HLTH4' number HEALTH // ~1~% end if and 20 > HEALTH // if the value is between 1 and 20 HEALTH >= 1 then 033F: set_text_draw_letter_size 0.6 2.6 033E: set_draw_text_position 550.0 350.0 GXT 'HLTH2' // HEALTH: 045A: draw_text_1number 550.0 375.0 GXT 'HLTH5' number HEALTH // ~1~% end if 1 > HEALTH // if the value is less than 1 then 033F: set_text_draw_letter_size 0.6 2.6 033E: set_draw_text_position 550.0 350.0 GXT 'HLTH3' // HEALTH: 045A: draw_text_1number 550.0 375.0 GXT 'HLTH6' number HEALTH // ~1~% end 03F0: text_draw_toggle 0 end endend The main problem with text_draw in loops is that you have to place "03F0: text_draw_toggle 0" at least once in a loop containing a text_draw opcode. Another problem is your original code only read your health once. It did not loop back to TXTHLTH_1 to reread your health again. Edited September 6, 2011 by spaceeinstein Link to comment Share on other sites More sharing options...
Silent Posted September 6, 2011 Share Posted September 6, 2011 The main problem with text_draw in loops is that you have to place "03F0: text_draw_toggle 0" at least once in a loop containing a text_draw opcode. Another problem is your original code only read your health once. It did not loop back to TXTHLTH_1 to reread your health again. I think the proper use is to use this opcode ONCE with param 1. But, it's a good idea to loop it in CLEOs, when you're not sure if SCM thread will mess with it, for example. Link to comment Share on other sites More sharing options...
spaceeinstein Posted September 6, 2011 Share Posted September 6, 2011 I'm unsure how SA works, but in VC, text_draws stay permanent on the screen unless you use 03F0: 0 to clear all text, especially important if you loop your code. Without it, the game will keep drawing additional text overlapping the previous ones until it reaches the limit and freezes the game. Link to comment Share on other sites More sharing options...
Silent Posted September 6, 2011 Share Posted September 6, 2011 In SA enable_text_draw 1 makes it draw only for one frame, makes it obsolete to loop the opcode (unless you make a CLEO script, when you are unsure how the flag is set by SCM threads/other CLEOs). VC may have a worse system though. Link to comment Share on other sites More sharing options...
bull.04 Posted September 6, 2011 Author Share Posted September 6, 2011 (edited) So the toggle only works once? I just wanted to use the draw_text_1number and size and position that then make the toggle loop. But that is obsolete in SA? Makes sense I guess. I will try spaceeinsteins code real quick and get back with results. EDIT: Oh spaceeinsteins uses the same basic concept as mine. So is there any way to size and position high priority text? That's all I need to do now, seeing as I put it to read the Actor's health before every text render and it worked with high priority text. EDIT: YESS! I GOT IT! The toggle actually worked big time, but the reason it stayed at 100 is because I forgot to change the variable the text read and I had a [email protected] variable at the beginning of the script set to 100 and no decreasing. Edited September 6, 2011 by bull.04 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