Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This file gets executed every time you start AssaultCube.
- // This is where you should put any scripts you may have created for AC.
- // findchar string char int - Returns int
- findchar = [
- charposition = -1; dupes = 0
- loop fcl (strlen $arg1) [ if (strcmp (substr $arg1 $fcl 1) $arg2) [ += dupes 1; if (> $dupes $arg3) [ charposition = $fcl; break ] ] ]
- result $charposition
- ]
- // echo (findchar AssaultCube s 0) // Output: 1
- // echo (findchar AssaultCube s 1) // Output: 2
- // echo (findchar AssaultCube s 2) // Output: -1
- // echo (findchar AssaultCube z 0) // Output: -1
- // countchar string char - Returns int
- countchar = [
- chars = 0
- loop ccl (strlen $arg1) [ if (strcmp (substr $arg1 $ccl 1) $arg2) [ += chars 1 ] ]
- result $chars
- ]
- // echo (countchar AssaultCube s) // Output: 2
- // echo (countchar Mississippi i) // Output: 4
- // echo (countchar "lol what!" p) // Output: 0
- // haschar string char - Returns bool
- haschar = [
- bool = 0
- loop ccl (strlen $arg1) [ if (strcmp (substr $arg1 $ccl 1) $arg2) [ bool = 1; break ] ]
- result $bool
- ]
- // echo (haschar AssaultCube C) // Output: 1
- // echo (haschar AssaultCube c) // Output: 0
- // inschar string string position - Returns string
- inschar = [
- output = ""
- if (<= $arg3 (- (strlen $arg1) 1)) [
- loop icl (strlen $arg1) [
- if (= $icl $arg3) [
- output = (concatword $output $arg2 (substr $arg1 $icl 1))
- ] [
- output = (concatword $output (substr $arg1 $icl 1))
- ]
- ]
- result $output
- ] [ result -1 ]
- ]
- // echo (inschar "hello world" " cruel" 5) // Output: hello cruel world
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement