Page 1 of 1

Cond questions

Posted: March 28th, 2012, 5:17 pm
by Sircameron
So ive been trying to figure out how to get cond to work in a test script and im clueless at this point. Ive read the cubescript reference page, and im familiar with the "else if" statement.. Ive probably editted this script over 60 times trying to get it to work, and decided to post it here to get some help.. Im not asking you to write the script just point out the flaws, so i can figure out what goes where, which containers to use and when.. Or if using another method would be better. I thought about using case but i dont understand it fully.. Anyways here's the script

Code: Select all

 r_script_signal interact [ 
r_global_set $item_counter (+ (r_global_get $item_counter) 1)
echo The item counter is at (r_global_get $item_counter)

if (= (r_global_get $item_counter) $itemlvl) [
itemlvl = [
 cond [= ((r_global_get $item_counter)) 10] [
 echo "you have gained a level with this item"
] [= ((r_global_get $item_counter)) 15] [
 echo "you have gained a level with this item"
] [= ((r_global_get $item_counter)) 25] [
 echo "you have gained a level with this item"
]

]
]

*Editted the brackets, but the cond still isnt working. The problem starts at the if statement. I dont know if im using in the correct way.. Do i need the if statement to run the cond?

Re: Cond questions

Posted: March 28th, 2012, 6:29 pm
by Hirato
case and cond are very similar.
The format is basically, the formats for cond and case is basically
cond cond action cond action cond action ...
case value cond action cond action cond action ...
(notice a pattern there?)

I'm not quite sure what you're trying to do.. but you did put the condition's brackets in the wrong place and effectively changed its format to ...
cond cond [action cond [action cond [ ... ]]

Re: Cond questions

Posted: March 28th, 2012, 7:30 pm
by Sircameron
Cool thanks! The brackets confuse me a lot! i'll rewrite it again, and see what happens.

what im trying to do is every time you "interact" it counts that number, and then after so many times (i.e 5x, 10x, 15x, etc) it sends the echo message..

big picture : items that gain "levels" after so many uses.. Obviously i plan to add/edit it way more. Because right now (even if it did work) it would only tell you that "you've gained a level blah".. Not actually set the level itself..


Just to let you know that im testing it with "r_script_signal interact" so i can make sure its working as intended..