Things to remember while writing code (Cleo 4.1)

A list of Cleo coding tips and things that "are supposed to work" but in practice don't work for some reason.

1. "wait 1000" will not work within command callbacks. More info

2. "alloc 0@ 1000" makes sure that the memory region can be used safely by the cleo mod. After using it the 0@ variable will hold an address (which is a number) to the begining of that memory. Most often it's used for storing text from what I see but any type of data can be stored there. To store text at that memory region it's possible to use:
Code:
format 0@ "some text"
To store integer and float next to each other the following opcodes could be used:
Code:
0A8C: write_memory 0@ size 4 value 77 virtual_protect 0
0@ += 4
0A8C: write_memory 0@ size 4 value 77.0 virtual_protect 0

3. A lot of opcodes allow using pointers like the aforementioned 0@ instead of 16-byte strings represented by "0@v" but there are some that accept only "0@v" expressions such as ini file reading opcodes. The "key" value cannot be specified by a passing pointer to it, I guess it could also be the case with section but I didn't test it.
Code:
format 0@v "some text"
0AF4: 29@ = read_string_from_ini_file "CLEO\file.ini" section "my_section" key 0@v // it should work fine

{It wouldn't work with something like that:
alloc 0@ 30
format 0@ "some text"
0AF4: 29@ = read_string_from_ini_file "CLEO\file.ini" section "my_section" key 0@
}

4. Sampfuncs "render" drawing opcodes use integers to define position and size. They represent window resolution pixels (not "game resolution" like 640-480 or something)


Useful resources:
http://blast.hk/wiki/tutorials:list
http://ru.cleo.wikia.com/wiki/Cleo_%D0%B2%D0%B8%D0%BA%D0%B8
(I suggest using google to translate whole websites to read and using the original russian versions to copy+paste the codes)

About this
Please let me know if you find some false information from this post. I invite anyone who has something to add to the list to share and I'll update the post.
 
Top