home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Stickerpedia Stickerbook
/
Stickerbook.iso
/
pc
/
DATA
/
objects.cxt
/
00022_Script_oMarvin
< prev
next >
Wrap
Text File
|
2003-03-19
|
9KB
|
396 lines
--¨
oMarvin
global oHQ, oMarvin
on new me
-- addObject me
-- updateProgressBar ("Object loading", oMarvin && "status #ok")
return me
end
on showProps me
showProps oHQ, me
end
on convertTextToField me
end
on getName me, theName, optionalDelimiter
set retVal = #noString
if stringP(theName) then
saveDelim = the itemDelimiter
if voidP(optionalDelimiter) then
the itemDelimiter = "."
else
the itemDelimiter = optionalDelimiter
end if
set retVal = item 1 of theName
itemDelimiter = saveDelim
end if
return retVal
end
on fadeSprite me, spriteNum, startBlend, endBlend, repeats
sprite(spriteNum).blend = startBlend
sprite(spriteNum).visible = 1
increment = 100/repeats
if startBlend > endBlend then increment = increment*-1
repeat with n = 1 to repeats
sprite(spriteNum).blend = sprite(spriteNum).blend + increment
updatestage
end repeat
sprite(spriteNum).blend = endBlend
updatestage
end
on pad me, x
-- insert "0" chars for single digit values of x
if x < 10 then
return "0" & string(x)
else
return x
end if
end
on doublePad me, x
-- insert "00" chars for single digit values of x
-- and "0" for doubleDigit characters
if x < 10 then
return "00" & string(x)
else if x < 100 then
return "0" & string(x)
else
return string(x)
end if
end
on triplePad me, x
-- insert "000" chars for single digit values of x
-- and insert "00" chars for double digit values of x
-- and "0" for triple characters
if x < 10 then
return "000" & string(x)
else if x < 100 then
return "00" & string(x)
else if x < 1000 then
return "0" & string(x)
else
return string(x)
end if
end
on doStage me
set the stageColor = the stageColor
end
on joinPropLists me, originalListOfLists
-- some deleting will be done, so make a copy of original lists
set listOfLists = duplicate(originalListOfLists)
-- newList will contain all passed lists, make it a property list:
set newList = [:]
set numOfLists = count(listOfLists)
-- two nested repeat loops:
-- first loop iterates through listOfLists
-- second loop iterate through current list and extracts data and adds it to newList
repeat with listIndex = 1 to numOfLists
set curList = getAt(listOfLists, ListIndex)
set lastIndex = count(curList)
repeat with curIndex = 1 to lastIndex
-- get the first value:
set nextValue = getAt(curList,1)
-- get the property assigned to it
set nextProp = getOne(curList,nextValue)
-- add the fellows to newList
addProp newList, nextProp, nextValue
-- because getOne() only retrieves the first occurence of a value,
-- delete the just retrieved entry from curList in case there are properties
-- with the same values
deleteAt curList,1
end repeat
end repeat
return newList
end
on splitPropLists me, propertyList
-- this handler splits a property list into a linear list that contains an entry per property as a string
set newList = []
-- some deleting will be done, so make a copy of original list
set damnLongPropertyList = duplicate(propertyList)
set numofProps = count(damnLongPropertyList)
repeat with n = 1 to numofProps
-- get the first value:
set nextValue = getAt(damnLongPropertyList,1)
-- get the property assigned to it
set nextProp = getOne(damnLongPropertyList,nextValue)
-- because getOne() only retrieves the first occurence of a value,
-- delete the just retrieved entry from curList in case there are properties
-- with the same values
deleteAt damnLongPropertyList,1
set tempList = [:]
addProp tempList, nextProp, nextValue
add newList, tempList
end repeat
return newList
end
on checkListForDuplicates me, aList
retVal = []
numOfEntries = aList.count
repeat with pointer = 1 to numOfEntries
checkThisEntry = aList[pointer]
-- updateProgressBar ("object Marvin checks asset lists for duplicates", string(pointer))
repeat with pointer2 = 1 to numOfEntries
if pointer = pointer2 then next repeat
compareTo = aList[pointer2]
if (checkThisEntry = compareTo) and not getOne(retVal, compareTo) then retVal.add(checkThisEntry)
end repeat
end repeat
return retVal
end
on eliminateDuplicatesInList me, originalList
startTimer
duplicatetInfoList =[:]
listOfDuplicates = []
retVal = originalList.duplicate()
deletePositionList = []
numOfEntries = originalList.count
repeat with pointer = 1 to numOfEntries
checkThisEntry = originalList[pointer]
tempList = []
repeat with pointer2 = 1 to numOfEntries
compareTo = originalList[pointer2]
if (checkThisEntry = compareTo) and not getOne(listOfDuplicates, compareTo) then tempList.add(pointer2)
end repeat
tempList.deleteAt(1)
if tempList.count then duplicatetInfoList.setAProp(checkThisEntry, tempList)
end repeat
-- put "duplicatetInfoList" && duplicatetInfoList
repeat with curPointerList in duplicatetInfoList
repeat with curPosition in curPointerList
deletePositionList.add(curPosition)
end repeat
end repeat
sort deletePositionList
--put "deletePositionList" && deletePositionList
numOfEntriesToDelete = deletePositionList.count
repeat with pointer = numOfEntriesToDelete down to 1
retVal.deleteAt(deletePositionList[pointer])
end repeat
put "eliminateDuplicatesInList" && the timer && "ticks"
return retVal
end
on invertPropertyListSortOrder me, aList
sort aList
retVal = [:]
numOfEntries = aList.count
repeat with pointer = numOfEntries down to 1
curValue = aList[pointer]
curProp = aList.getPropAt(pointer)
retVal.addProp(curProp, curValue)
end repeat
return retVal
end
on textToList me, theText
retVal = []
numOfEntries = theText.lines.count
repeat with pointer = 1 to numOfEntries
theValue = theText.line[pointer]
retVal.add(theValue)
end repeat
return retVal
end
on listToText me, aList
retVal = ""
if ilk(aList) = #propList then propList = 1
numOfEntries = aList.count
repeat with pointer = 1 to numOfEntries
theValue = aList[pointer]
if propList then
theProp = aList.getPropAt(pointer)
retVal = retVal & theProp && "=" && theValue & RETURN
else
retVal = retVal & theValue & RETURN
end if
end repeat
return retVal
end
--
--on switchListPosition me, aList, oldPos, newPos
-- -- switches the position of a value in a list from oldPos to newPos
-- retVal = []
-- numOfEntries = aList.count
-- if aList.ilk = #propList then customAlert "Not a property list"
--
-- oldValue = aList[oldPos]
-- aList.deleteAt(oldPos)
--
-- -- create a new value at the end of the list
-- -- move all values
--
--end
on letterToNumber me, aLetter
set retVal = -1
if not stringP(aLetter) then
handleError oHQ, "object Marvin's method 'letterToNumber' can't translate" && aLetter && "into a number"
exit
return retVal
end if
if the number of chars in aLetter > 1 then
handleError oHQ, "object Marvin's method 'letterToNumber' can't translate" && aLetter && "into a number"
exit
return retVal
end if
set theNumber = charToNum(aLetter)-96
if theNumber >=1 and theNumber <= 26 then
set retVal = theNumber
end if
return retVal
end
on switchCapitalLowerCase me, aLetter
set retVal = -1
set theNumber = charToNum(aLetter)
if theNumber >= 65 and theNumber <= 90 then
set retVal = numToChar(theNumber+32)
else
set retVal = numToChar(theNumber-32)
end if
return retVal
end
on eliminateSpaces me, aString
repeat while aString.char[1] = " "
delete aString.char[1]
end repeat
repeat while aString.char[(aString.length)] = " "
delete aString.char[(aString.length)]
end repeat
return aString
end
on pointWithInRect me, aPoint, aRect
if (getAt(aPoint,1) > getAt(aRect,1) ) and (getAt(aPoint,1) < getAt(aRect,3)) and (getAt(aPoint,2) > getAt(aRect,2) ) and (getAt(aPoint,2) < getAt(aRect,4)) then return 1
else return 0
end
on getAllRollovers me
set sprList = []
repeat with n = 1 to 120
if rollover(n) then add sprList, n
end repeat
return sprList
end