CLEO Help Increment, decrement a value

CLEO related
Status
Not open for further replies.

Wut

Well-known member
Joined
Mar 1, 2013
Messages
338
Reaction score
1
I am a big newbie in CLEO.

I want to declare 2 variables, and if i press key1 the first one will be incremented by 1, if i press key2 the second will be incremented by 1 and if i press key3 both variables will get the value 0.

And i also want the 2 variabiles to be shown on screen, under the money.

In c++ it will be like
int a=0,b=0;

if(key1 is pressed)
a++;
if(key2 is pressed)
b++;
if(key3 is pressed)
{
a=0; b=0;
}

How can I do this in cleo? + Show on screen.
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
271
:KEY1
wait 0 ms
if
0AB0: 49 // first key
jf @KEY2
1@ += 1

:KEY2
wait 0
if
0ab0: 50 // second key
jf @RKEY
2@ += 1


:RKEY
wait 0
if
0ab0: 51 // Reset key
jf @MESSAGE
1@ = 0
2@ = 0

Then add your message with both variables.
 

xzytro

God
Joined
Apr 1, 2013
Messages
2,294
Reaction score
7
L00l springy wrote faster than meh.


Well i don't know how to show them on screen, as i am not so good at textdraws. But here's the scriptflow i would do in this case (almost the same as springfield's one, but our ways of scripting are different somehow) :

Code:
// This file was decompiled using sascm.ini published by Seemann (http://sannybuilder.com/files/SASCM.rar) on 13.10.2007

{$VERSION 3.1.0027}
{$CLEO .cs}

//-------------MAIN---------------
thread 'SUMSINK_SPACHUL' 

:MAIN
:RESET
wait 0
0006: 1@ = 0
0006: 2@ = 0

:CONDITIONS
:CONDITION_OF_1
wait 0
if
0AB0: key_pressed 49 // key 1, not numpad
else_jump @CONDITION_OF_2
jump @IF_PRESSED_1

:CONDITION_OF_2
wait 0
if
0AB0: key_pressed 50 // key 2, not numpad
else_jump @CONDITION_OF_3
jump @IF_PRESSED_2

:CONDITION_OF_3
wait 0
if
0AB0: key_pressed 51 // key 3, not numpad
else_jump @CONDITION_OF_1
jump @RESET

:IF_PRESSED_1
wait 0
000A: 1@ += 1
0085: 1@ = 1@
jump @CONDITIONS

:IF_PRESSED_2
wait 0
000A: 2@ += 1
0085: 2@ = 2@
jump @CONDITIONS
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
271
huehue, yours got too much texts, i might get lost in it :xD: :xD::xD:
Forgot about the screen message. You can use either code, mine or xzytro.


KEY1
wait 0 ms
if
0AB0: 49 // first key
jf @KEY2
1@ += 1

:KEY2
wait 0
if
0ab0: 50 // second key
jf @RKEY
2@ += 1


:RKEY
wait 0
if
0ab0: 51 // Reset key
jf @MESSAGE
1@ = 0
2@ = 0

:MESSAGE
0AC8: 5@ = allocate_memory_size 120
0AD3: string 5@ format "%d %d" 1@ 2@
0AA8: call_function_method 0x6A0050 0xC1B340 num_params 1 pop 0 'CRED369' 6@
0AA5: call 0x718600 2 pop 2 6@ 5@
0342: set_text_draw_centered 1
033F: set_text_draw_letter_size width 0.3 height 1.0
081C: draw_text_outline 1 RGBA 0 0 0 255
0340: set_text_draw_RGBA 255 255 255 255
033E: set_draw_text_position 544.5 167.0 GXT 'CRED369'
0AC9: free_allocated_memory 5@
jump @KEY1
 

Wut

Well-known member
Joined
Mar 1, 2013
Messages
338
Reaction score
1
Code:
{$CLEO .cs}
:Akt
03A4: name_thread 'AKT'
:KEY1
wait 0 ms
if
0AB0: 97 // first key
jf @KEY2
1@ += 1

:KEY2
wait 0
if 
0ab0: 98 // second key
jf @RKEY
2@ += 1


:RKEY
wait 0
if
0ab0: 99 // Reset key
jf @MESSAGE
1@ = 0
2@ = 0

:MESSAGE
0AC8: 5@ = allocate_memory_size 120
0AD3: string 5@ format "%d si %d" 1@ 2@
0AA8: call_function_method 0x6A0050 0xC1B340 num_params 1 pop 0 'CRED369' 6@ 
0AA5: call 0x718600 2 pop 2 6@ 5@
0342: set_text_draw_centered 1
033F: set_text_draw_letter_size width 0.3 height 1.0 
081C: draw_text_outline 1 RGBA 0 0 0 255 
0340: set_text_draw_RGBA 255 255 255 255
033E: set_draw_text_position 544.5 167.0 GXT 'CRED369'
0AC9: free_allocated_memory 5@
jump @KEY1

I get D D text and is kinda flashing, not stable..
If i press numpad1, numpad2 or numpad3 ( the keys ) nothing happens, maybe because D and D is drawn..
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
271
I copied the tex you provided compiled and tested it in game, pressed 1 and 2 and it works :hm: :hm::hm:
OONFuG7.png
 
Status
Not open for further replies.
Top