fixes/added MDArray_Add_To_Subarray
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6825 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
+31
-1
@@ -30,6 +30,15 @@ getQuotePosition = [
|
||||
]
|
||||
]
|
||||
|
||||
removeLeadingWhitespace = [
|
||||
newstr = ""; gotchar = 0
|
||||
loop re (strlen $arg1) [
|
||||
if (&& (! $gotchar) (! (testchar (substr $arg1 $re 1) 7))) [ gotchar = 1 ]
|
||||
if $gotchar [ newstr = (concatword $newstr (substr $arg1 $re 1)) ]
|
||||
]
|
||||
result $newstr
|
||||
]
|
||||
|
||||
reverseString = [
|
||||
oldstr = $arg1
|
||||
newstr = ""
|
||||
@@ -162,7 +171,7 @@ MDArray_Delete_Subarray = [
|
||||
]
|
||||
]
|
||||
]
|
||||
delstr = (substr $orig_array $target_pos (- $gotclose $target_pos))
|
||||
delstr = (substr $orig_array $target_pos (- (+ $gotclose 1) $target_pos))
|
||||
$arg1 = (strreplace $orig_array $delstr "")
|
||||
result (getalias $arg1)
|
||||
]
|
||||
@@ -196,5 +205,26 @@ MDArray_Modify_Subarray = [
|
||||
]
|
||||
]
|
||||
|
||||
MDArray_Add_To_Subarray = [
|
||||
mdarray = (getalias $arg1)
|
||||
target_sub = (findlist $mdarray $arg2)
|
||||
to_add = $arg3
|
||||
|
||||
if (!= $target_sub -1) [
|
||||
subarray = (MDArray_Get $arg1 $arg2 -1)
|
||||
if (islists $to_add) [
|
||||
if (islists $subarray) [ newarray = (concat $subarray $to_add) ] [
|
||||
newarray = (concat (addpunct $subarray) $to_add)
|
||||
]
|
||||
] [
|
||||
if (islists $subarray) [ newarray = (concat $subarray (addpunct $to_add)) ] [
|
||||
newarray = (concat (addpunct $subarray) (addpunct $to_add))
|
||||
]
|
||||
]
|
||||
MDArray_Delete_Subarray $arg1 $arg2
|
||||
MDArray_New_Subarray $arg1 $arg2 (removeLeadingWhitespace $newarray)
|
||||
]
|
||||
]
|
||||
|
||||
// some of these aliases can cause issues if they get stored in saved.cfg (missing bracket errors/etc.)
|
||||
addListOnQuit "bool MDArray_New_Subarray MDArray_Get_Bracket_Positions MDArray_Get reverseString MDArray_Get_All_Opening_Bracket_Positions MDArray_Get_Subarray_Count MDArray_Get_All_Subarray_Names extractSubarrayName MDArray_Search MDArray_Delete_Subarray MDArray_Modify_Subarray original_subarray target_elem new_elem new_subarray j next_elem islists hasQuotePair got_open_quote got_close_quote r i d mdarray subarray firstchar lastchar oldstr newstr subarray_names subarray_name tmpchar token subarrays search_results curarray orig_array target_subarray target_pos gotclose delstr h next_char"
|
||||
+2
-2
@@ -144,8 +144,8 @@ const changegamma [
|
||||
if (> $curgamma $targetgamma) [
|
||||
loopss = (- $curgamma $targetgamma)
|
||||
] [ loopss = (- $targetgamma $curgamma) ]
|
||||
loop i $loopss [
|
||||
sleep (* $i $incrementss) [
|
||||
loop t $loopss [
|
||||
sleep (* $t $incrementss) [
|
||||
gamma ((at "+ -" (> $curgamma $targetgamma)) $gamma 1)
|
||||
]
|
||||
]
|
||||
|
||||
@@ -1286,6 +1286,31 @@ echo foo
|
||||
<argument token="C" description="subarray content (string)"/>
|
||||
</arguments>
|
||||
<references>
|
||||
<identifierReference identifier="MDArray_Add_To_Subarray"/>
|
||||
<identifierReference identifier="MDArray_Get"/>
|
||||
<identifierReference identifier="MDArray_Modify_Subarray"/>
|
||||
<identifierReference identifier="MDArray_Delete_Subarray"/>
|
||||
<identifierReference identifier="MDArray_Get_Subarray_Count"/>
|
||||
<identifierReference identifier="MDArray_Get_All_Subarray_Names"/>
|
||||
<identifierReference identifier="MDArray_Search"/>
|
||||
</references>
|
||||
</command>
|
||||
|
||||
<command name="MDArray_Add_To_Subarray">
|
||||
<description>Adds a string to an existing subarray in a cubescript multidimensional array.</description>
|
||||
<examples>
|
||||
<example>
|
||||
<code><![CDATA[MDArray_New_Subarray test list1 "this is part of list1"; MDArray_Add_To_Subarray test list1 "and so is this"; echo (MDArray_Get test list1 -1)]]></code>
|
||||
<explanation>Output: "this is part of list1" "and so is this"</explanation>
|
||||
</example>
|
||||
</examples>
|
||||
<arguments>
|
||||
<argument token="A" description="name of alias (multidimensional array)"/>
|
||||
<argument token="N" description="name of target subarray to add to"/>
|
||||
<argument token="C" description="string to add to target subarray"/>
|
||||
</arguments>
|
||||
<references>
|
||||
<identifierReference identifier="MDArray_New_Subarray"/>
|
||||
<identifierReference identifier="MDArray_Get"/>
|
||||
<identifierReference identifier="MDArray_Modify_Subarray"/>
|
||||
<identifierReference identifier="MDArray_Delete_Subarray"/>
|
||||
@@ -1311,6 +1336,7 @@ echo foo
|
||||
</arguments>
|
||||
<references>
|
||||
<identifierReference identifier="MDArray_New_Subarray"/>
|
||||
<identifierReference identifier="MDArray_Add_To_Subarray"/>
|
||||
<identifierReference identifier="MDArray_Modify_Subarray"/>
|
||||
<identifierReference identifier="MDArray_Delete_Subarray"/>
|
||||
<identifierReference identifier="MDArray_Get_Subarray_Count"/>
|
||||
@@ -1336,6 +1362,7 @@ echo foo
|
||||
</arguments>
|
||||
<references>
|
||||
<identifierReference identifier="MDArray_New_Subarray"/>
|
||||
<identifierReference identifier="MDArray_Add_To_Subarray"/>
|
||||
<identifierReference identifier="MDArray_Get"/>
|
||||
<identifierReference identifier="MDArray_Delete_Subarray"/>
|
||||
<identifierReference identifier="MDArray_Get_Subarray_Count"/>
|
||||
@@ -1352,6 +1379,7 @@ echo foo
|
||||
</arguments>
|
||||
<references>
|
||||
<identifierReference identifier="MDArray_New_Subarray"/>
|
||||
<identifierReference identifier="MDArray_Add_To_Subarray"/>
|
||||
<identifierReference identifier="MDArray_Get"/>
|
||||
<identifierReference identifier="MDArray_Modify_Subarray"/>
|
||||
<identifierReference identifier="MDArray_Get_Subarray_Count"/>
|
||||
@@ -1367,6 +1395,7 @@ echo foo
|
||||
</arguments>
|
||||
<references>
|
||||
<identifierReference identifier="MDArray_New_Subarray"/>
|
||||
<identifierReference identifier="MDArray_Add_To_Subarray"/>
|
||||
<identifierReference identifier="MDArray_Get"/>
|
||||
<identifierReference identifier="MDArray_Modify_Subarray"/>
|
||||
<identifierReference identifier="MDArray_Delete_Subarray"/>
|
||||
@@ -1387,6 +1416,7 @@ echo foo
|
||||
<argument token="A" description="name of alias (multidimensional array)"/>
|
||||
</arguments>
|
||||
<references>
|
||||
<identifierReference identifier="MDArray_Add_To_Subarray"/>
|
||||
<identifierReference identifier="MDArray_New_Subarray"/>
|
||||
<identifierReference identifier="MDArray_Get"/>
|
||||
<identifierReference identifier="MDArray_Modify_Subarray"/>
|
||||
@@ -1414,6 +1444,7 @@ echo foo
|
||||
<argument token="K" description="keyword to search for"/>
|
||||
</arguments>
|
||||
<references>
|
||||
<identifierReference identifier="MDArray_Add_To_Subarray"/>
|
||||
<identifierReference identifier="MDArray_New_Subarray"/>
|
||||
<identifierReference identifier="MDArray_Get"/>
|
||||
<identifierReference identifier="MDArray_Modify_Subarray"/>
|
||||
|
||||
@@ -777,7 +777,8 @@ inline const char * spawn_message()
|
||||
else return "3You must be on the correct map to spawn. Type /getmap to download it.";
|
||||
}
|
||||
else if (m_coop) return "3Type /getmap or send a map and vote for it to start co-op edit.";
|
||||
else return "4Awaiting permission to spawn. \f2DON'T PANIC!";
|
||||
else if (multiplayer(false)) return "4Awaiting permission to spawn. \f2DON'T PANIC!";
|
||||
else return ""; // theres no waiting for permission in sp
|
||||
// Despite its many glaring (and occasionally fatal) inaccuracies, AssaultCube itself has outsold the
|
||||
// Encyclopedia Galactica because it is slightly cheaper, and because it has the words "Don't Panic"
|
||||
// in large, friendly letters.
|
||||
|
||||
Reference in New Issue
Block a user