| 1 | -- Script_Root_Object |
|---|
| 2 | ----------------------------------- |
|---|
| 3 | -- CREATED: |
|---|
| 4 | -- 26.02.2010 |
|---|
| 5 | -- |
|---|
| 6 | -- DESCRIPTION: |
|---|
| 7 | -- This is the base script to use as ancestor for all parentscripts |
|---|
| 8 | -- It provides basic handlers for authoring and runtime functions |
|---|
| 9 | -- |
|---|
| 10 | -- REQUIRES: |
|---|
| 11 | -- - |
|---|
| 12 | -- |
|---|
| 13 | -- USAGE: |
|---|
| 14 | -- use this script as ancestor for scripts in order to incorporate some basic handlers |
|---|
| 15 | ----------------------------------- |
|---|
| 16 | |
|---|
| 17 | on _____________________PROPERTY_DECLARATION me |
|---|
| 18 | end |
|---|
| 19 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 20 | property pMyScriptName |
|---|
| 21 | property pAlreadyDestroying |
|---|
| 22 | |
|---|
| 23 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 24 | on _____________________STANDARD_EVENTS me |
|---|
| 25 | end |
|---|
| 26 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 27 | |
|---|
| 28 | on new me |
|---|
| 29 | return me |
|---|
| 30 | end |
|---|
| 31 | |
|---|
| 32 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 33 | on _____________________ENGINE_EVENTS me |
|---|
| 34 | end |
|---|
| 35 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 36 | |
|---|
| 37 | on mDestroy me |
|---|
| 38 | pAlreadyDestroying = 1 |
|---|
| 39 | end |
|---|
| 40 | |
|---|
| 41 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 42 | |
|---|
| 43 | on mIsAlreadyDestroying me |
|---|
| 44 | return pAlreadyDestroying |
|---|
| 45 | end |
|---|
| 46 | |
|---|
| 47 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 48 | on ___________________PUBLIC_EVENTS me |
|---|
| 49 | end |
|---|
| 50 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 51 | |
|---|
| 52 | on mSetScriptName me, aScriptname |
|---|
| 53 | ----------------------------------- |
|---|
| 54 | -- ACTION: Set the name of the script. This is typically the castmember name, |
|---|
| 55 | -- so we can identify this script in the list of scripts attached to the node |
|---|
| 56 | -- in order to for example get a reference or check, if the script is already present |
|---|
| 57 | -- THIS IS TO BE USED, IF THIS SCRIPT IS USED AS AN ANCESTOR! |
|---|
| 58 | -- INPUT: <aScriptname> ; string ; name of the script, which shall be used for |
|---|
| 59 | -- * mGetScriptInstance() |
|---|
| 60 | -- * mGetScriptInstanceList() |
|---|
| 61 | -- RETURNS: - |
|---|
| 62 | ----------------------------------- |
|---|
| 63 | |
|---|
| 64 | pMyScriptName = string(aScriptname) |
|---|
| 65 | end |
|---|
| 66 | |
|---|
| 67 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 68 | |
|---|
| 69 | on mGetScriptName me |
|---|
| 70 | ----------------------------------- |
|---|
| 71 | -- ACTION: Get the name of the script. This is typically the castmember name, |
|---|
| 72 | -- so we can identify this script in the list of scripts attached to the node |
|---|
| 73 | -- in order to for example get a reference or check, if the script is already present |
|---|
| 74 | -- THIS IS TO BE USED, IF THIS SCRIPT IS USED AS AN ANCESTOR! |
|---|
| 75 | -- INPUT: - |
|---|
| 76 | -- RETURNS: string ; name of the script, which shall be used for |
|---|
| 77 | ----------------------------------- |
|---|
| 78 | |
|---|
| 79 | return pMyScriptName |
|---|
| 80 | end |
|---|
| 81 | |
|---|
| 82 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 83 | |
|---|
| 84 | on mGetInterface me, string_keyword |
|---|
| 85 | ----------------------------------- |
|---|
| 86 | -- CREATED: 20.03.2008 |
|---|
| 87 | -- ACTION: Get the "interface" of this script: all properties |
|---|
| 88 | -- this is rather an AUTHORING FUNCTION! At runtime it is limited, |
|---|
| 89 | -- as we do not have scripttext |
|---|
| 90 | -- |
|---|
| 91 | -- INPUT: <string_keyword> ; string ; optional filter to constrain the results |
|---|
| 92 | -- use "%" or "^" as the first char if the filter shall be => |
|---|
| 93 | -- 'word STARTS with <string_keyword>' |
|---|
| 94 | -- use "$" as the last char if the filter shall be => |
|---|
| 95 | -- 'word ENDS with <string_keyword>' |
|---|
| 96 | -- (HINT: if searching for the exact phrase use ^keyword$ as filter) |
|---|
| 97 | -- otherwise the string <string_keyword> may appear anywhere in the word => |
|---|
| 98 | -- 'word CONTAINS <string_keyword>' |
|---|
| 99 | -- RETURNS: string |
|---|
| 100 | -- EXAMPLE: put xscr().GetInterfaceList() |
|---|
| 101 | ----------------------------------- |
|---|
| 102 | |
|---|
| 103 | string_keyword = string(string_keyword) |
|---|
| 104 | scrName = getReferenceString(me) |
|---|
| 105 | props = "-- -- -- PROPERTIES:" |
|---|
| 106 | str = "-- -- -- OBJECTS:" |
|---|
| 107 | cnt = count(me) |
|---|
| 108 | xscr = xscr() |
|---|
| 109 | repeat with n = 1 to cnt |
|---|
| 110 | propname = string(me.getPropAt(n)) |
|---|
| 111 | if ilk(me.getaProp(propname)) = #instance then |
|---|
| 112 | instname = string(me.getPropAt(n)) |
|---|
| 113 | if xscr.mFilterString(instname, string_keyword) = 1 then |
|---|
| 114 | put RETURN & scrName & "." & instname & RETURN after str |
|---|
| 115 | end if |
|---|
| 116 | else |
|---|
| 117 | if xscr.mFilterString(propname, string_keyword) = 1 then |
|---|
| 118 | put RETURN & scrName & "." & propname & RETURN after props |
|---|
| 119 | end if |
|---|
| 120 | end if |
|---|
| 121 | end repeat |
|---|
| 122 | |
|---|
| 123 | hnd = "-- -- -- HANDLERS:" |
|---|
| 124 | scriptTextParser = xscr(#scriptTextParser) |
|---|
| 125 | if ilk(scriptTextParser) = #instance then |
|---|
| 126 | hnd = scriptTextParser.handlerList(me, string_keyword, scrName) |
|---|
| 127 | end if |
|---|
| 128 | |
|---|
| 129 | return RETURN & str & RETURN & RETURN & props & RETURN & RETURN & hnd & RETURN |
|---|
| 130 | end |
|---|
| 131 | |
|---|
| 132 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 133 | -- just a shortcut to avoid typing "mGetInterface" into the message window all the time |
|---|
| 134 | on __iface me, string_keyword |
|---|
| 135 | return mGetInterface(me, string_keyword) |
|---|
| 136 | end |
|---|
| 137 | |
|---|
| 138 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 139 | |
|---|
| 140 | on lingodoc me, string_keyword |
|---|
| 141 | |
|---|
| 142 | string_keyword = string(string_keyword) |
|---|
| 143 | scrName = getReferenceString(me) |
|---|
| 144 | |
|---|
| 145 | scriptTextParser = xscr(#scriptTextParser) |
|---|
| 146 | if ilk(scriptTextParser) = #instance then |
|---|
| 147 | hnd = scriptTextParser.handlerList(me, string_keyword, scrName, 1, 1) |
|---|
| 148 | end if |
|---|
| 149 | |
|---|
| 150 | return RETURN & hnd & RETURN |
|---|
| 151 | |
|---|
| 152 | end |
|---|
| 153 | |
|---|
| 154 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 155 | |
|---|
| 156 | on showInScript me, string_keyword |
|---|
| 157 | |
|---|
| 158 | if (the runmode contains "aut") then |
|---|
| 159 | string_keyword = string(string_keyword) |
|---|
| 160 | scrName = getReferenceString(me) |
|---|
| 161 | |
|---|
| 162 | scriptTextParser = xscr(#scriptTextParser) |
|---|
| 163 | if ilk(scriptTextParser) = #instance then |
|---|
| 164 | hndList = scriptTextParser.mGetInfoListForItem(me, string_keyword) |
|---|
| 165 | end if |
|---|
| 166 | |
|---|
| 167 | if ilk(hndList) <> #proplist then exit |
|---|
| 168 | |
|---|
| 169 | memnum = hndList[#memberNumber] |
|---|
| 170 | cnum = hndList[#castlibNumber] |
|---|
| 171 | offs1 = 1 |
|---|
| 172 | offs2 = 1 |
|---|
| 173 | |
|---|
| 174 | itms = hndList[#items] |
|---|
| 175 | if listP(itms) then |
|---|
| 176 | if count(itms) > 0 then |
|---|
| 177 | thisHnd = itms[1] |
|---|
| 178 | memnum = thisHnd[#memberInfo][#memberNumber] |
|---|
| 179 | cnum = thisHnd[#memberInfo][#castlibNumber] |
|---|
| 180 | offs = thisHnd[#charoffset] |
|---|
| 181 | if listP(offs) then |
|---|
| 182 | if count(offs) > 1 then |
|---|
| 183 | offs1 = offs[1] |
|---|
| 184 | offs2 = offs[2] |
|---|
| 185 | end if |
|---|
| 186 | end if |
|---|
| 187 | end if |
|---|
| 188 | end if |
|---|
| 189 | |
|---|
| 190 | activateScriptEditor memnum, cnum, offs1, offs2 |
|---|
| 191 | |
|---|
| 192 | else |
|---|
| 193 | alert "This function is only available in authoring" |
|---|
| 194 | end if |
|---|
| 195 | |
|---|
| 196 | end |
|---|
| 197 | |
|---|
| 198 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 199 | on ___________________CALLBACK_EVENTS me |
|---|
| 200 | end |
|---|
| 201 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 202 | |
|---|
| 203 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 204 | on ___________________PRIVATE_VENTS me |
|---|
| 205 | end |
|---|
| 206 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 207 | |
|---|
| 208 | on getReferenceString me |
|---|
| 209 | |
|---|
| 210 | scrName = string(mGetScriptName()) |
|---|
| 211 | if length(scrName) < 1 then |
|---|
| 212 | scrName = word 2 of string(me) |
|---|
| 213 | delete char 1 of scrName |
|---|
| 214 | delete the last char of scrName |
|---|
| 215 | end if |
|---|
| 216 | return "xscr(#" & xscr().mSymbolify(scrName) & ")" |
|---|
| 217 | end |
|---|