CubeScript syntax highlighter
#1
Something we should really have done some time ago...
The php code button on the post editor has now been replaced with a CubeScript button:
[Image: IB8BY.gif]
You can also manually use the [noparse][cubescript][/cubescript][/noparse] tags to the same effect. This will highlight your cubescript keywords in pretty colours, all thanks to Luc4s (and some modification of a nice plugin by CrazyCat)
Example:

[cubescript]// CubeScript placed in this file is automatically executed on each startup.

// "editent" command:
// This command collects all the attributes of the nearest entity, and then
// prompts that into a handy command that allows you to edit that entities
// attributes easily.
// Note: The editent command can NOT define rotation/yaw inside the command!
// However, the current yaw of the player will define the rotation/yaw when
// using the command!
alias editent [
if (strcmp (getenttype) "mapmodel") [
saycommand "/entset" (getenttype) (getentattr 1) (getentattr 2) (getentattr 3)
] [
if (> (findlist "light sound clip plclip" (getenttype)) -1) [
saycommand "/entset" (getenttype) (getentattr 0) (getentattr 1) (getentattr 2) (getentattr 3)
] [
saycommand "/entset" (getenttype) (getentattr ((> (findlist "playerstart ctf-flag" (getenttype)) -1)))
] ] ]

// "convertclips" command:
// This command automatically changes the a "clip" to a "plclip" entity or vice-versa.
alias convertclips [
if (strcmp (getenttype) "clip") [
entset plclip (getentattr 0) (getentattr 1) (getentattr 2) (getentattr 3)
] [
if (strcmp (getenttype) "plclip") [
entset clip (getentattr 0) (getentattr 1) (getentattr 2) (getentattr 3)
] [
echo "No changes made. This entity isn't a clip or a plclip."
echo "Try using the /closestenttype command to find a specific entity."
] ] ][/cubescript]

edit: Also, in order to show the [noparse][cubescript][/noparse] tags in my post, I added the noparse plugin by Ad Bakker, which forces the forum to ignore mycode tags if you put them inside [noparse][noparse][/noparse][/noparse] tags.
Thanks given by:
#2
Nice :) Now we can actually make proper use of code tags for more than just blacklisting posts ;)
Thanks given by:
#3
You ought to release this so people like me can install it on their forums ;)
Thanks given by:
#4
(30 Oct 11, 09:41PM)Ronald_Reagan Wrote: You ought to release this so people like me can install it on their forums ;)

I would really appreciate it if you did this Luc4s. :D
Thanks given by:
#5
"Awesome."
Thanks given by:
#6
Thank you!
Thanks given by:
#7
I still need to update the GeSHi-codetag on the wiki to use the new code. My PC's power-supply gave out on Sunday though, so I didn't have a chance to do it till now :-P
Done now. Thanks for the work!
And before people re-ask for the code, without going to the wiki-page where the link is; I know you, you know!? :-P
CubeScript for GeSHI-source
Thanks given by:
#8
Ahhh, I had a disconnect between the crazycat plugin and the GeSHI file. Aka I noobed up and thought a lot more was done than it really was.
Thanks given by:
#9
[cubescript]alias goodjob [say "This is great!"][/cubescript]

/goodjob
Thanks given by:
#10
The myBB-plugin even has an awesome extra feature, which - if feasible - should find it's way into the wiki too. Research still pending there, though. Just hover over the "say"-command in the following, more modern syntax as opposed to Viper's code above:
[cubescript]
goodjob = [ say "This is great" ]
[/cubescript]
Seems alias is somehow not recognized/defined by our current (at time of writing) definition, so keep watching out for things like this and help us fine-tune it! Anyway - two things about the updated script line. For one, alias X Y and X = Y are the same, the latter just more conform to most other languages & shorter; secondly there've been known issues with Macintosh and leaving out the spaces .. so, if in doubt, go with the spaces-padding inside a CubeScript-block!
Thanks given by:
#11
flowtron, I used = first but got no special syntax highlighting so I switched to "alias" for the effect, haha.
Thanks given by: