home home

downloads files

forum forum

docs docs

wiki wiki

faq faq

Cube & Cube 2 FORUM


Cubescript tutorial

by rknigh21 on 12/13/2008 01:56, 2 messages, last message: 12/27/2008 09:27, 1340 views, last view: 05/05/2024 09:26

Here is a cubescript tutorial created with specific emphasis on player interaction with the map and how to use menus (to control doors etc). It has 6 fully worked examples which are also avialable as a download.

http://www.clearcrystal.co.uk/

Hope someone finds it interesting.

Robin

   Board Index   

#1: you're doing it wrong!

by Hirato Kirata on 12/17/2008 12:09

quite an extensive tutorial, I'm busy gonig through it, but it's hard not to say anything about some stuff

loop i 10 [ echo "i holds " $i ]

that is wrong in my books, there's three ways at least in which it can be acceptable, they're as follows

loop i 10 [ echo [i holds $i] ]
loop i 10 [ echo (concatword "i holds " $i) ]
loop i 10 [ echo (format "i holds %1" $i) ]

while [(< $i 10 )] [ echo $i ; i = (+ $i 1)]

the reason the first needs to be in []'s is because it'd only get evaluated once otherwise, observer

while (< $i 10 ) [ echo $i ; i = (+ $i 1)]
while true [ echo 0 ; i = 1]
while true [ echo 1 ; i = 2]
...
while true [ echo 9 ; i = 10]
while true [ echo 10 ; i = 11]

the true is never re evaluated again, unlike like when you gave it
while [(< $i 10 )] [ echo $i ; i = (+ $i 1)]

(< $1 10) is evaluated on each execution, so, it'd end as follows when compared to the above, assuming i == 0

while true [ echo 9 ; i = 10]
while false [ echo 10 ; i = 11]

next problem :P

checkkey = [ If ( = $greenkey 1 ) [ echo "You have the key"] ["Try to find the key"]]

you're missing an echo in the second pair of []'s :P

note that checkey = [ echo (if (= $greenkey 1) "You have the key" "Try to find the key")] should be equivalent :)

same can be said for the second instance that uses $arg1 for it's validation

level_trigger_22 = [ Echo "You fired the trigger "]

sauer is case sensitive, Echo is an invalid command

I skimmed the rest, couldn't find any faults in the brief skimming :)

though you may wait to mention there are floating point variations of the commands if you add an 'f' suffix, ie (+f 1.1 2.4123)

the full list of functions are as follows

+ - add
- - subtract
* - multiply
div - division
mod - modulous
= - equality test
!= - inequality test
< - less than
> - greater than
<= - less than or equal
>= - greater than of equal
^ - either, but it can't be both or neither
! - swaps true and false
min - returns the variable with the lowest value
max returns varaible with highest value
&& - checks if both are true
|| - checks if either ot both are true

there's string commands too like strstr (sees if given text is in a string, -1 if false), strcmp, strreplace, and obviously concat, concatword, format, at, push, pop, substr, listlen, getalias, result

lastly, I'm surprised you didn't do anything on the @ stuff

an example

mainmenu = [
guitext "This is a menu w00t!"
guibar
guibutton "I am button! click me!" "cleargui"
]

newgui main [@mainmenu]

hope this all helps you improve your tutorial :)

reply to this message

#2: Thanks

by rknigh21 on 12/27/2008 09:27

Hi Hirato

Thanks for you comments. I will revise the tutorial over the next few days.

Although if SP mode is dropped this will all become a bit academic.

Thanks again Robin

reply to this message

   Board Index   


Unvalidated accounts can only reply to the 'Permanent Threads' section!


content by Aardappel & eihrul © 2001-2024
website by SleepwalkR © 2001-2024
53867523 visitors requested 71642682 pages
page created in 0.019 seconds using 10 queries
hosted by Boost Digital