LSL_BuiltIn_Commands.cs 219 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSim Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections;
  29. using System.Collections.Generic;
  30. using System.Runtime.Remoting.Lifetime;
  31. using System.Text;
  32. using System.Threading;
  33. using Axiom.Math;
  34. using libsecondlife;
  35. using OpenSim.Framework;
  36. using OpenSim.Region.Environment;
  37. using OpenSim.Region.Environment.Interfaces;
  38. using OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney;
  39. using OpenSim.Region.Environment.Modules.World.Land;
  40. using OpenSim.Region.Environment.Scenes;
  41. using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase;
  42. //using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL;
  43. namespace OpenSim.Region.ScriptEngine.Common
  44. {
  45. /// <summary>
  46. /// Contains all LSL ll-functions. This class will be in Default AppDomain.
  47. /// </summary>
  48. public class LSL_BuiltIn_Commands : MarshalByRefObject, LSL_BuiltIn_Commands_Interface
  49. {
  50. // private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  51. internal ScriptEngineBase.ScriptEngine m_ScriptEngine;
  52. internal SceneObjectPart m_host;
  53. internal uint m_localID;
  54. internal LLUUID m_itemID;
  55. internal bool throwErrorOnNotImplemented = true;
  56. public LSL_BuiltIn_Commands(ScriptEngineBase.ScriptEngine ScriptEngine, SceneObjectPart host, uint localID, LLUUID itemID)
  57. {
  58. m_ScriptEngine = ScriptEngine;
  59. m_host = host;
  60. m_localID = localID;
  61. m_itemID = itemID;
  62. //m_log.Info(ScriptEngineName, "LSL_BaseClass.Start() called. Hosted by [" + m_host.Name + ":" + m_host.UUID + "@" + m_host.AbsolutePosition + "]");
  63. }
  64. private DateTime m_timer = DateTime.Now;
  65. private string m_state = "default";
  66. private bool m_waitingForScriptAnswer=false;
  67. public string State
  68. {
  69. get { return m_state; }
  70. set {
  71. // Set it if it changed
  72. if (m_state != value)
  73. {
  74. try
  75. {
  76. m_ScriptEngine.m_EventManager.state_exit(m_localID);
  77. }
  78. catch (AppDomainUnloadedException)
  79. {
  80. Console.WriteLine("[SCRIPT]: state change called when script was unloaded. Nothing to worry about, but noting the occurance");
  81. }
  82. m_state = value;
  83. try
  84. {
  85. int eventFlags = m_ScriptEngine.m_ScriptManager.GetStateEventFlags(m_localID, m_itemID);
  86. m_host.SetScriptEvents(m_itemID, eventFlags);
  87. m_ScriptEngine.m_EventManager.state_entry(m_localID);
  88. }
  89. catch (AppDomainUnloadedException)
  90. {
  91. Console.WriteLine("[SCRIPT]: state change called when script was unloaded. Nothing to worry about, but noting the occurance");
  92. }
  93. }
  94. }
  95. }
  96. // Object never expires
  97. public override Object InitializeLifetimeService()
  98. {
  99. //Console.WriteLine("LSL_BuiltIn_Commands: InitializeLifetimeService()");
  100. // return null;
  101. ILease lease = (ILease)base.InitializeLifetimeService();
  102. if (lease.CurrentState == LeaseState.Initial)
  103. {
  104. lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1);
  105. // lease.SponsorshipTimeout = TimeSpan.FromMinutes(2);
  106. // lease.RenewOnCallTime = TimeSpan.FromSeconds(2);
  107. }
  108. return lease;
  109. }
  110. public Scene World
  111. {
  112. get { return m_ScriptEngine.World; }
  113. }
  114. // Extension commands use this:
  115. public ICommander GetCommander(string name)
  116. {
  117. return World.GetCommander(name);
  118. }
  119. private LLUUID InventorySelf()
  120. {
  121. LLUUID invItemID=new LLUUID();
  122. foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
  123. {
  124. if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID)
  125. {
  126. invItemID=inv.Key;
  127. break;
  128. }
  129. }
  130. return invItemID;
  131. }
  132. private LLUUID InventoryKey(string name, int type)
  133. {
  134. m_host.AddScriptLPS(1);
  135. foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
  136. {
  137. if (inv.Value.Name == name)
  138. {
  139. if (inv.Value.Type != type)
  140. return LLUUID.Zero;
  141. return inv.Value.AssetID.ToString();
  142. }
  143. }
  144. return LLUUID.Zero;
  145. }
  146. private LLUUID InventoryKey(string name)
  147. {
  148. m_host.AddScriptLPS(1);
  149. foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
  150. {
  151. if (inv.Value.Name == name)
  152. {
  153. return inv.Value.AssetID.ToString();
  154. }
  155. }
  156. return LLUUID.Zero;
  157. }
  158. public void osSetRegionWaterHeight(double height)
  159. {
  160. m_host.AddScriptLPS(1);
  161. //Check to make sure that the script's owner is the estate manager/master
  162. //World.Permissions.GenericEstatePermission(
  163. if (World.ExternalChecks.ExternalChecksCanBeGodLike(m_host.OwnerID))
  164. {
  165. World.EventManager.TriggerRequestChangeWaterHeight((float)height);
  166. }
  167. }
  168. //These are the implementations of the various ll-functions used by the LSL scripts.
  169. //starting out, we use the System.Math library for trig functions. - ckrinke 8-14-07
  170. public double llSin(double f)
  171. {
  172. m_host.AddScriptLPS(1);
  173. return (double)Math.Sin(f);
  174. }
  175. public double llCos(double f)
  176. {
  177. m_host.AddScriptLPS(1);
  178. return (double)Math.Cos(f);
  179. }
  180. public double llTan(double f)
  181. {
  182. m_host.AddScriptLPS(1);
  183. return (double)Math.Tan(f);
  184. }
  185. public double llAtan2(double x, double y)
  186. {
  187. m_host.AddScriptLPS(1);
  188. return (double)Math.Atan2(y, x);
  189. }
  190. public double llSqrt(double f)
  191. {
  192. m_host.AddScriptLPS(1);
  193. return (double)Math.Sqrt(f);
  194. }
  195. public double llPow(double fbase, double fexponent)
  196. {
  197. m_host.AddScriptLPS(1);
  198. return (double)Math.Pow(fbase, fexponent);
  199. }
  200. public LSL_Types.LSLInteger llAbs(int i)
  201. {
  202. m_host.AddScriptLPS(1);
  203. return (int)Math.Abs(i);
  204. }
  205. public double llFabs(double f)
  206. {
  207. m_host.AddScriptLPS(1);
  208. return (double)Math.Abs(f);
  209. }
  210. public double llFrand(double mag)
  211. {
  212. m_host.AddScriptLPS(1);
  213. lock (Util.RandomClass)
  214. {
  215. return Util.RandomClass.NextDouble() * mag;
  216. }
  217. }
  218. public LSL_Types.LSLInteger llFloor(double f)
  219. {
  220. m_host.AddScriptLPS(1);
  221. return (int)Math.Floor(f);
  222. }
  223. public LSL_Types.LSLInteger llCeil(double f)
  224. {
  225. m_host.AddScriptLPS(1);
  226. return (int)Math.Ceiling(f);
  227. }
  228. // Xantor 01/May/2008 fixed midpointrounding (2.5 becomes 3.0 instead of 2.0, default = ToEven)
  229. public LSL_Types.LSLInteger llRound(double f)
  230. {
  231. m_host.AddScriptLPS(1);
  232. return (int)Math.Round(f, MidpointRounding.AwayFromZero);
  233. }
  234. //This next group are vector operations involving squaring and square root. ckrinke
  235. public double llVecMag(LSL_Types.Vector3 v)
  236. {
  237. m_host.AddScriptLPS(1);
  238. return LSL_Types.Vector3.Mag(v);
  239. }
  240. public LSL_Types.Vector3 llVecNorm(LSL_Types.Vector3 v)
  241. {
  242. m_host.AddScriptLPS(1);
  243. double mag = LSL_Types.Vector3.Mag(v);
  244. LSL_Types.Vector3 nor = new LSL_Types.Vector3();
  245. nor.x = v.x / mag;
  246. nor.y = v.y / mag;
  247. nor.z = v.z / mag;
  248. return nor;
  249. }
  250. public double llVecDist(LSL_Types.Vector3 a, LSL_Types.Vector3 b)
  251. {
  252. m_host.AddScriptLPS(1);
  253. double dx = a.x - b.x;
  254. double dy = a.y - b.y;
  255. double dz = a.z - b.z;
  256. return Math.Sqrt(dx * dx + dy * dy + dz * dz);
  257. }
  258. //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke
  259. // Utility function for llRot2Euler
  260. // normalize an angle between 0 - 2*PI (0 and 360 degrees)
  261. private double NormalizeAngle(double angle)
  262. {
  263. angle = angle % (Math.PI * 2);
  264. if (angle < 0) angle = angle + Math.PI * 2;
  265. return angle;
  266. }
  267. // Old implementation of llRot2Euler, now normalized
  268. public LSL_Types.Vector3 llRot2Euler(LSL_Types.Quaternion r)
  269. {
  270. m_host.AddScriptLPS(1);
  271. //This implementation is from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions. ckrinke
  272. LSL_Types.Quaternion t = new LSL_Types.Quaternion(r.x * r.x, r.y * r.y, r.z * r.z, r.s * r.s);
  273. double m = (t.x + t.y + t.z + t.s);
  274. if (m == 0) return new LSL_Types.Vector3();
  275. double n = 2 * (r.y * r.s + r.x * r.z);
  276. double p = m * m - n * n;
  277. if (p > 0)
  278. return new LSL_Types.Vector3(NormalizeAngle(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s))),
  279. NormalizeAngle(Math.Atan2(n, Math.Sqrt(p))),
  280. NormalizeAngle(Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s))));
  281. else if (n > 0)
  282. return new LSL_Types.Vector3(0.0, Math.PI / 2, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)));
  283. else
  284. return new LSL_Types.Vector3(0.0, -Math.PI / 2, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)));
  285. }
  286. // Xantor's newer llEuler2Rot() *try the second* inverted quaternions (-x,-y,-z,w) as LL seems to like
  287. // New and improved, now actually works as described. Prim rotates as expected as does llRot2Euler.
  288. /* From wiki:
  289. The Euler angle vector (in radians) is converted to a rotation by doing the rotations around the 3 axes
  290. in Z, Y, X order. So llEuler2Rot(<1.0, 2.0, 3.0> * DEG_TO_RAD) generates a rotation by taking the zero rotation,
  291. a vector pointing along the X axis, first rotating it 3 degrees around the global Z axis, then rotating the resulting
  292. vector 2 degrees around the global Y axis, and finally rotating that 1 degree around the global X axis.
  293. */
  294. public LSL_Types.Quaternion llEuler2Rot(LSL_Types.Vector3 v)
  295. {
  296. m_host.AddScriptLPS(1);
  297. double x,y,z,s,s_i;
  298. double cosX = Math.Cos(v.x);
  299. double cosY = Math.Cos(v.y);
  300. double cosZ = Math.Cos(v.z);
  301. double sinX = Math.Sin(v.x);
  302. double sinY = Math.Sin(v.y);
  303. double sinZ = Math.Sin(v.z);
  304. s = Math.Sqrt(cosY * cosZ - sinX * sinY * sinZ + cosX * cosZ + cosX * cosY + 1.0f) * 0.5f;
  305. if (Math.Abs(s) < 0.00001) // null rotation
  306. {
  307. x = 0.0f;
  308. y = 1.0f;
  309. z = 0.0f;
  310. }
  311. else
  312. {
  313. s_i = 1.0f / (4.0f * s);
  314. x = - (-sinX * cosY - cosX * sinY * sinZ - sinX * cosZ) * s_i;
  315. y = - (-cosX * sinY * cosZ + sinX * sinZ - sinY) * s_i;
  316. z = - (-cosY * sinZ - sinX * sinY * cosZ - cosX * sinZ) * s_i;
  317. }
  318. return new LSL_Types.Quaternion(x, y, z, s);
  319. }
  320. public LSL_Types.Quaternion llAxes2Rot(LSL_Types.Vector3 fwd, LSL_Types.Vector3 left, LSL_Types.Vector3 up)
  321. {
  322. m_host.AddScriptLPS(1);
  323. NotImplemented("llAxes2Rot");
  324. return new LSL_Types.Quaternion();
  325. }
  326. public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r)
  327. {
  328. m_host.AddScriptLPS(1);
  329. return (new LSL_Types.Vector3(1,0,0) * r);
  330. }
  331. public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r)
  332. {
  333. m_host.AddScriptLPS(1);
  334. return (new LSL_Types.Vector3(0, 1, 0) * r);
  335. }
  336. public LSL_Types.Vector3 llRot2Up(LSL_Types.Quaternion r)
  337. {
  338. m_host.AddScriptLPS(1);
  339. return (new LSL_Types.Vector3(0, 0, 1) * r);
  340. }
  341. public LSL_Types.Quaternion llRotBetween(LSL_Types.Vector3 a, LSL_Types.Vector3 b)
  342. {
  343. //A and B should both be normalized
  344. m_host.AddScriptLPS(1);
  345. double dotProduct = LSL_Types.Vector3.Dot(a, b);
  346. LSL_Types.Vector3 crossProduct = LSL_Types.Vector3.Cross(a, b);
  347. double magProduct = LSL_Types.Vector3.Mag(a) * LSL_Types.Vector3.Mag(b);
  348. double angle = Math.Acos(dotProduct / magProduct);
  349. LSL_Types.Vector3 axis = LSL_Types.Vector3.Norm(crossProduct);
  350. double s = Math.Sin(angle / 2);
  351. return new LSL_Types.Quaternion(axis.x * s, axis.y * s, axis.z * s, (float)Math.Cos(angle / 2));
  352. }
  353. public void llWhisper(int channelID, string text)
  354. {
  355. m_host.AddScriptLPS(1);
  356. World.SimChat(Helpers.StringToField(text),
  357. ChatTypeEnum.Whisper, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID, false);
  358. IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
  359. wComm.DeliverMessage(ChatTypeEnum.Whisper, channelID, m_host.Name, m_host.UUID, text);
  360. }
  361. public void llSay(int channelID, string text)
  362. {
  363. m_host.AddScriptLPS(1);
  364. World.SimChat(Helpers.StringToField(text),
  365. ChatTypeEnum.Say, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID, false);
  366. IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
  367. wComm.DeliverMessage(ChatTypeEnum.Say, channelID, m_host.Name, m_host.UUID, text);
  368. }
  369. public void llShout(int channelID, string text)
  370. {
  371. m_host.AddScriptLPS(1);
  372. World.SimChat(Helpers.StringToField(text),
  373. ChatTypeEnum.Shout, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID, false);
  374. IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
  375. wComm.DeliverMessage(ChatTypeEnum.Shout, channelID, m_host.Name, m_host.UUID, text);
  376. }
  377. public void llRegionSay(int channelID, string text)
  378. {
  379. if (channelID == 0)
  380. {
  381. LSLError("Cannot use llRegionSay() on channel 0");
  382. return;
  383. }
  384. m_host.AddScriptLPS(1);
  385. IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
  386. wComm.DeliverMessage(ChatTypeEnum.Region, channelID, m_host.Name, m_host.UUID, text);
  387. }
  388. public LSL_Types.LSLInteger llListen(int channelID, string name, string ID, string msg)
  389. {
  390. m_host.AddScriptLPS(1);
  391. LLUUID keyID;
  392. LLUUID.TryParse(ID, out keyID);
  393. IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
  394. return wComm.Listen(m_localID, m_itemID, m_host.UUID, channelID, name, keyID, msg);
  395. }
  396. public void llListenControl(int number, int active)
  397. {
  398. m_host.AddScriptLPS(1);
  399. IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
  400. wComm.ListenControl(m_itemID, number, active);
  401. }
  402. public void llListenRemove(int number)
  403. {
  404. m_host.AddScriptLPS(1);
  405. IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
  406. wComm.ListenRemove(m_itemID, number);
  407. }
  408. public void llSensor(string name, string id, int type, double range, double arc)
  409. {
  410. m_host.AddScriptLPS(300);
  411. LLUUID keyID = LLUUID.Zero;
  412. LLUUID.TryParse(id, out keyID);
  413. m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.SenseOnce(m_localID, m_itemID, name, keyID, type, range, arc, m_host);
  414. }
  415. public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate)
  416. {
  417. m_host.AddScriptLPS(1);
  418. LLUUID keyID = LLUUID.Zero;
  419. LLUUID.TryParse(id, out keyID);
  420. m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.SetSenseRepeatEvent(m_localID, m_itemID, name, keyID, type, range, arc, rate, m_host);
  421. }
  422. public void llSensorRemove()
  423. {
  424. m_host.AddScriptLPS(1);
  425. m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.UnSetSenseRepeaterEvents(m_localID, m_itemID);
  426. }
  427. public string resolveName(LLUUID objecUUID)
  428. {
  429. // try avatar username surname
  430. UserProfileData profile = World.CommsManager.UserService.GetUserProfile(objecUUID);
  431. if (profile != null)
  432. {
  433. string avatarname = profile.FirstName + " " + profile.SurName;
  434. return avatarname;
  435. }
  436. // try an scene object
  437. SceneObjectPart SOP = World.GetSceneObjectPart(objecUUID);
  438. if (SOP != null)
  439. {
  440. string objectname = SOP.Name;
  441. return objectname;
  442. }
  443. EntityBase SensedObject;
  444. lock (World.Entities)
  445. {
  446. World.Entities.TryGetValue(objecUUID, out SensedObject);
  447. }
  448. if (SensedObject == null)
  449. return String.Empty;
  450. return SensedObject.Name;
  451. }
  452. public string llDetectedName(int number)
  453. {
  454. m_host.AddScriptLPS(1);
  455. LSL_Types.list SenseList = m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.GetSensorList(m_localID, m_itemID);
  456. if (SenseList != null)
  457. {
  458. if ((number >= 0) && (number <= SenseList.Length))
  459. {
  460. LLUUID SensedUUID = (LLUUID)SenseList.Data[number];
  461. return resolveName(SensedUUID);
  462. }
  463. }
  464. return String.Empty;
  465. }
  466. public LLUUID uuidDetectedKey(int number)
  467. {
  468. LSL_Types.list SenseList = m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.GetSensorList(m_localID, m_itemID);
  469. if (SenseList != null)
  470. {
  471. if ((number >= 0) && (number < SenseList.Length))
  472. {
  473. LLUUID SensedUUID = (LLUUID)SenseList.Data[number];
  474. return SensedUUID;
  475. }
  476. }
  477. else
  478. {
  479. ScriptManager sm;
  480. IScript script = null;
  481. if ((sm = m_ScriptEngine.m_ScriptManager) != null)
  482. {
  483. if (sm.Scripts.ContainsKey(m_localID))
  484. {
  485. if ((script = sm.GetScript(m_localID, m_itemID)) != null)
  486. {
  487. if (script.llDetectParams._key[0])
  488. {
  489. return new LLUUID(script.llDetectParams._key[0]);
  490. }
  491. }
  492. }
  493. }
  494. }
  495. return LLUUID.Zero;
  496. }
  497. public EntityBase entityDetectedKey(int number)
  498. {
  499. LSL_Types.list SenseList = m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.GetSensorList(m_localID, m_itemID);
  500. if (SenseList != null)
  501. {
  502. if ((number >= 0) && (number < SenseList.Length))
  503. {
  504. LLUUID SensedUUID = (LLUUID)SenseList.Data[number];
  505. EntityBase SensedObject = null;
  506. lock (World.Entities)
  507. {
  508. World.Entities.TryGetValue(SensedUUID, out SensedObject);
  509. }
  510. return SensedObject;
  511. }
  512. }
  513. return null;
  514. }
  515. public string llDetectedKey(int number)
  516. {
  517. m_host.AddScriptLPS(1);
  518. LLUUID SensedUUID = uuidDetectedKey(number);
  519. if (SensedUUID == LLUUID.Zero)
  520. return String.Empty;
  521. return SensedUUID.ToString();
  522. }
  523. public string llDetectedOwner(int number)
  524. {
  525. // returns UUID of owner of object detected
  526. m_host.AddScriptLPS(1);
  527. EntityBase SensedObject = entityDetectedKey(number);
  528. if (SensedObject ==null)
  529. return String.Empty;
  530. LLUUID SensedUUID = uuidDetectedKey(number);
  531. if (World.GetScenePresence(SensedUUID) == null)
  532. {
  533. // sensed object is not an avatar
  534. // so get the owner of the sensed object
  535. SceneObjectPart SOP = World.GetSceneObjectPart(SensedUUID);
  536. if (SOP != null) { return SOP.ObjectOwner.ToString(); }
  537. }
  538. else
  539. {
  540. // sensed object is an avatar, and so must be its own owner
  541. return SensedUUID.ToString();
  542. }
  543. return String.Empty;
  544. }
  545. public LSL_Types.LSLInteger llDetectedType(int number)
  546. {
  547. m_host.AddScriptLPS(1);
  548. EntityBase SensedObject = entityDetectedKey(number);
  549. if (SensedObject == null)
  550. return 0;
  551. int mask = 0;
  552. LLUUID SensedUUID = uuidDetectedKey(number);
  553. LSL_Types.Vector3 ZeroVector = new LSL_Types.Vector3(0, 0, 0);
  554. if (World.GetScenePresence(SensedUUID) != null) mask |= 0x01; // actor
  555. if (SensedObject.Velocity.Equals(ZeroVector))
  556. mask |= 0x04; // passive non-moving
  557. else
  558. mask |= 0x02; // active moving
  559. if (SensedObject is IScript) mask |= 0x08; // Scripted. It COULD have one hidden ...
  560. return mask;
  561. }
  562. public LSL_Types.Vector3 llDetectedPos(int number)
  563. {
  564. m_host.AddScriptLPS(1);
  565. EntityBase SensedObject = entityDetectedKey(number);
  566. if (SensedObject == null)
  567. return new LSL_Types.Vector3(0, 0, 0);
  568. return new LSL_Types.Vector3(SensedObject.AbsolutePosition.X,SensedObject.AbsolutePosition.Y,SensedObject.AbsolutePosition.Z);
  569. }
  570. public LSL_Types.Vector3 llDetectedVel(int number)
  571. {
  572. m_host.AddScriptLPS(1);
  573. EntityBase SensedObject = entityDetectedKey(number);
  574. if (SensedObject == null)
  575. return new LSL_Types.Vector3(0, 0, 0);
  576. return new LSL_Types.Vector3(SensedObject.Velocity.X, SensedObject.Velocity.Y, SensedObject.Velocity.Z);
  577. // return new LSL_Types.Vector3();
  578. }
  579. public LSL_Types.Vector3 llDetectedGrab(int number)
  580. {
  581. m_host.AddScriptLPS(1);
  582. NotImplemented("llDetectedGrab");
  583. return new LSL_Types.Vector3();
  584. }
  585. public LSL_Types.Quaternion llDetectedRot(int number)
  586. {
  587. m_host.AddScriptLPS(1);
  588. EntityBase SensedObject = entityDetectedKey(number);
  589. if (SensedObject == null)
  590. return new LSL_Types.Quaternion();
  591. return new LSL_Types.Quaternion(SensedObject.Rotation.x, SensedObject.Rotation.y, SensedObject.Rotation.z, SensedObject.Rotation.w);
  592. }
  593. public LSL_Types.LSLInteger llDetectedGroup(int number)
  594. {
  595. m_host.AddScriptLPS(1);
  596. NotImplemented("llDetectedGroup");
  597. return 0;
  598. }
  599. public LSL_Types.LSLInteger llDetectedLinkNumber(int number)
  600. {
  601. m_host.AddScriptLPS(1);
  602. NotImplemented("llDetectedLinkNumber");
  603. return 0;
  604. }
  605. public void llDie()
  606. {
  607. m_host.AddScriptLPS(1);
  608. World.DeleteSceneObject(m_host.ParentGroup);
  609. }
  610. public double llGround(LSL_Types.Vector3 offset)
  611. {
  612. m_host.AddScriptLPS(1);
  613. int x = (int)(m_host.AbsolutePosition.X + offset.x);
  614. int y = (int)(m_host.AbsolutePosition.Y + offset.y);
  615. return World.GetLandHeight(x, y);
  616. }
  617. public double llCloud(LSL_Types.Vector3 offset)
  618. {
  619. m_host.AddScriptLPS(1);
  620. NotImplemented("llCloud");
  621. return 0;
  622. }
  623. public LSL_Types.Vector3 llWind(LSL_Types.Vector3 offset)
  624. {
  625. m_host.AddScriptLPS(1);
  626. NotImplemented("llWind");
  627. return new LSL_Types.Vector3();
  628. }
  629. public void llSetStatus(int status, int value)
  630. {
  631. m_host.AddScriptLPS(1);
  632. int statusrotationaxis = 0;
  633. if ((status & BuiltIn_Commands_BaseClass.STATUS_PHYSICS) == BuiltIn_Commands_BaseClass.STATUS_PHYSICS)
  634. {
  635. if (value == 1)
  636. m_host.ScriptSetPhysicsStatus(true);
  637. else
  638. m_host.ScriptSetPhysicsStatus(false);
  639. }
  640. if ((status & BuiltIn_Commands_BaseClass.STATUS_PHANTOM) == BuiltIn_Commands_BaseClass.STATUS_PHANTOM)
  641. {
  642. if (value == 1)
  643. m_host.ScriptSetPhantomStatus(true);
  644. else
  645. m_host.ScriptSetPhantomStatus(false);
  646. }
  647. if ((status & BuiltIn_Commands_BaseClass.STATUS_CAST_SHADOWS) == BuiltIn_Commands_BaseClass.STATUS_CAST_SHADOWS)
  648. {
  649. m_host.AddFlag(LLObject.ObjectFlags.CastShadows);
  650. }
  651. if ((status & BuiltIn_Commands_BaseClass.STATUS_ROTATE_X) == BuiltIn_Commands_BaseClass.STATUS_ROTATE_X)
  652. {
  653. statusrotationaxis |= BuiltIn_Commands_BaseClass.STATUS_ROTATE_X;
  654. }
  655. if ((status & BuiltIn_Commands_BaseClass.STATUS_ROTATE_Y) == BuiltIn_Commands_BaseClass.STATUS_ROTATE_Y)
  656. {
  657. statusrotationaxis |= BuiltIn_Commands_BaseClass.STATUS_ROTATE_Y;
  658. }
  659. if ((status & BuiltIn_Commands_BaseClass.STATUS_ROTATE_Z) == BuiltIn_Commands_BaseClass.STATUS_ROTATE_Z)
  660. {
  661. statusrotationaxis |= BuiltIn_Commands_BaseClass.STATUS_ROTATE_Z;
  662. }
  663. if ((status & BuiltIn_Commands_BaseClass.STATUS_BLOCK_GRAB) == BuiltIn_Commands_BaseClass.STATUS_BLOCK_GRAB)
  664. {
  665. NotImplemented("llSetStatus - STATUS_BLOCK_GRAB");
  666. }
  667. if ((status & BuiltIn_Commands_BaseClass.STATUS_DIE_AT_EDGE) == BuiltIn_Commands_BaseClass.STATUS_DIE_AT_EDGE)
  668. {
  669. if (value == 1)
  670. m_host.SetDieAtEdge(true);
  671. else
  672. m_host.SetDieAtEdge(false);
  673. }
  674. if ((status & BuiltIn_Commands_BaseClass.STATUS_RETURN_AT_EDGE) == BuiltIn_Commands_BaseClass.STATUS_RETURN_AT_EDGE)
  675. {
  676. NotImplemented("llSetStatus - STATUS_RETURN_AT_EDGE");
  677. }
  678. if ((status & BuiltIn_Commands_BaseClass.STATUS_SANDBOX) == BuiltIn_Commands_BaseClass.STATUS_SANDBOX)
  679. {
  680. NotImplemented("llSetStatus - STATUS_SANDBOX");
  681. }
  682. if (statusrotationaxis != 0)
  683. {
  684. m_host.SetAxisRotation(statusrotationaxis, value);
  685. }
  686. }
  687. public LSL_Types.LSLInteger llGetStatus(int status)
  688. {
  689. m_host.AddScriptLPS(1);
  690. // Console.WriteLine(m_host.UUID.ToString() + " status is " + m_host.GetEffectiveObjectFlags().ToString());
  691. switch (status)
  692. {
  693. case BuiltIn_Commands_BaseClass.STATUS_PHYSICS:
  694. if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Physics) == (uint)LLObject.ObjectFlags.Physics)
  695. {
  696. return 1;
  697. }
  698. return 0;
  699. case BuiltIn_Commands_BaseClass.STATUS_PHANTOM:
  700. if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Phantom) == (uint)LLObject.ObjectFlags.Phantom)
  701. {
  702. return 1;
  703. }
  704. return 0;
  705. case BuiltIn_Commands_BaseClass.STATUS_CAST_SHADOWS:
  706. if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.CastShadows) == (uint)LLObject.ObjectFlags.CastShadows)
  707. {
  708. return 1;
  709. }
  710. return 0;
  711. case BuiltIn_Commands_BaseClass.STATUS_BLOCK_GRAB:
  712. NotImplemented("llGetStatus - STATUS_BLOCK_GRAB");
  713. return 0;
  714. case BuiltIn_Commands_BaseClass.STATUS_DIE_AT_EDGE:
  715. if (m_host.GetDieAtEdge())
  716. return 1;
  717. else
  718. return 0;
  719. case BuiltIn_Commands_BaseClass.STATUS_RETURN_AT_EDGE:
  720. NotImplemented("llGetStatus - STATUS_RETURN_AT_EDGE");
  721. return 0;
  722. case BuiltIn_Commands_BaseClass.STATUS_ROTATE_X:
  723. NotImplemented("llGetStatus - STATUS_ROTATE_X");
  724. return 0;
  725. case BuiltIn_Commands_BaseClass.STATUS_ROTATE_Y:
  726. NotImplemented("llGetStatus - STATUS_ROTATE_Y");
  727. return 0;
  728. case BuiltIn_Commands_BaseClass.STATUS_ROTATE_Z:
  729. NotImplemented("llGetStatus - STATUS_ROTATE_Z");
  730. return 0;
  731. case BuiltIn_Commands_BaseClass.STATUS_SANDBOX:
  732. NotImplemented("llGetStatus - STATUS_SANDBOX");
  733. return 0;
  734. }
  735. return 0;
  736. }
  737. public void llSetScale(LSL_Types.Vector3 scale)
  738. {
  739. m_host.AddScriptLPS(1);
  740. SetScale(m_host, scale);
  741. }
  742. private void SetScale(SceneObjectPart part, LSL_Types.Vector3 scale)
  743. {
  744. // TODO: this needs to trigger a persistance save as well
  745. LLVector3 tmp = part.Scale;
  746. tmp.X = (float)scale.x;
  747. tmp.Y = (float)scale.y;
  748. tmp.Z = (float)scale.z;
  749. part.Scale = tmp;
  750. part.SendFullUpdateToAllClients();
  751. }
  752. public LSL_Types.Vector3 llGetScale()
  753. {
  754. m_host.AddScriptLPS(1);
  755. return new LSL_Types.Vector3(m_host.Scale.X, m_host.Scale.Y, m_host.Scale.Z);
  756. }
  757. public void llSetColor(LSL_Types.Vector3 color, int face)
  758. {
  759. m_host.AddScriptLPS(1);
  760. SetColor(m_host, color, face);
  761. }
  762. private void SetColor(SceneObjectPart part, LSL_Types.Vector3 color, int face)
  763. {
  764. LLObject.TextureEntry tex = part.Shape.Textures;
  765. LLColor texcolor;
  766. if (face > -1)
  767. {
  768. texcolor = tex.CreateFace((uint)face).RGBA;
  769. texcolor.R = (float)Math.Abs(color.x - 1);
  770. texcolor.G = (float)Math.Abs(color.y - 1);
  771. texcolor.B = (float)Math.Abs(color.z - 1);
  772. tex.FaceTextures[face].RGBA = texcolor;
  773. part.UpdateTexture(tex);
  774. return;
  775. }
  776. else if (face == -1)
  777. {
  778. for (uint i = 0; i < 32; i++)
  779. {
  780. if (tex.FaceTextures[i] != null)
  781. {
  782. texcolor = tex.FaceTextures[i].RGBA;
  783. texcolor.R = (float)Math.Abs(color.x - 1);
  784. texcolor.G = (float)Math.Abs(color.y - 1);
  785. texcolor.B = (float)Math.Abs(color.z - 1);
  786. tex.FaceTextures[i].RGBA = texcolor;
  787. }
  788. texcolor = tex.DefaultTexture.RGBA;
  789. texcolor.R = (float)Math.Abs(color.x - 1);
  790. texcolor.G = (float)Math.Abs(color.y - 1);
  791. texcolor.B = (float)Math.Abs(color.z - 1);
  792. tex.DefaultTexture.RGBA = texcolor;
  793. }
  794. part.UpdateTexture(tex);
  795. return;
  796. }
  797. }
  798. public double llGetAlpha(int face)
  799. {
  800. m_host.AddScriptLPS(1);
  801. LLObject.TextureEntry tex = m_host.Shape.Textures;
  802. if (face == -1) // TMP: Until we can determine number of sides, ALL_SIDES (-1) will return default color
  803. {
  804. return (double)((tex.DefaultTexture.RGBA.A * 255) / 255);
  805. }
  806. if (face > -1)
  807. {
  808. return (double)((tex.GetFace((uint)face).RGBA.A * 255) / 255);
  809. }
  810. return 0;
  811. }
  812. public void llSetAlpha(double alpha, int face)
  813. {
  814. m_host.AddScriptLPS(1);
  815. SetAlpha(m_host, alpha, face);
  816. }
  817. private void SetAlpha(SceneObjectPart part, double alpha, int face)
  818. {
  819. LLObject.TextureEntry tex = part.Shape.Textures;
  820. LLColor texcolor;
  821. if (face > -1)
  822. {
  823. texcolor = tex.CreateFace((uint)face).RGBA;
  824. texcolor.A = (float)Math.Abs(alpha - 1);
  825. tex.FaceTextures[face].RGBA = texcolor;
  826. part.UpdateTexture(tex);
  827. return;
  828. }
  829. else if (face == -1)
  830. {
  831. for (int i = 0; i < 32; i++)
  832. {
  833. if (tex.FaceTextures[i] != null)
  834. {
  835. texcolor = tex.FaceTextures[i].RGBA;
  836. texcolor.A = (float)Math.Abs(alpha - 1);
  837. tex.FaceTextures[i].RGBA = texcolor;
  838. }
  839. }
  840. texcolor = tex.DefaultTexture.RGBA;
  841. texcolor.A = (float)Math.Abs(alpha - 1);
  842. tex.DefaultTexture.RGBA = texcolor;
  843. part.UpdateTexture(tex);
  844. return;
  845. }
  846. }
  847. public LSL_Types.Vector3 llGetColor(int face)
  848. {
  849. m_host.AddScriptLPS(1);
  850. LLObject.TextureEntry tex = m_host.Shape.Textures;
  851. LLColor texcolor;
  852. LSL_Types.Vector3 rgb;
  853. if (face == -1) // TMP: Until we can determine number of sides, ALL_SIDES (-1) will return default color
  854. {
  855. texcolor = tex.DefaultTexture.RGBA;
  856. rgb.x = (255 - (texcolor.R * 255)) / 255;
  857. rgb.y = (255 - (texcolor.G * 255)) / 255;
  858. rgb.z = (255 - (texcolor.B * 255)) / 255;
  859. return rgb;
  860. }
  861. if (face > -1)
  862. {
  863. texcolor = tex.GetFace((uint)face).RGBA;
  864. rgb.x = (255 - (texcolor.R * 255)) / 255;
  865. rgb.y = (255 - (texcolor.G * 255)) / 255;
  866. rgb.z = (255 - (texcolor.B * 255)) / 255;
  867. return rgb;
  868. }
  869. else
  870. {
  871. return new LSL_Types.Vector3();
  872. }
  873. }
  874. public void llSetTexture(string texture, int face)
  875. {
  876. m_host.AddScriptLPS(1);
  877. SetTexture(m_host, texture, face);
  878. }
  879. private void SetTexture(SceneObjectPart part, string texture, int face)
  880. {
  881. LLUUID textureID=new LLUUID();
  882. if (!LLUUID.TryParse(texture, out textureID))
  883. {
  884. textureID=InventoryKey(texture, (int)AssetType.Texture);
  885. }
  886. if (textureID == LLUUID.Zero)
  887. return;
  888. LLObject.TextureEntry tex = part.Shape.Textures;
  889. if (face > -1)
  890. {
  891. LLObject.TextureEntryFace texface = tex.CreateFace((uint)face);
  892. texface.TextureID = textureID;
  893. tex.FaceTextures[face] = texface;
  894. part.UpdateTexture(tex);
  895. return;
  896. }
  897. else if (face == -1)
  898. {
  899. for (uint i = 0; i < 32; i++)
  900. {
  901. if (tex.FaceTextures[i] != null)
  902. {
  903. tex.FaceTextures[i].TextureID = textureID;
  904. }
  905. }
  906. tex.DefaultTexture.TextureID = textureID;
  907. part.UpdateTexture(tex);
  908. return;
  909. }
  910. }
  911. public void llScaleTexture(double u, double v, int face)
  912. {
  913. m_host.AddScriptLPS(1);
  914. ScaleTexture(m_host, u, v, face);
  915. }
  916. private void ScaleTexture(SceneObjectPart part, double u, double v, int face)
  917. {
  918. LLObject.TextureEntry tex = part.Shape.Textures;
  919. if (face > -1)
  920. {
  921. LLObject.TextureEntryFace texface = tex.CreateFace((uint)face);
  922. texface.RepeatU = (float)u;
  923. texface.RepeatV = (float)v;
  924. tex.FaceTextures[face] = texface;
  925. part.UpdateTexture(tex);
  926. return;
  927. }
  928. if (face == -1)
  929. {
  930. for (int i = 0; i < 32; i++)
  931. {
  932. if (tex.FaceTextures[i] != null)
  933. {
  934. tex.FaceTextures[i].RepeatU = (float)u;
  935. tex.FaceTextures[i].RepeatV = (float)v;
  936. }
  937. }
  938. tex.DefaultTexture.RepeatU = (float)u;
  939. tex.DefaultTexture.RepeatV = (float)v;
  940. part.UpdateTexture(tex);
  941. return;
  942. }
  943. }
  944. public void llOffsetTexture(double u, double v, int face)
  945. {
  946. m_host.AddScriptLPS(1);
  947. OffsetTexture(m_host, u, v, face);
  948. }
  949. private void OffsetTexture(SceneObjectPart part, double u, double v, int face)
  950. {
  951. LLObject.TextureEntry tex = part.Shape.Textures;
  952. if (face > -1)
  953. {
  954. LLObject.TextureEntryFace texface = tex.CreateFace((uint)face);
  955. texface.OffsetU = (float)u;
  956. texface.OffsetV = (float)v;
  957. tex.FaceTextures[face] = texface;
  958. part.UpdateTexture(tex);
  959. return;
  960. }
  961. if (face == -1)
  962. {
  963. for (int i = 0; i < 32; i++)
  964. {
  965. if (tex.FaceTextures[i] != null)
  966. {
  967. tex.FaceTextures[i].OffsetU = (float)u;
  968. tex.FaceTextures[i].OffsetV = (float)v;
  969. }
  970. }
  971. tex.DefaultTexture.OffsetU = (float)u;
  972. tex.DefaultTexture.OffsetV = (float)v;
  973. part.UpdateTexture(tex);
  974. return;
  975. }
  976. }
  977. public void llRotateTexture(double rotation, int face)
  978. {
  979. m_host.AddScriptLPS(1);
  980. RotateTexture(m_host, rotation, face);
  981. }
  982. private void RotateTexture(SceneObjectPart part, double rotation, int face)
  983. {
  984. LLObject.TextureEntry tex = part.Shape.Textures;
  985. if (face > -1)
  986. {
  987. LLObject.TextureEntryFace texface = tex.CreateFace((uint)face);
  988. texface.Rotation = (float)rotation;
  989. tex.FaceTextures[face] = texface;
  990. part.UpdateTexture(tex);
  991. return;
  992. }
  993. if (face == -1)
  994. {
  995. for (int i = 0; i < 32; i++)
  996. {
  997. if (tex.FaceTextures[i] != null)
  998. {
  999. tex.FaceTextures[i].Rotation = (float)rotation;
  1000. }
  1001. }
  1002. tex.DefaultTexture.Rotation = (float)rotation;
  1003. part.UpdateTexture(tex);
  1004. return;
  1005. }
  1006. }
  1007. public string llGetTexture(int face)
  1008. {
  1009. m_host.AddScriptLPS(1);
  1010. LLObject.TextureEntry tex = m_host.Shape.Textures;
  1011. if (face == -1)
  1012. {
  1013. face = 0;
  1014. }
  1015. if (face > -1)
  1016. {
  1017. LLObject.TextureEntryFace texface;
  1018. texface = tex.GetFace((uint)face);
  1019. return texface.TextureID.ToString();
  1020. }
  1021. else
  1022. {
  1023. return String.Empty;
  1024. }
  1025. }
  1026. public void llSetPos(LSL_Types.Vector3 pos)
  1027. {
  1028. m_host.AddScriptLPS(1);
  1029. SetPos(m_host, pos);
  1030. }
  1031. private void SetPos(SceneObjectPart part, LSL_Types.Vector3 pos)
  1032. {
  1033. if (part.ParentID != 0)
  1034. {
  1035. part.UpdateOffSet(new LLVector3((float)pos.x, (float)pos.y, (float)pos.z));
  1036. }
  1037. else
  1038. {
  1039. part.UpdateGroupPosition(new LLVector3((float)pos.x, (float)pos.y, (float)pos.z));
  1040. }
  1041. }
  1042. public LSL_Types.Vector3 llGetPos()
  1043. {
  1044. m_host.AddScriptLPS(1);
  1045. return new LSL_Types.Vector3(m_host.AbsolutePosition.X,
  1046. m_host.AbsolutePosition.Y,
  1047. m_host.AbsolutePosition.Z);
  1048. }
  1049. public LSL_Types.Vector3 llGetLocalPos()
  1050. {
  1051. m_host.AddScriptLPS(1);
  1052. if (m_host.ParentID != 0)
  1053. {
  1054. return new LSL_Types.Vector3(m_host.OffsetPosition.X,
  1055. m_host.OffsetPosition.Y,
  1056. m_host.OffsetPosition.Z);
  1057. }
  1058. else
  1059. {
  1060. return new LSL_Types.Vector3(m_host.AbsolutePosition.X,
  1061. m_host.AbsolutePosition.Y,
  1062. m_host.AbsolutePosition.Z);
  1063. }
  1064. }
  1065. public void llSetRot(LSL_Types.Quaternion rot)
  1066. {
  1067. m_host.AddScriptLPS(1);
  1068. SetRot(m_host, rot);
  1069. }
  1070. private void SetRot(SceneObjectPart part, LSL_Types.Quaternion rot)
  1071. {
  1072. part.UpdateRotation(new LLQuaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s));
  1073. // Update rotation does not move the object in the physics scene if it's a linkset.
  1074. part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition;
  1075. }
  1076. public LSL_Types.Quaternion llGetRot()
  1077. {
  1078. m_host.AddScriptLPS(1);
  1079. LLQuaternion q = m_host.RotationOffset;
  1080. return new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W);
  1081. }
  1082. public LSL_Types.Quaternion llGetLocalRot()
  1083. {
  1084. m_host.AddScriptLPS(1);
  1085. return new LSL_Types.Quaternion(m_host.RotationOffset.X, m_host.RotationOffset.Y, m_host.RotationOffset.Z, m_host.RotationOffset.W);
  1086. }
  1087. public void llSetForce(LSL_Types.Vector3 force, int local)
  1088. {
  1089. m_host.AddScriptLPS(1);
  1090. NotImplemented("llSetForce");
  1091. }
  1092. public LSL_Types.Vector3 llGetForce()
  1093. {
  1094. m_host.AddScriptLPS(1);
  1095. NotImplemented("llGetForce");
  1096. return new LSL_Types.Vector3();
  1097. }
  1098. public LSL_Types.LSLInteger llTarget(LSL_Types.Vector3 position, double range)
  1099. {
  1100. m_host.AddScriptLPS(1);
  1101. return m_host.registerTargetWaypoint(new LLVector3((float)position.x, (float)position.y, (float)position.z), (float)range);
  1102. }
  1103. public void llTargetRemove(int number)
  1104. {
  1105. m_host.AddScriptLPS(1);
  1106. m_host.unregisterTargetWaypoint(number);
  1107. }
  1108. public LSL_Types.LSLInteger llRotTarget(LSL_Types.Quaternion rot, double error)
  1109. {
  1110. m_host.AddScriptLPS(1);
  1111. NotImplemented("llRotTarget");
  1112. return 0;
  1113. }
  1114. public void llRotTargetRemove(int number)
  1115. {
  1116. m_host.AddScriptLPS(1);
  1117. NotImplemented("llRotTargetRemove");
  1118. }
  1119. public void llMoveToTarget(LSL_Types.Vector3 target, double tau)
  1120. {
  1121. m_host.AddScriptLPS(1);
  1122. m_host.MoveToTarget(new LLVector3((float)target.x, (float)target.y, (float)target.z), (float)tau);
  1123. }
  1124. public void llStopMoveToTarget()
  1125. {
  1126. m_host.AddScriptLPS(1);
  1127. m_host.StopMoveToTarget();
  1128. }
  1129. public void llApplyImpulse(LSL_Types.Vector3 force, int local)
  1130. {
  1131. m_host.AddScriptLPS(1);
  1132. //No energy force yet
  1133. if (force.x > 20000)
  1134. force.x = 20000;
  1135. if (force.y > 20000)
  1136. force.y = 20000;
  1137. if (force.z > 20000)
  1138. force.z = 20000;
  1139. if (local == 1)
  1140. {
  1141. m_host.ApplyImpulse(new LLVector3((float)force.x, (float)force.y, (float)force.z), true);
  1142. }
  1143. else
  1144. {
  1145. m_host.ApplyImpulse(new LLVector3((float)force.x,(float)force.y,(float)force.z), false);
  1146. }
  1147. }
  1148. public void llApplyRotationalImpulse(LSL_Types.Vector3 force, int local)
  1149. {
  1150. m_host.AddScriptLPS(1);
  1151. NotImplemented("llApplyRotationalImpulse");
  1152. }
  1153. public void llSetTorque(LSL_Types.Vector3 torque, int local)
  1154. {
  1155. m_host.AddScriptLPS(1);
  1156. NotImplemented("llSetTorque");
  1157. }
  1158. public LSL_Types.Vector3 llGetTorque()
  1159. {
  1160. m_host.AddScriptLPS(1);
  1161. NotImplemented("llGetTorque");
  1162. return new LSL_Types.Vector3();
  1163. }
  1164. public void llSetForceAndTorque(LSL_Types.Vector3 force, LSL_Types.Vector3 torque, int local)
  1165. {
  1166. m_host.AddScriptLPS(1);
  1167. NotImplemented("llSetForceAndTorque");
  1168. }
  1169. public LSL_Types.Vector3 llGetVel()
  1170. {
  1171. m_host.AddScriptLPS(1);
  1172. return new LSL_Types.Vector3(m_host.Velocity.X, m_host.Velocity.Y, m_host.Velocity.Z);
  1173. }
  1174. public LSL_Types.Vector3 llGetAccel()
  1175. {
  1176. m_host.AddScriptLPS(1);
  1177. return new LSL_Types.Vector3(m_host.Acceleration.X, m_host.Acceleration.Y, m_host.Acceleration.Z);
  1178. }
  1179. public LSL_Types.Vector3 llGetOmega()
  1180. {
  1181. m_host.AddScriptLPS(1);
  1182. return new LSL_Types.Vector3(m_host.RotationalVelocity.X, m_host.RotationalVelocity.Y, m_host.RotationalVelocity.Z);
  1183. }
  1184. public double llGetTimeOfDay()
  1185. {
  1186. m_host.AddScriptLPS(1);
  1187. NotImplemented("llGetTimeOfDay");
  1188. return 0;
  1189. }
  1190. public double llGetWallclock()
  1191. {
  1192. m_host.AddScriptLPS(1);
  1193. return DateTime.Now.TimeOfDay.TotalSeconds;
  1194. }
  1195. public double llGetTime()
  1196. {
  1197. m_host.AddScriptLPS(1);
  1198. TimeSpan ScriptTime = DateTime.Now - m_timer;
  1199. return (double)((ScriptTime.TotalMilliseconds / 1000)*World.TimeDilation);
  1200. }
  1201. public void llResetTime()
  1202. {
  1203. m_host.AddScriptLPS(1);
  1204. m_timer = DateTime.Now;
  1205. }
  1206. public double llGetAndResetTime()
  1207. {
  1208. m_host.AddScriptLPS(1);
  1209. TimeSpan ScriptTime = DateTime.Now - m_timer;
  1210. m_timer = DateTime.Now;
  1211. return (double)((ScriptTime.TotalMilliseconds / 1000)*World.TimeDilation);
  1212. }
  1213. public void llSound()
  1214. {
  1215. m_host.AddScriptLPS(1);
  1216. // This function has been deprecated
  1217. // see http://www.lslwiki.net/lslwiki/wakka.php?wakka=llSound
  1218. Deprecated("llSound");
  1219. }
  1220. // Xantor 20080528 PlaySound updated so it accepts an objectinventory name -or- a key to a sound
  1221. public void llPlaySound(string sound, double volume)
  1222. {
  1223. m_host.AddScriptLPS(1);
  1224. LLUUID key = LLUUID.Zero;
  1225. // if we can parse the string as a key, use it.
  1226. if (LLUUID.TryParse(sound, out key))
  1227. {
  1228. sound = key.ToString();
  1229. }
  1230. // else try to locate the name in inventory of object. found returns key,
  1231. // not found returns LLUUID.Zero
  1232. else
  1233. {
  1234. sound = InventoryKey(sound).ToString();
  1235. }
  1236. // send the sound, once, to all clients in range
  1237. m_host.SendSound(sound, volume, false, 0);
  1238. }
  1239. // Xantor 20080528 we should do this differently.
  1240. // 1) apply the sound to the object
  1241. // 2) schedule full update
  1242. // just sending the sound out once doesn't work so well when other avatars come in view later on
  1243. // or when the prim gets moved, changed, sat on, whatever
  1244. // see large number of mantises (mantes?)
  1245. public void llLoopSound(string sound, double volume)
  1246. {
  1247. m_host.AddScriptLPS(1);
  1248. // m_host.SendSound(sound, volume, false, 1);
  1249. LLUUID key = LLUUID.Zero;
  1250. // if we can parse the string as a key, use it.
  1251. if (LLUUID.TryParse(sound, out key))
  1252. {
  1253. m_host.Sound = key;
  1254. }
  1255. // else try to locate the name in inventory of object. found returns key,
  1256. // not found returns LLUUID.Zero
  1257. else
  1258. {
  1259. m_host.Sound = InventoryKey(sound.ToString());
  1260. }
  1261. m_host.SoundGain = volume;
  1262. m_host.SoundFlags = 1; // looping
  1263. m_host.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable?
  1264. m_host.SendFullUpdateToAllClients();
  1265. }
  1266. public void llLoopSoundMaster(string sound, double volume)
  1267. {
  1268. m_host.AddScriptLPS(1);
  1269. NotImplemented("llLoopSoundMaster");
  1270. }
  1271. public void llLoopSoundSlave(string sound, double volume)
  1272. {
  1273. m_host.AddScriptLPS(1);
  1274. NotImplemented("llLoopSoundSlave");
  1275. }
  1276. public void llPlaySoundSlave(string sound, double volume)
  1277. {
  1278. m_host.AddScriptLPS(1);
  1279. NotImplemented("llPlaySoundSlave");
  1280. }
  1281. public void llTriggerSound(string sound, double volume)
  1282. {
  1283. m_host.AddScriptLPS(1);
  1284. m_host.SendSound(sound, volume, true, 0);
  1285. }
  1286. // Xantor 20080528: Clear prim data of sound instead
  1287. public void llStopSound()
  1288. {
  1289. m_host.AddScriptLPS(1);
  1290. m_host.Sound = LLUUID.Zero;
  1291. m_host.SoundGain = 0;
  1292. m_host.SoundFlags = 0;
  1293. m_host.SoundRadius = 0;
  1294. m_host.SendFullUpdateToAllClients();
  1295. // m_host.SendSound(LLUUID.Zero.ToString(), 1.0, false, 2);
  1296. }
  1297. public void llPreloadSound(string sound)
  1298. {
  1299. m_host.AddScriptLPS(1);
  1300. m_host.PreloadSound(sound);
  1301. }
  1302. /// <summary>
  1303. /// Return a portion of the designated string bounded by
  1304. /// inclusive indices (start and end). As usual, the negative
  1305. /// indices, and the tolerance for out-of-bound values, makes
  1306. /// this more complicated than it might otherwise seem.
  1307. /// </summary>
  1308. public string llGetSubString(string src, int start, int end)
  1309. {
  1310. m_host.AddScriptLPS(1);
  1311. // Normalize indices (if negative).
  1312. // After normlaization they may still be
  1313. // negative, but that is now relative to
  1314. // the start, rather than the end, of the
  1315. // sequence.
  1316. if (start < 0)
  1317. {
  1318. start = src.Length+start;
  1319. }
  1320. if (end < 0)
  1321. {
  1322. end = src.Length+end;
  1323. }
  1324. // Conventional substring
  1325. if (start <= end)
  1326. {
  1327. // Implies both bounds are out-of-range.
  1328. if (end < 0 || start >= src.Length)
  1329. {
  1330. return String.Empty;
  1331. }
  1332. // If end is positive, then it directly
  1333. // corresponds to the lengt of the substring
  1334. // needed (plus one of course). BUT, it
  1335. // must be within bounds.
  1336. if (end >= src.Length)
  1337. {
  1338. end = src.Length-1;
  1339. }
  1340. if (start < 0)
  1341. {
  1342. return src.Substring(0,end+1);
  1343. }
  1344. // Both indices are positive
  1345. return src.Substring(start, (end+1) - start);
  1346. }
  1347. // Inverted substring (end < start)
  1348. else
  1349. {
  1350. // Implies both indices are below the
  1351. // lower bound. In the inverted case, that
  1352. // means the entire string will be returned
  1353. // unchanged.
  1354. if (start < 0)
  1355. {
  1356. return src;
  1357. }
  1358. // If both indices are greater than the upper
  1359. // bound the result may seem initially counter
  1360. // intuitive.
  1361. if (end >= src.Length)
  1362. {
  1363. return src;
  1364. }
  1365. if (end < 0)
  1366. {
  1367. if (start < src.Length)
  1368. {
  1369. return src.Substring(start);
  1370. }
  1371. else
  1372. {
  1373. return String.Empty;
  1374. }
  1375. }
  1376. else
  1377. {
  1378. if (start < src.Length)
  1379. {
  1380. return src.Substring(0,end+1) + src.Substring(start);
  1381. }
  1382. else
  1383. {
  1384. return src.Substring(0,end+1);
  1385. }
  1386. }
  1387. }
  1388. }
  1389. /// <summary>
  1390. /// Delete substring removes the specified substring bounded
  1391. /// by the inclusive indices start and end. Indices may be
  1392. /// negative (indicating end-relative) and may be inverted,
  1393. /// i.e. end < start.
  1394. /// </summary>
  1395. public string llDeleteSubString(string src, int start, int end)
  1396. {
  1397. m_host.AddScriptLPS(1);
  1398. // Normalize indices (if negative).
  1399. // After normlaization they may still be
  1400. // negative, but that is now relative to
  1401. // the start, rather than the end, of the
  1402. // sequence.
  1403. if (start < 0)
  1404. {
  1405. start = src.Length+start;
  1406. }
  1407. if (end < 0)
  1408. {
  1409. end = src.Length+end;
  1410. }
  1411. // Conventionally delimited substring
  1412. if (start <= end)
  1413. {
  1414. // If both bounds are outside of the existing
  1415. // string, then return unchanges.
  1416. if (end < 0 || start >= src.Length)
  1417. {
  1418. return src;
  1419. }
  1420. // At least one bound is in-range, so we
  1421. // need to clip the out-of-bound argument.
  1422. if (start < 0)
  1423. {
  1424. start = 0;
  1425. }
  1426. if (end >= src.Length)
  1427. {
  1428. end = src.Length-1;
  1429. }
  1430. return src.Remove(start,end-start+1);
  1431. }
  1432. // Inverted substring
  1433. else
  1434. {
  1435. // In this case, out of bounds means that
  1436. // the existing string is part of the cut.
  1437. if (start < 0 || end >= src.Length)
  1438. {
  1439. return String.Empty;
  1440. }
  1441. if (end > 0)
  1442. {
  1443. if (start < src.Length)
  1444. {
  1445. return src.Remove(start).Remove(0,end+1);
  1446. }
  1447. else
  1448. {
  1449. return src.Remove(0,end+1);
  1450. }
  1451. }
  1452. else
  1453. {
  1454. if (start < src.Length)
  1455. {
  1456. return src.Remove(start);
  1457. }
  1458. else
  1459. {
  1460. return src;
  1461. }
  1462. }
  1463. }
  1464. }
  1465. /// <summary>
  1466. /// Insert string inserts the specified string identified by src
  1467. /// at the index indicated by index. Index may be negative, in
  1468. /// which case it is end-relative. The index may exceed either
  1469. /// string bound, with the result being a concatenation.
  1470. /// </summary>
  1471. public string llInsertString(string dest, int index, string src)
  1472. {
  1473. m_host.AddScriptLPS(1);
  1474. // Normalize indices (if negative).
  1475. // After normlaization they may still be
  1476. // negative, but that is now relative to
  1477. // the start, rather than the end, of the
  1478. // sequence.
  1479. if (index < 0)
  1480. {
  1481. index = dest.Length+index;
  1482. // Negative now means it is less than the lower
  1483. // bound of the string.
  1484. if (index < 0)
  1485. {
  1486. return src+dest;
  1487. }
  1488. }
  1489. if (index >= dest.Length)
  1490. {
  1491. return dest+src;
  1492. }
  1493. // The index is in bounds.
  1494. // In this case the index refers to the index that will
  1495. // be assigned to the first character of the inserted string.
  1496. // So unlike the other string operations, we do not add one
  1497. // to get the correct string length.
  1498. return dest.Substring(0,index)+src+dest.Substring(index);
  1499. }
  1500. public string llToUpper(string src)
  1501. {
  1502. m_host.AddScriptLPS(1);
  1503. return src.ToUpper();
  1504. }
  1505. public string llToLower(string src)
  1506. {
  1507. m_host.AddScriptLPS(1);
  1508. return src.ToLower();
  1509. }
  1510. public LSL_Types.LSLInteger llGiveMoney(string destination, int amount)
  1511. {
  1512. LLUUID invItemID=InventorySelf();
  1513. if (invItemID == LLUUID.Zero)
  1514. return 0;
  1515. m_host.AddScriptLPS(1);
  1516. if (m_host.TaskInventory[invItemID].PermsGranter == LLUUID.Zero)
  1517. return 0;
  1518. if ((m_host.TaskInventory[invItemID].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_DEBIT) == 0)
  1519. {
  1520. LSLError("No permissions to give money");
  1521. return 0;
  1522. }
  1523. LLUUID toID=new LLUUID();
  1524. if (!LLUUID.TryParse(destination, out toID))
  1525. {
  1526. LSLError("Bad key in llGiveMoney");
  1527. return 0;
  1528. }
  1529. IMoneyModule money=World.RequestModuleInterface<IMoneyModule>();
  1530. if (money == null)
  1531. {
  1532. NotImplemented("llGiveMoney");
  1533. return 0;
  1534. }
  1535. bool result=money.ObjectGiveMoney(m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount);
  1536. if (result)
  1537. return 1;
  1538. return 0;
  1539. }
  1540. public void llMakeExplosion()
  1541. {
  1542. m_host.AddScriptLPS(1);
  1543. NotImplemented("llMakeExplosion");
  1544. }
  1545. public void llMakeFountain()
  1546. {
  1547. m_host.AddScriptLPS(1);
  1548. NotImplemented("llMakeFountain");
  1549. }
  1550. public void llMakeSmoke()
  1551. {
  1552. m_host.AddScriptLPS(1);
  1553. NotImplemented("llMakeSmoke");
  1554. }
  1555. public void llMakeFire()
  1556. {
  1557. m_host.AddScriptLPS(1);
  1558. NotImplemented("llMakeFire");
  1559. }
  1560. public void llRezObject(string inventory, LSL_Types.Vector3 pos, LSL_Types.Vector3 vel, LSL_Types.Quaternion rot, int param)
  1561. {
  1562. m_host.AddScriptLPS(1);
  1563. //NotImplemented("llRezObject");
  1564. bool found = false;
  1565. // Instead of using return;, I'm using continue; because in our TaskInventory implementation
  1566. // it's possible to have two items with the same task inventory name.
  1567. // this is an easter egg of sorts.
  1568. foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
  1569. {
  1570. if (inv.Value.Name == inventory)
  1571. {
  1572. // make sure we're an object.
  1573. if (inv.Value.InvType != (int)InventoryType.Object)
  1574. {
  1575. llSay(0, "Unable to create requested object. Object is missing from database.");
  1576. continue;
  1577. }
  1578. LLVector3 llpos = new LLVector3((float)pos.x, (float)pos.y, (float)pos.z);
  1579. // test if we're further away then 10m
  1580. if (Util.GetDistanceTo(llpos, m_host.AbsolutePosition) > 10)
  1581. return; // wiki says, if it's further away then 10m, silently fail.
  1582. LLVector3 llvel = new LLVector3((float)vel.x, (float)vel.y, (float)vel.z);
  1583. // need the magnitude later
  1584. float velmag = (float)Util.GetMagnitude(llvel);
  1585. SceneObjectGroup new_group = World.RezObject(inv.Value, llpos, new LLQuaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s), llvel, param);
  1586. // If either of these are null, then there was an unknown error.
  1587. if (new_group == null)
  1588. continue;
  1589. if (new_group.RootPart == null)
  1590. continue;
  1591. // objects rezzed with this method are die_at_edge by default.
  1592. new_group.RootPart.SetDieAtEdge(true);
  1593. m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(m_localID, m_itemID, "object_rez", EventQueueManager.llDetectNull, new Object[] { new LSL_Types.LSLString(new_group.RootPart.UUID.ToString()) });
  1594. float groupmass = new_group.GetMass();
  1595. //Recoil.
  1596. llApplyImpulse(new LSL_Types.Vector3(llvel.X * groupmass, llvel.Y * groupmass, llvel.Z * groupmass), 0);
  1597. found = true;
  1598. //script delay
  1599. System.Threading.Thread.Sleep((int)((groupmass * velmag) / 10));
  1600. break;
  1601. }
  1602. }
  1603. if (!found)
  1604. llSay(0, "Could not find object " + inventory);
  1605. }
  1606. public void llLookAt(LSL_Types.Vector3 target, double strength, double damping)
  1607. {
  1608. m_host.AddScriptLPS(1);
  1609. NotImplemented("llLookAt");
  1610. }
  1611. public void llStopLookAt()
  1612. {
  1613. m_host.AddScriptLPS(1);
  1614. NotImplemented("llStopLookAt");
  1615. }
  1616. public void llSetTimerEvent(double sec)
  1617. {
  1618. m_host.AddScriptLPS(1);
  1619. // Setting timer repeat
  1620. m_ScriptEngine.m_ASYNCLSLCommandManager.m_Timer.SetTimerEvent(m_localID, m_itemID, sec);
  1621. }
  1622. public void llSleep(double sec)
  1623. {
  1624. m_host.AddScriptLPS((int)(sec * 100));
  1625. Thread.Sleep((int)(sec * 1000));
  1626. }
  1627. public double llGetMass()
  1628. {
  1629. m_host.AddScriptLPS(1);
  1630. return m_host.GetMass();
  1631. }
  1632. public void llCollisionFilter(string name, string id, int accept)
  1633. {
  1634. m_host.AddScriptLPS(1);
  1635. NotImplemented("llCollisionFilter");
  1636. }
  1637. public void llTakeControls(int controls, int accept, int pass_on)
  1638. {
  1639. if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
  1640. {
  1641. return;
  1642. }
  1643. if (m_host.TaskInventory[InventorySelf()].PermsGranter != LLUUID.Zero)
  1644. {
  1645. ScenePresence presence = World.GetScenePresence(m_host.TaskInventory[InventorySelf()].PermsGranter);
  1646. if (presence != null)
  1647. {
  1648. if ((m_host.TaskInventory[InventorySelf()].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_TAKE_CONTROLS) != 0)
  1649. {
  1650. presence.RegisterControlEventsToScript(controls, accept, pass_on, m_localID, m_itemID);
  1651. }
  1652. }
  1653. }
  1654. m_host.AddScriptLPS(1);
  1655. //NotImplemented("llTakeControls");
  1656. }
  1657. public void llReleaseControls()
  1658. {
  1659. m_host.AddScriptLPS(1);
  1660. if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
  1661. {
  1662. return;
  1663. }
  1664. if (m_host.TaskInventory[InventorySelf()].PermsGranter != LLUUID.Zero)
  1665. {
  1666. ScenePresence presence = World.GetScenePresence(m_host.TaskInventory[InventorySelf()].PermsGranter);
  1667. if (presence != null)
  1668. {
  1669. if ((m_host.TaskInventory[InventorySelf()].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_TAKE_CONTROLS) != 0)
  1670. {
  1671. // Unregister controls from Presence
  1672. presence.UnRegisterControlEventsToScript(m_localID, m_itemID);
  1673. // Remove Take Control permission.
  1674. m_host.TaskInventory[InventorySelf()].PermsMask &= ~BuiltIn_Commands_BaseClass.PERMISSION_TAKE_CONTROLS;
  1675. }
  1676. }
  1677. }
  1678. }
  1679. public void llAttachToAvatar(int attachment)
  1680. {
  1681. m_host.AddScriptLPS(1);
  1682. NotImplemented("llAttachToAvatar");
  1683. }
  1684. public void llDetachFromAvatar()
  1685. {
  1686. m_host.AddScriptLPS(1);
  1687. NotImplemented("llDetachFromAvatar");
  1688. }
  1689. public void llTakeCamera()
  1690. {
  1691. m_host.AddScriptLPS(1);
  1692. NotImplemented("llTakeCamera");
  1693. }
  1694. public void llReleaseCamera()
  1695. {
  1696. m_host.AddScriptLPS(1);
  1697. NotImplemented("llReleaseCamera");
  1698. }
  1699. public string llGetOwner()
  1700. {
  1701. m_host.AddScriptLPS(1);
  1702. return m_host.ObjectOwner.ToString();
  1703. }
  1704. public void llInstantMessage(string user, string message)
  1705. {
  1706. m_host.AddScriptLPS(1);
  1707. // We may be able to use ClientView.SendInstantMessage here, but we need a client instance.
  1708. // InstantMessageModule.OnInstantMessage searches through a list of scenes for a client matching the toAgent,
  1709. // but I don't think we have a list of scenes available from here.
  1710. // (We also don't want to duplicate the code in OnInstantMessage if we can avoid it.)
  1711. // user is a UUID
  1712. // TODO: figure out values for client, fromSession, and imSessionID
  1713. // client.SendInstantMessage(m_host.UUID, fromSession, message, user, imSessionID, m_host.Name, AgentManager.InstantMessageDialog.MessageFromAgent, (uint)Util.UnixTimeSinceEpoch());
  1714. LLUUID friendTransactionID = LLUUID.Random();
  1715. //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID);
  1716. GridInstantMessage msg = new GridInstantMessage();
  1717. msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.UUID;
  1718. msg.fromAgentSession = new Guid(friendTransactionID.ToString());// fromAgentSession.UUID;
  1719. msg.toAgentID = new Guid(user); // toAgentID.UUID;
  1720. msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here
  1721. Console.WriteLine("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message);
  1722. Console.WriteLine("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString());
  1723. msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp;
  1724. //if (client != null)
  1725. //{
  1726. msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName;
  1727. //}
  1728. //else
  1729. //{
  1730. // msg.fromAgentName = "(hippos)";// Added for posterity. This means that we can't figure out who sent it
  1731. //}
  1732. msg.message = message;
  1733. msg.dialog = (byte)19; // messgage from script ??? // dialog;
  1734. msg.fromGroup = false;// fromGroup;
  1735. msg.offline = (byte)0; //offline;
  1736. msg.ParentEstateID = 0; //ParentEstateID;
  1737. msg.Position = new sLLVector3();// new sLLVector3(m_host.AbsolutePosition);
  1738. msg.RegionID = World.RegionInfo.RegionID.UUID;//RegionID.UUID;
  1739. msg.binaryBucket = new byte[0];// binaryBucket;
  1740. World.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule);
  1741. // NotImplemented("llInstantMessage");
  1742. }
  1743. public void llEmail(string address, string subject, string message)
  1744. {
  1745. m_host.AddScriptLPS(1);
  1746. NotImplemented("llEmail");
  1747. }
  1748. public void llGetNextEmail(string address, string subject)
  1749. {
  1750. m_host.AddScriptLPS(1);
  1751. NotImplemented("llGetNextEmail");
  1752. }
  1753. public string llGetKey()
  1754. {
  1755. m_host.AddScriptLPS(1);
  1756. return m_host.UUID.ToString();
  1757. }
  1758. public void llSetBuoyancy(double buoyancy)
  1759. {
  1760. m_host.AddScriptLPS(1);
  1761. if (m_host.ParentGroup != null)
  1762. {
  1763. if (m_host.ParentGroup.RootPart != null)
  1764. {
  1765. m_host.ParentGroup.RootPart.SetBuoyancy((float)buoyancy);
  1766. }
  1767. }
  1768. }
  1769. public void llSetHoverHeight(double height, int water, double tau)
  1770. {
  1771. m_host.AddScriptLPS(1);
  1772. NotImplemented("llSetHoverHeight");
  1773. }
  1774. public void llStopHover()
  1775. {
  1776. m_host.AddScriptLPS(1);
  1777. NotImplemented("llStopHover");
  1778. }
  1779. public void llMinEventDelay(double delay)
  1780. {
  1781. m_host.AddScriptLPS(1);
  1782. NotImplemented("llMinEventDelay");
  1783. }
  1784. public void llSoundPreload()
  1785. {
  1786. m_host.AddScriptLPS(1);
  1787. NotImplemented("llSoundPreload");
  1788. }
  1789. public void llRotLookAt(LSL_Types.Quaternion target, double strength, double damping)
  1790. {
  1791. m_host.AddScriptLPS(1);
  1792. NotImplemented("llRotLookAt");
  1793. }
  1794. public LSL_Types.LSLInteger llStringLength(string str)
  1795. {
  1796. m_host.AddScriptLPS(1);
  1797. if (str.Length > 0)
  1798. {
  1799. return str.Length;
  1800. }
  1801. else
  1802. {
  1803. return 0;
  1804. }
  1805. }
  1806. public void llStartAnimation(string anim)
  1807. {
  1808. m_host.AddScriptLPS(1);
  1809. LLUUID invItemID=InventorySelf();
  1810. if (invItemID == LLUUID.Zero)
  1811. return;
  1812. if (m_host.TaskInventory[invItemID].PermsGranter == LLUUID.Zero)
  1813. return;
  1814. if ((m_host.TaskInventory[invItemID].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
  1815. {
  1816. ScenePresence presence = World.GetScenePresence(m_host.TaskInventory[invItemID].PermsGranter);
  1817. if (presence != null)
  1818. {
  1819. // Do NOT try to parse LLUUID, animations cannot be triggered by ID
  1820. LLUUID animID=InventoryKey(anim, (int)AssetType.Animation);
  1821. if (animID == LLUUID.Zero)
  1822. presence.AddAnimation(anim);
  1823. else
  1824. presence.AddAnimation(animID);
  1825. }
  1826. }
  1827. }
  1828. public void llStopAnimation(string anim)
  1829. {
  1830. m_host.AddScriptLPS(1);
  1831. LLUUID invItemID=InventorySelf();
  1832. if (invItemID == LLUUID.Zero)
  1833. return;
  1834. if (m_host.TaskInventory[invItemID].PermsGranter == LLUUID.Zero)
  1835. return;
  1836. if ((m_host.TaskInventory[invItemID].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
  1837. {
  1838. LLUUID animID = new LLUUID();
  1839. if (!LLUUID.TryParse(anim, out animID))
  1840. {
  1841. animID=InventoryKey(anim);
  1842. }
  1843. if (animID == LLUUID.Zero)
  1844. return;
  1845. ScenePresence presence = World.GetScenePresence(m_host.TaskInventory[invItemID].PermsGranter);
  1846. if (presence != null)
  1847. {
  1848. if (animID == LLUUID.Zero)
  1849. presence.RemoveAnimation(anim);
  1850. else
  1851. presence.RemoveAnimation(animID);
  1852. }
  1853. }
  1854. }
  1855. public void llPointAt()
  1856. {
  1857. m_host.AddScriptLPS(1);
  1858. NotImplemented("llPointAt");
  1859. }
  1860. public void llStopPointAt()
  1861. {
  1862. m_host.AddScriptLPS(1);
  1863. NotImplemented("llStopPointAt");
  1864. }
  1865. public void llTargetOmega(LSL_Types.Vector3 axis, double spinrate, double gain)
  1866. {
  1867. m_host.AddScriptLPS(1);
  1868. m_host.RotationalVelocity = new LLVector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate));
  1869. m_host.AngularVelocity = new LLVector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate));
  1870. m_host.ScheduleTerseUpdate();
  1871. m_host.SendTerseUpdateToAllClients();
  1872. }
  1873. public LSL_Types.LSLInteger llGetStartParameter()
  1874. {
  1875. m_host.AddScriptLPS(1);
  1876. // NotImplemented("llGetStartParameter");
  1877. return m_host.ParentGroup.StartParameter;
  1878. }
  1879. public void llGodLikeRezObject(string inventory, LSL_Types.Vector3 pos)
  1880. {
  1881. m_host.AddScriptLPS(1);
  1882. NotImplemented("llGodLikeRezObject");
  1883. }
  1884. public void llRequestPermissions(string agent, int perm)
  1885. {
  1886. LLUUID agentID=new LLUUID();
  1887. if (!LLUUID.TryParse(agent, out agentID))
  1888. return;
  1889. LLUUID invItemID=InventorySelf();
  1890. if (invItemID == LLUUID.Zero)
  1891. return; // Not in a prim? How??
  1892. if (agentID == LLUUID.Zero || perm == 0) // Releasing permissions
  1893. {
  1894. m_host.TaskInventory[invItemID].PermsGranter=LLUUID.Zero;
  1895. m_host.TaskInventory[invItemID].PermsMask=0;
  1896. m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
  1897. m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {new LSL_Types.LSLInteger(0)});
  1898. return;
  1899. }
  1900. m_host.AddScriptLPS(1);
  1901. if (m_host.ParentGroup.RootPart.m_IsAttachment && agent == m_host.ParentGroup.RootPart.m_attachedAvatar)
  1902. {
  1903. // When attached, certain permissions are implicit if requested from owner
  1904. int implicitPerms = BuiltIn_Commands_BaseClass.PERMISSION_TAKE_CONTROLS |
  1905. BuiltIn_Commands_BaseClass.PERMISSION_TRIGGER_ANIMATION |
  1906. BuiltIn_Commands_BaseClass.PERMISSION_ATTACH;
  1907. if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
  1908. {
  1909. m_host.TaskInventory[invItemID].PermsGranter=agentID;
  1910. m_host.TaskInventory[invItemID].PermsMask=perm;
  1911. m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
  1912. m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {new LSL_Types.LSLInteger(perm)});
  1913. return;
  1914. }
  1915. }
  1916. else if (m_host.m_sitTargetAvatar == agentID) // Sitting avatar
  1917. {
  1918. // When agent is sitting, certain permissions are implicit if requested from sitting agent
  1919. int implicitPerms = BuiltIn_Commands_BaseClass.PERMISSION_TRIGGER_ANIMATION |
  1920. BuiltIn_Commands_BaseClass.PERMISSION_TRACK_CAMERA;
  1921. if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
  1922. {
  1923. m_host.TaskInventory[invItemID].PermsGranter=agentID;
  1924. m_host.TaskInventory[invItemID].PermsMask=perm;
  1925. m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
  1926. m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {new LSL_Types.LSLInteger(perm)});
  1927. return;
  1928. }
  1929. }
  1930. ScenePresence presence = World.GetScenePresence(agentID);
  1931. if (presence != null)
  1932. {
  1933. string ownerName=resolveName(m_host.ParentGroup.RootPart.OwnerID);
  1934. if (ownerName == String.Empty)
  1935. ownerName="(hippos)";
  1936. if (!m_waitingForScriptAnswer)
  1937. {
  1938. m_host.TaskInventory[invItemID].PermsGranter=agentID;
  1939. m_host.TaskInventory[invItemID].PermsMask=0;
  1940. presence.ControllingClient.OnScriptAnswer+=handleScriptAnswer;
  1941. m_waitingForScriptAnswer=true;
  1942. }
  1943. presence.ControllingClient.SendScriptQuestion(m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, invItemID, perm);
  1944. return;
  1945. }
  1946. // Requested agent is not in range, refuse perms
  1947. m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
  1948. m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {new LSL_Types.LSLInteger(0)});
  1949. }
  1950. void handleScriptAnswer(IClientAPI client, LLUUID taskID, LLUUID itemID, int answer)
  1951. {
  1952. if (taskID != m_host.UUID)
  1953. return;
  1954. LLUUID invItemID=InventorySelf();
  1955. if (invItemID == LLUUID.Zero)
  1956. return;
  1957. client.OnScriptAnswer-=handleScriptAnswer;
  1958. m_waitingForScriptAnswer=false;
  1959. m_host.TaskInventory[invItemID].PermsMask=answer;
  1960. m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
  1961. m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {new LSL_Types.LSLInteger(answer)});
  1962. }
  1963. public string llGetPermissionsKey()
  1964. {
  1965. m_host.AddScriptLPS(1);
  1966. foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
  1967. {
  1968. if (item.Type == 10 && item.ItemID == m_itemID)
  1969. {
  1970. return item.PermsGranter.ToString();
  1971. }
  1972. }
  1973. return LLUUID.Zero.ToString();
  1974. }
  1975. public LSL_Types.LSLInteger llGetPermissions()
  1976. {
  1977. m_host.AddScriptLPS(1);
  1978. foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
  1979. {
  1980. if (item.Type == 10 && item.ItemID == m_itemID)
  1981. {
  1982. return item.PermsMask;
  1983. }
  1984. }
  1985. return 0;
  1986. }
  1987. public LSL_Types.LSLInteger llGetLinkNumber()
  1988. {
  1989. m_host.AddScriptLPS(1);
  1990. if (m_host.ParentGroup.Children.Count > 0)
  1991. {
  1992. return m_host.LinkNum + 1;
  1993. }
  1994. else
  1995. {
  1996. return 0;
  1997. }
  1998. }
  1999. public void llSetLinkColor(int linknumber, LSL_Types.Vector3 color, int face)
  2000. {
  2001. m_host.AddScriptLPS(1);
  2002. SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknumber);
  2003. if (linknumber > -1)
  2004. {
  2005. LLObject.TextureEntry tex = part.Shape.Textures;
  2006. LLColor texcolor;
  2007. if (face > -1)
  2008. {
  2009. texcolor = tex.CreateFace((uint)face).RGBA;
  2010. texcolor.R = (float)Math.Abs(color.x - 1);
  2011. texcolor.G = (float)Math.Abs(color.y - 1);
  2012. texcolor.B = (float)Math.Abs(color.z - 1);
  2013. tex.FaceTextures[face].RGBA = texcolor;
  2014. part.UpdateTexture(tex);
  2015. return;
  2016. }
  2017. else if (face == -1)
  2018. {
  2019. texcolor = tex.DefaultTexture.RGBA;
  2020. texcolor.R = (float)Math.Abs(color.x - 1);
  2021. texcolor.G = (float)Math.Abs(color.y - 1);
  2022. texcolor.B = (float)Math.Abs(color.z - 1);
  2023. tex.DefaultTexture.RGBA = texcolor;
  2024. for (uint i = 0; i < 32; i++)
  2025. {
  2026. if (tex.FaceTextures[i] != null)
  2027. {
  2028. texcolor = tex.FaceTextures[i].RGBA;
  2029. texcolor.R = (float)Math.Abs(color.x - 1);
  2030. texcolor.G = (float)Math.Abs(color.y - 1);
  2031. texcolor.B = (float)Math.Abs(color.z - 1);
  2032. tex.FaceTextures[i].RGBA = texcolor;
  2033. }
  2034. }
  2035. texcolor = tex.DefaultTexture.RGBA;
  2036. texcolor.R = (float)Math.Abs(color.x - 1);
  2037. texcolor.G = (float)Math.Abs(color.y - 1);
  2038. texcolor.B = (float)Math.Abs(color.z - 1);
  2039. tex.DefaultTexture.RGBA = texcolor;
  2040. part.UpdateTexture(tex);
  2041. return;
  2042. }
  2043. return;
  2044. }
  2045. else if (linknumber == -1)
  2046. {
  2047. int num = m_host.ParentGroup.PrimCount;
  2048. for (int w = 0; w < num; w++)
  2049. {
  2050. linknumber = w;
  2051. part = m_host.ParentGroup.GetLinkNumPart(linknumber);
  2052. LLObject.TextureEntry tex = part.Shape.Textures;
  2053. LLColor texcolor;
  2054. if (face > -1)
  2055. {
  2056. texcolor = tex.CreateFace((uint)face).RGBA;
  2057. texcolor.R = (float)Math.Abs(color.x - 1);
  2058. texcolor.G = (float)Math.Abs(color.y - 1);
  2059. texcolor.B = (float)Math.Abs(color.z - 1);
  2060. tex.FaceTextures[face].RGBA = texcolor;
  2061. part.UpdateTexture(tex);
  2062. }
  2063. else if (face == -1)
  2064. {
  2065. texcolor = tex.DefaultTexture.RGBA;
  2066. texcolor.R = (float)Math.Abs(color.x - 1);
  2067. texcolor.G = (float)Math.Abs(color.y - 1);
  2068. texcolor.B = (float)Math.Abs(color.z - 1);
  2069. tex.DefaultTexture.RGBA = texcolor;
  2070. for (uint i = 0; i < 32; i++)
  2071. {
  2072. if (tex.FaceTextures[i] != null)
  2073. {
  2074. texcolor = tex.FaceTextures[i].RGBA;
  2075. texcolor.R = (float)Math.Abs(color.x - 1);
  2076. texcolor.G = (float)Math.Abs(color.y - 1);
  2077. texcolor.B = (float)Math.Abs(color.z - 1);
  2078. tex.FaceTextures[i].RGBA = texcolor;
  2079. }
  2080. }
  2081. texcolor = tex.DefaultTexture.RGBA;
  2082. texcolor.R = (float)Math.Abs(color.x - 1);
  2083. texcolor.G = (float)Math.Abs(color.y - 1);
  2084. texcolor.B = (float)Math.Abs(color.z - 1);
  2085. tex.DefaultTexture.RGBA = texcolor;
  2086. part.UpdateTexture(tex);
  2087. }
  2088. }
  2089. return;
  2090. }
  2091. }
  2092. public void llCreateLink(string target, int parent)
  2093. {
  2094. m_host.AddScriptLPS(1);
  2095. NotImplemented("llCreateLink");
  2096. }
  2097. public void llBreakLink(int linknum)
  2098. {
  2099. m_host.AddScriptLPS(1);
  2100. NotImplemented("llBreakLink");
  2101. }
  2102. public void llBreakAllLinks()
  2103. {
  2104. m_host.AddScriptLPS(1);
  2105. NotImplemented("llBreakAllLinks");
  2106. }
  2107. public string llGetLinkKey(int linknum)
  2108. {
  2109. m_host.AddScriptLPS(1);
  2110. SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknum);
  2111. if (part != null)
  2112. {
  2113. return part.UUID.ToString();
  2114. }
  2115. else
  2116. {
  2117. return LLUUID.Zero.ToString();
  2118. }
  2119. }
  2120. public string llGetLinkName(int linknum)
  2121. {
  2122. m_host.AddScriptLPS(1);
  2123. SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknum);
  2124. if (part != null)
  2125. {
  2126. return part.Name;
  2127. }
  2128. else
  2129. {
  2130. return LLUUID.Zero.ToString();
  2131. }
  2132. }
  2133. public LSL_Types.LSLInteger llGetInventoryNumber(int type)
  2134. {
  2135. m_host.AddScriptLPS(1);
  2136. int count = 0;
  2137. foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
  2138. {
  2139. if (inv.Value.Type == type || type == -1)
  2140. {
  2141. count = count + 1;
  2142. }
  2143. }
  2144. return count;
  2145. }
  2146. public string llGetInventoryName(int type, int number)
  2147. {
  2148. m_host.AddScriptLPS(1);
  2149. ArrayList keys = new ArrayList();
  2150. foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
  2151. {
  2152. if (inv.Value.Type == type || type == -1)
  2153. {
  2154. keys.Add(inv.Value.Name);
  2155. }
  2156. }
  2157. if (keys.Count == 0)
  2158. {
  2159. return String.Empty;
  2160. }
  2161. keys.Sort();
  2162. if (keys.Count > number)
  2163. {
  2164. return (string)keys[number];
  2165. }
  2166. return String.Empty;
  2167. }
  2168. public void llSetScriptState(string name, int run)
  2169. {
  2170. LLUUID item;
  2171. ScriptManager sm;
  2172. IScript script = null;
  2173. m_host.AddScriptLPS(1);
  2174. // These functions are supposed to be robust,
  2175. // so get the state one step at a time.
  2176. if ((item = ScriptByName(name)) != LLUUID.Zero)
  2177. {
  2178. if ((sm = m_ScriptEngine.m_ScriptManager) != null)
  2179. {
  2180. if (sm.Scripts.ContainsKey(m_localID))
  2181. {
  2182. if ((script = sm.GetScript(m_localID, item)) != null)
  2183. {
  2184. script.Exec.Running = (run==0) ? false : true;
  2185. }
  2186. }
  2187. }
  2188. }
  2189. // Required by SL
  2190. if (script == null)
  2191. ShoutError("llSetScriptState: script "+name+" not found");
  2192. // If we didn't find it, then it's safe to
  2193. // assume it is not running.
  2194. }
  2195. public double llGetEnergy()
  2196. {
  2197. m_host.AddScriptLPS(1);
  2198. // TODO: figure out real energy value
  2199. return 1.0f;
  2200. }
  2201. public void llGiveInventory(string destination, string inventory)
  2202. {
  2203. m_host.AddScriptLPS(1);
  2204. NotImplemented("llGiveInventory");
  2205. }
  2206. public void llRemoveInventory(string item)
  2207. {
  2208. m_host.AddScriptLPS(1);
  2209. NotImplemented("llRemoveInventory");
  2210. }
  2211. public void llSetText(string text, LSL_Types.Vector3 color, double alpha)
  2212. {
  2213. m_host.AddScriptLPS(1);
  2214. Vector3 av3 = new Vector3((float)color.x, (float)color.y, (float)color.z);
  2215. m_host.SetText(text, av3, alpha);
  2216. }
  2217. public double llWater(LSL_Types.Vector3 offset)
  2218. {
  2219. m_host.AddScriptLPS(1);
  2220. return World.RegionInfo.EstateSettings.waterHeight;
  2221. }
  2222. public void llPassTouches(int pass)
  2223. {
  2224. m_host.AddScriptLPS(1);
  2225. NotImplemented("llPassTouches");
  2226. }
  2227. public string llRequestAgentData(string id, int data)
  2228. {
  2229. m_host.AddScriptLPS(1);
  2230. NotImplemented("llRequestAgentData");
  2231. return String.Empty;
  2232. }
  2233. public string llRequestInventoryData(string name)
  2234. {
  2235. m_host.AddScriptLPS(1);
  2236. NotImplemented("llRequestInventoryData");
  2237. return String.Empty;
  2238. }
  2239. public void llSetDamage(double damage)
  2240. {
  2241. m_host.AddScriptLPS(1);
  2242. NotImplemented("llSetDamage");
  2243. }
  2244. public void llTeleportAgentHome(string agent)
  2245. {
  2246. m_host.AddScriptLPS(1);
  2247. NotImplemented("llTeleportAgentHome");
  2248. }
  2249. public void llModifyLand(int action, int brush)
  2250. {
  2251. m_host.AddScriptLPS(1);
  2252. World.ExternalChecks.ExternalChecksCanTerraformLand(m_host.OwnerID, new LLVector3(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, 0));
  2253. }
  2254. public void llCollisionSound(string impact_sound, double impact_volume)
  2255. {
  2256. m_host.AddScriptLPS(1);
  2257. NotImplemented("llCollisionSound");
  2258. }
  2259. public void llCollisionSprite(string impact_sprite)
  2260. {
  2261. m_host.AddScriptLPS(1);
  2262. NotImplemented("llCollisionSprite");
  2263. }
  2264. public string llGetAnimation(string id)
  2265. {
  2266. m_host.AddScriptLPS(1);
  2267. NotImplemented("llGetAnimation");
  2268. return String.Empty;
  2269. }
  2270. public void llResetScript()
  2271. {
  2272. m_host.AddScriptLPS(800);
  2273. m_ScriptEngine.m_ScriptManager.ResetScript(m_localID, m_itemID);
  2274. }
  2275. public void llMessageLinked(int linknum, int num, string msg, string id)
  2276. {
  2277. m_host.AddScriptLPS(1);
  2278. uint partLocalID;
  2279. LLUUID partItemID;
  2280. switch ((int)linknum)
  2281. {
  2282. case (int)BuiltIn_Commands_BaseClass.LINK_ROOT:
  2283. SceneObjectPart part = m_host.ParentGroup.RootPart;
  2284. foreach (TaskInventoryItem item in part.TaskInventory.Values)
  2285. {
  2286. if (item.Type == 10)
  2287. {
  2288. partLocalID = part.LocalId;
  2289. partItemID = item.ItemID;
  2290. object[] resobj = new object[]
  2291. {
  2292. new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id)
  2293. };
  2294. m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
  2295. partLocalID, partItemID, "link_message", EventQueueManager.llDetectNull, resobj
  2296. );
  2297. }
  2298. }
  2299. break;
  2300. case (int)BuiltIn_Commands_BaseClass.LINK_SET:
  2301. Console.WriteLine("LINK_SET");
  2302. foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts())
  2303. {
  2304. foreach (TaskInventoryItem item in partInst.TaskInventory.Values)
  2305. {
  2306. if (item.Type == 10)
  2307. {
  2308. partLocalID = partInst.LocalId;
  2309. partItemID = item.ItemID;
  2310. Object[] resobj = new object[]
  2311. {
  2312. new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id)
  2313. };
  2314. m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
  2315. partLocalID, partItemID, "link_message", EventQueueManager.llDetectNull, resobj
  2316. );
  2317. }
  2318. }
  2319. }
  2320. break;
  2321. case (int)BuiltIn_Commands_BaseClass.LINK_ALL_OTHERS:
  2322. foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts())
  2323. {
  2324. if (partInst.LocalId != m_host.LocalId)
  2325. {
  2326. foreach (TaskInventoryItem item in partInst.TaskInventory.Values)
  2327. {
  2328. if (item.Type == 10)
  2329. {
  2330. partLocalID = partInst.LocalId;
  2331. partItemID = item.ItemID;
  2332. Object[] resobj = new object[]
  2333. {
  2334. new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id)
  2335. };
  2336. m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
  2337. partLocalID, partItemID, "link_message", EventQueueManager.llDetectNull, resobj
  2338. );
  2339. }
  2340. }
  2341. }
  2342. }
  2343. break;
  2344. case (int)BuiltIn_Commands_BaseClass.LINK_ALL_CHILDREN:
  2345. foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts())
  2346. {
  2347. if (partInst.LocalId != m_host.ParentGroup.RootPart.LocalId)
  2348. {
  2349. foreach (TaskInventoryItem item in partInst.TaskInventory.Values)
  2350. {
  2351. if (item.Type == 10)
  2352. {
  2353. partLocalID = partInst.LocalId;
  2354. partItemID = item.ItemID;
  2355. Object[] resobj = new object[]
  2356. {
  2357. new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id)
  2358. };
  2359. m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
  2360. partLocalID, partItemID, "link_message", EventQueueManager.llDetectNull, resobj
  2361. );
  2362. }
  2363. }
  2364. }
  2365. }
  2366. break;
  2367. case (int)BuiltIn_Commands_BaseClass.LINK_THIS:
  2368. foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
  2369. {
  2370. if (item.Type == 10)
  2371. {
  2372. partItemID = item.ItemID;
  2373. object[] resobj = new object[]
  2374. {
  2375. new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id)
  2376. };
  2377. m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
  2378. m_localID, partItemID, "link_message", EventQueueManager.llDetectNull, resobj
  2379. );
  2380. }
  2381. }
  2382. break;
  2383. default:
  2384. foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts())
  2385. {
  2386. if ((partInst.LinkNum + 1) == linknum)
  2387. {
  2388. foreach (TaskInventoryItem item in partInst.TaskInventory.Values)
  2389. {
  2390. if (item.Type == 10)
  2391. {
  2392. partLocalID = partInst.LocalId;
  2393. partItemID = item.ItemID;
  2394. Object[] resObjDef = new object[]
  2395. {
  2396. new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id)
  2397. };
  2398. m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
  2399. partLocalID, partItemID, "link_message", EventQueueManager.llDetectNull, resObjDef
  2400. );
  2401. }
  2402. }
  2403. }
  2404. }
  2405. break;
  2406. }
  2407. }
  2408. public void llPushObject(string target, LSL_Types.Vector3 impulse, LSL_Types.Vector3 ang_impulse, int local)
  2409. {
  2410. m_host.AddScriptLPS(1);
  2411. NotImplemented("llPushObject");
  2412. }
  2413. public void llPassCollisions(int pass)
  2414. {
  2415. m_host.AddScriptLPS(1);
  2416. NotImplemented("llPassCollisions");
  2417. }
  2418. public string llGetScriptName()
  2419. {
  2420. string result = String.Empty;
  2421. m_host.AddScriptLPS(1);
  2422. foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
  2423. {
  2424. if (item.Type == 10 && item.ItemID == m_itemID)
  2425. {
  2426. result = item.Name!=null?item.Name:String.Empty;
  2427. break;
  2428. }
  2429. }
  2430. return result;
  2431. }
  2432. public LSL_Types.LSLInteger llGetNumberOfSides()
  2433. {
  2434. m_host.AddScriptLPS(1);
  2435. NotImplemented("llGetNumberOfSides");
  2436. return 0;
  2437. }
  2438. /* The new / changed functions were tested with the following LSL script:
  2439. default
  2440. {
  2441. state_entry()
  2442. {
  2443. rotation rot = llEuler2Rot(<0,70,0> * DEG_TO_RAD);
  2444. llOwnerSay("to get here, we rotate over: "+ (string) llRot2Axis(rot));
  2445. llOwnerSay("and we rotate for: "+ (llRot2Angle(rot) * RAD_TO_DEG));
  2446. // convert back and forth between quaternion <-> vector and angle
  2447. rotation newrot = llAxisAngle2Rot(llRot2Axis(rot),llRot2Angle(rot));
  2448. llOwnerSay("Old rotation was: "+(string) rot);
  2449. llOwnerSay("re-converted rotation is: "+(string) newrot);
  2450. llSetRot(rot); // to check the parameters in the prim
  2451. }
  2452. }
  2453. */
  2454. // Xantor 29/apr/2008
  2455. // Returns rotation described by rotating angle radians about axis.
  2456. // q = cos(a/2) + i (x * sin(a/2)) + j (y * sin(a/2)) + k (z * sin(a/2))
  2457. public LSL_Types.Quaternion llAxisAngle2Rot(LSL_Types.Vector3 axis, double angle)
  2458. {
  2459. m_host.AddScriptLPS(1);
  2460. double x, y, z, s, t;
  2461. s = Math.Cos(angle / 2);
  2462. t = Math.Sin(angle / 2); // temp value to avoid 2 more sin() calcs
  2463. x = axis.x * t;
  2464. y = axis.y * t;
  2465. z = axis.z * t;
  2466. return new LSL_Types.Quaternion(x,y,z,s);
  2467. // NotImplemented("llAxisAngle2Rot");
  2468. }
  2469. // Xantor 29/apr/2008
  2470. // converts a Quaternion to X,Y,Z axis rotations
  2471. public LSL_Types.Vector3 llRot2Axis(LSL_Types.Quaternion rot)
  2472. {
  2473. m_host.AddScriptLPS(1);
  2474. double x,y,z;
  2475. if (rot.s > 1) // normalization needed
  2476. {
  2477. double length = Math.Sqrt(rot.x * rot.x + rot.y * rot.y +
  2478. rot.z * rot.z + rot.s * rot.s);
  2479. rot.x /= length;
  2480. rot.y /= length;
  2481. rot.z /= length;
  2482. rot.s /= length;
  2483. }
  2484. double angle = 2 * Math.Acos(rot.s);
  2485. double s = Math.Sqrt(1 - rot.s * rot.s);
  2486. if (s < 0.001)
  2487. {
  2488. x = 1;
  2489. y = z = 0;
  2490. }
  2491. else
  2492. {
  2493. x = rot.x / s; // normalise axis
  2494. y = rot.y / s;
  2495. z = rot.z / s;
  2496. }
  2497. return new LSL_Types.Vector3(x,y,z);
  2498. // NotImplemented("llRot2Axis");
  2499. }
  2500. // Returns the angle of a quaternion (see llRot2Axis for the axis)
  2501. public double llRot2Angle(LSL_Types.Quaternion rot)
  2502. {
  2503. m_host.AddScriptLPS(1);
  2504. if (rot.s > 1) // normalization needed
  2505. {
  2506. double length = Math.Sqrt(rot.x * rot.x + rot.y * rot.y +
  2507. rot.z * rot.z + rot.s * rot.s);
  2508. rot.x /= length;
  2509. rot.y /= length;
  2510. rot.z /= length;
  2511. rot.s /= length;
  2512. }
  2513. double angle = 2 * Math.Acos(rot.s);
  2514. return angle;
  2515. // NotImplemented("llRot2Angle");
  2516. }
  2517. public double llAcos(double val)
  2518. {
  2519. m_host.AddScriptLPS(1);
  2520. return (double)Math.Acos(val);
  2521. }
  2522. public double llAsin(double val)
  2523. {
  2524. m_host.AddScriptLPS(1);
  2525. return (double)Math.Asin(val);
  2526. }
  2527. // Xantor 30/apr/2008
  2528. public double llAngleBetween(LSL_Types.Quaternion a, LSL_Types.Quaternion b)
  2529. {
  2530. m_host.AddScriptLPS(1);
  2531. return (double) Math.Acos(a.x * b.x + a.y * b.y + a.z * b.z + a.s * b.s) * 2;
  2532. // NotImplemented("llAngleBetween");
  2533. }
  2534. public string llGetInventoryKey(string name)
  2535. {
  2536. m_host.AddScriptLPS(1);
  2537. foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
  2538. {
  2539. if (inv.Value.Name == name)
  2540. {
  2541. if ((inv.Value.OwnerMask & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify))
  2542. {
  2543. return inv.Value.AssetID.ToString();
  2544. }
  2545. else
  2546. {
  2547. return LLUUID.Zero.ToString();
  2548. }
  2549. }
  2550. }
  2551. return LLUUID.Zero.ToString();
  2552. }
  2553. public void llAllowInventoryDrop(int add)
  2554. {
  2555. m_host.AddScriptLPS(1);
  2556. NotImplemented("llAllowInventoryDrop");
  2557. }
  2558. public LSL_Types.Vector3 llGetSunDirection()
  2559. {
  2560. m_host.AddScriptLPS(1);
  2561. LSL_Types.Vector3 SunDoubleVector3;
  2562. LLVector3 SunFloatVector3;
  2563. // sunPosition estate setting is set in OpenSim.Region.Environment.Modules.SunModule
  2564. // have to convert from LLVector3 (float) to LSL_Types.Vector3 (double)
  2565. SunFloatVector3 = World.RegionInfo.EstateSettings.sunPosition;
  2566. SunDoubleVector3.x = (double)SunFloatVector3.X;
  2567. SunDoubleVector3.y = (double)SunFloatVector3.Y;
  2568. SunDoubleVector3.z = (double)SunFloatVector3.Z;
  2569. return SunDoubleVector3;
  2570. }
  2571. public LSL_Types.Vector3 llGetTextureOffset(int face)
  2572. {
  2573. m_host.AddScriptLPS(1);
  2574. LLObject.TextureEntry tex = m_host.Shape.Textures;
  2575. LSL_Types.Vector3 offset;
  2576. if (face == -1)
  2577. {
  2578. face = 0;
  2579. }
  2580. offset.x = tex.GetFace((uint)face).OffsetU;
  2581. offset.y = tex.GetFace((uint)face).OffsetV;
  2582. offset.z = 0.0;
  2583. return offset;
  2584. }
  2585. public LSL_Types.Vector3 llGetTextureScale(int side)
  2586. {
  2587. m_host.AddScriptLPS(1);
  2588. LLObject.TextureEntry tex = m_host.Shape.Textures;
  2589. LSL_Types.Vector3 scale;
  2590. if (side == -1)
  2591. {
  2592. side = 0;
  2593. }
  2594. scale.x = tex.GetFace((uint)side).RepeatU;
  2595. scale.y = tex.GetFace((uint)side).RepeatV;
  2596. scale.z = 0.0;
  2597. return scale;
  2598. }
  2599. public double llGetTextureRot(int face)
  2600. {
  2601. m_host.AddScriptLPS(1);
  2602. LLObject.TextureEntry tex = m_host.Shape.Textures;
  2603. if (face == -1)
  2604. {
  2605. face = 0;
  2606. }
  2607. return tex.GetFace((uint)face).Rotation;
  2608. }
  2609. public LSL_Types.LSLInteger llSubStringIndex(string source, string pattern)
  2610. {
  2611. m_host.AddScriptLPS(1);
  2612. return source.IndexOf(pattern);
  2613. }
  2614. public string llGetOwnerKey(string id)
  2615. {
  2616. m_host.AddScriptLPS(1);
  2617. LLUUID key = new LLUUID();
  2618. if (LLUUID.TryParse(id, out key))
  2619. {
  2620. return World.GetSceneObjectPart(World.Entities[key].LocalId).OwnerID.ToString();
  2621. }
  2622. else
  2623. {
  2624. return LLUUID.Zero.ToString();
  2625. }
  2626. }
  2627. public LSL_Types.Vector3 llGetCenterOfMass()
  2628. {
  2629. m_host.AddScriptLPS(1);
  2630. NotImplemented("llGetCenterOfMass");
  2631. return new LSL_Types.Vector3();
  2632. }
  2633. public LSL_Types.list llListSort(LSL_Types.list src, int stride, int ascending)
  2634. {
  2635. m_host.AddScriptLPS(1);
  2636. return src.Sort(stride, ascending);
  2637. }
  2638. public LSL_Types.LSLInteger llGetListLength(LSL_Types.list src)
  2639. {
  2640. m_host.AddScriptLPS(1);
  2641. return src.Length;
  2642. }
  2643. public LSL_Types.LSLInteger llList2Integer(LSL_Types.list src, int index)
  2644. {
  2645. m_host.AddScriptLPS(1);
  2646. if (index < 0)
  2647. {
  2648. index = src.Length + index;
  2649. }
  2650. if (index >= src.Length)
  2651. {
  2652. return 0;
  2653. }
  2654. try
  2655. {
  2656. return Convert.ToInt32(src.Data[index]);
  2657. }
  2658. catch (FormatException)
  2659. {
  2660. return 0;
  2661. }
  2662. }
  2663. public double osList2Double(LSL_Types.list src, int index)
  2664. {
  2665. m_host.AddScriptLPS(1);
  2666. if (index < 0)
  2667. {
  2668. index = src.Length + index;
  2669. }
  2670. if (index >= src.Length)
  2671. {
  2672. return 0.0;
  2673. }
  2674. return Convert.ToDouble(src.Data[index]);
  2675. }
  2676. public double llList2Float(LSL_Types.list src, int index)
  2677. {
  2678. m_host.AddScriptLPS(1);
  2679. if (index < 0)
  2680. {
  2681. index = src.Length + index;
  2682. }
  2683. if (index >= src.Length)
  2684. {
  2685. return 0.0;
  2686. }
  2687. try
  2688. {
  2689. return Convert.ToDouble(src.Data[index]);
  2690. }
  2691. catch (FormatException)
  2692. {
  2693. return 0.0;
  2694. }
  2695. }
  2696. public string llList2String(LSL_Types.list src, int index)
  2697. {
  2698. m_host.AddScriptLPS(1);
  2699. if (index < 0)
  2700. {
  2701. index = src.Length + index;
  2702. }
  2703. if (index >= src.Length)
  2704. {
  2705. return String.Empty;
  2706. }
  2707. return src.Data[index].ToString();
  2708. }
  2709. public string llList2Key(LSL_Types.list src, int index)
  2710. {
  2711. m_host.AddScriptLPS(1);
  2712. if (index < 0)
  2713. {
  2714. index = src.Length + index;
  2715. }
  2716. if (index >= src.Length)
  2717. {
  2718. return "";
  2719. }
  2720. return src.Data[index].ToString();
  2721. }
  2722. public LSL_Types.Vector3 llList2Vector(LSL_Types.list src, int index)
  2723. {
  2724. m_host.AddScriptLPS(1);
  2725. if (index < 0)
  2726. {
  2727. index = src.Length + index;
  2728. }
  2729. if (index >= src.Length)
  2730. {
  2731. return new LSL_Types.Vector3(0, 0, 0);
  2732. }
  2733. if (src.Data[index].GetType() == typeof(LSL_Types.Vector3))
  2734. {
  2735. return (LSL_Types.Vector3)src.Data[index];
  2736. }
  2737. else
  2738. {
  2739. return new LSL_Types.Vector3(src.Data[index].ToString());
  2740. }
  2741. }
  2742. public LSL_Types.Quaternion llList2Rot(LSL_Types.list src, int index)
  2743. {
  2744. m_host.AddScriptLPS(1);
  2745. if (index < 0)
  2746. {
  2747. index = src.Length + index;
  2748. }
  2749. if (index >= src.Length)
  2750. {
  2751. return new LSL_Types.Quaternion(0, 0, 0, 1);
  2752. }
  2753. if (src.Data[index].GetType() == typeof(LSL_Types.Quaternion))
  2754. {
  2755. return (LSL_Types.Quaternion)src.Data[index];
  2756. }
  2757. else
  2758. {
  2759. return new LSL_Types.Quaternion(src.Data[index].ToString());
  2760. }
  2761. }
  2762. public LSL_Types.list llList2List(LSL_Types.list src, int start, int end)
  2763. {
  2764. m_host.AddScriptLPS(1);
  2765. return src.GetSublist(start, end);
  2766. }
  2767. public LSL_Types.list llDeleteSubList(LSL_Types.list src, int start, int end)
  2768. {
  2769. return src.DeleteSublist(end, start);
  2770. }
  2771. public LSL_Types.LSLInteger llGetListEntryType(LSL_Types.list src, int index)
  2772. {
  2773. m_host.AddScriptLPS(1);
  2774. if (index < 0)
  2775. {
  2776. index = src.Length + index;
  2777. }
  2778. if (index >= src.Length)
  2779. {
  2780. return 0;
  2781. }
  2782. if (src.Data[index] is Int32)
  2783. return 1;
  2784. if (src.Data[index] is Double)
  2785. return 2;
  2786. if (src.Data[index] is String)
  2787. {
  2788. LLUUID tuuid;
  2789. if (LLUUID.TryParse(src.Data[index].ToString(), out tuuid))
  2790. {
  2791. return 3;
  2792. }
  2793. else
  2794. {
  2795. return 4;
  2796. }
  2797. }
  2798. if (src.Data[index] is LSL_Types.Vector3)
  2799. return 5;
  2800. if (src.Data[index] is LSL_Types.Quaternion)
  2801. return 6;
  2802. if (src.Data[index] is LSL_Types.list)
  2803. return 7;
  2804. return 0;
  2805. }
  2806. /// <summary>
  2807. /// Process the supplied list and return the
  2808. /// content of the list formatted as a comma
  2809. /// separated list. There is a space after
  2810. /// each comma.
  2811. /// </summary>
  2812. public string llList2CSV(LSL_Types.list src)
  2813. {
  2814. string ret = String.Empty;
  2815. int x = 0;
  2816. m_host.AddScriptLPS(1);
  2817. if (src.Data.Length > 0)
  2818. {
  2819. ret = src.Data[x++].ToString();
  2820. for (; x < src.Data.Length; x++)
  2821. {
  2822. ret += ", "+src.Data[x].ToString();
  2823. }
  2824. }
  2825. return ret;
  2826. }
  2827. /// <summary>
  2828. /// The supplied string is scanned for commas
  2829. /// and converted into a list. Commas are only
  2830. /// effective if they are encountered outside
  2831. /// of '<' '>' delimiters. Any whitespace
  2832. /// before or after an element is trimmed.
  2833. /// </summary>
  2834. public LSL_Types.list llCSV2List(string src)
  2835. {
  2836. LSL_Types.list result = new LSL_Types.list();
  2837. int parens = 0;
  2838. int start = 0;
  2839. int length = 0;
  2840. m_host.AddScriptLPS(1);
  2841. for (int i = 0; i < src.Length; i++)
  2842. {
  2843. switch (src[i])
  2844. {
  2845. case '<' :
  2846. parens++;
  2847. length++;
  2848. break;
  2849. case '>' :
  2850. if (parens > 0)
  2851. parens--;
  2852. length++;
  2853. break;
  2854. case ',' :
  2855. if (parens == 0)
  2856. {
  2857. result.Add(src.Substring(start,length).Trim());
  2858. start += length+1;
  2859. length = 0;
  2860. }
  2861. else
  2862. {
  2863. length++;
  2864. }
  2865. break;
  2866. default :
  2867. length++;
  2868. break;
  2869. }
  2870. }
  2871. result.Add(src.Substring(start,length).Trim());
  2872. return result;
  2873. }
  2874. /// <summary>
  2875. /// Randomizes the list, be arbitrarily reordering
  2876. /// sublists of stride elements. As the stride approaches
  2877. /// the size of the list, the options become very
  2878. /// limited.
  2879. /// </summary>
  2880. /// <remarks>
  2881. /// This could take a while for very large list
  2882. /// sizes.
  2883. /// </remarks>
  2884. public LSL_Types.list llListRandomize(LSL_Types.list src, int stride)
  2885. {
  2886. LSL_Types.list result;
  2887. Random rand = new Random();
  2888. int chunkk;
  2889. int[] chunks;
  2890. int index1;
  2891. int index2;
  2892. int tmp;
  2893. m_host.AddScriptLPS(1);
  2894. if (stride == 0)
  2895. stride = 1;
  2896. // Stride MUST be a factor of the list length
  2897. // If not, then return the src list. This also
  2898. // traps those cases where stride > length.
  2899. if (src.Length != stride && src.Length%stride == 0)
  2900. {
  2901. chunkk = src.Length/stride;
  2902. chunks = new int[chunkk];
  2903. for (int i = 0; i < chunkk; i++)
  2904. chunks[i] = i;
  2905. for (int i = 0; i < chunkk - 1; i++)
  2906. {
  2907. // randomly select 2 chunks
  2908. index1 = rand.Next(rand.Next(65536));
  2909. index1 = index1%chunkk;
  2910. index2 = rand.Next(rand.Next(65536));
  2911. index2 = index2%chunkk;
  2912. // and swap their relative positions
  2913. tmp = chunks[index1];
  2914. chunks[index1] = chunks[index2];
  2915. chunks[index2] = tmp;
  2916. }
  2917. // Construct the randomized list
  2918. result = new LSL_Types.list();
  2919. for (int i = 0; i < chunkk; i++)
  2920. {
  2921. for (int j = 0; j < stride; j++)
  2922. {
  2923. result.Add(src.Data[chunks[i]*stride+j]);
  2924. }
  2925. }
  2926. }
  2927. else {
  2928. object[] array = new object[src.Length];
  2929. Array.Copy(src.Data, 0, array, 0, src.Length);
  2930. result = new LSL_Types.list(array);
  2931. }
  2932. return result;
  2933. }
  2934. /// <summary>
  2935. /// Elements in the source list starting with 0 and then
  2936. /// every i+stride. If the stride is negative then the scan
  2937. /// is backwards producing an inverted result.
  2938. /// Only those elements that are also in the specified
  2939. /// range are included in the result.
  2940. /// </summary>
  2941. public LSL_Types.list llList2ListStrided(LSL_Types.list src, int start, int end, int stride)
  2942. {
  2943. LSL_Types.list result = new LSL_Types.list();
  2944. int[] si = new int[2];
  2945. int[] ei = new int[2];
  2946. bool twopass = false;
  2947. m_host.AddScriptLPS(1);
  2948. // First step is always to deal with negative indices
  2949. if (start < 0)
  2950. start = src.Length+start;
  2951. if (end < 0)
  2952. end = src.Length+end;
  2953. // Out of bounds indices are OK, just trim them
  2954. // accordingly
  2955. if (start > src.Length)
  2956. start = src.Length;
  2957. if (end > src.Length)
  2958. end = src.Length;
  2959. // There may be one or two ranges to be considered
  2960. if (start != end)
  2961. {
  2962. if (start <= end)
  2963. {
  2964. si[0] = start;
  2965. ei[0] = end;
  2966. }
  2967. else
  2968. {
  2969. si[1] = start;
  2970. ei[1] = src.Length;
  2971. si[0] = 0;
  2972. ei[0] = end;
  2973. twopass = true;
  2974. }
  2975. // The scan always starts from the beginning of the
  2976. // source list, but members are only selected if they
  2977. // fall within the specified sub-range. The specified
  2978. // range values are inclusive.
  2979. // A negative stride reverses the direction of the
  2980. // scan producing an inverted list as a result.
  2981. if (stride == 0)
  2982. stride = 1;
  2983. if (stride > 0)
  2984. {
  2985. for (int i = 0; i < src.Length; i += stride)
  2986. {
  2987. if (i<=ei[0] && i>=si[0])
  2988. result.Add(src.Data[i]);
  2989. if (twopass && i>=si[1] && i<=ei[1])
  2990. result.Add(src.Data[i]);
  2991. }
  2992. }
  2993. else if (stride < 0)
  2994. {
  2995. for (int i = src.Length - 1; i >= 0; i += stride)
  2996. {
  2997. if (i <= ei[0] && i >= si[0])
  2998. result.Add(src.Data[i]);
  2999. if (twopass && i >= si[1] && i <= ei[1])
  3000. result.Add(src.Data[i]);
  3001. }
  3002. }
  3003. }
  3004. return result;
  3005. }
  3006. public LSL_Types.Vector3 llGetRegionCorner()
  3007. {
  3008. m_host.AddScriptLPS(1);
  3009. return new LSL_Types.Vector3(World.RegionInfo.RegionLocX * Constants.RegionSize, World.RegionInfo.RegionLocY * Constants.RegionSize, 0);
  3010. }
  3011. /// <summary>
  3012. /// Insert the list identified by <src> into the
  3013. /// list designated by <dest> such that the first
  3014. /// new element has the index specified by <index>
  3015. /// </summary>
  3016. public LSL_Types.list llListInsertList(LSL_Types.list dest, LSL_Types.list src, int index)
  3017. {
  3018. LSL_Types.list pref = null;
  3019. LSL_Types.list suff = null;
  3020. m_host.AddScriptLPS(1);
  3021. if (index < 0)
  3022. {
  3023. index = index+dest.Length;
  3024. if (index < 0)
  3025. {
  3026. index = 0;
  3027. }
  3028. }
  3029. if (index != 0)
  3030. {
  3031. pref = dest.GetSublist(0,index-1);
  3032. if (index < dest.Length)
  3033. {
  3034. suff = dest.GetSublist(index,-1);
  3035. return pref + src + suff;
  3036. }
  3037. else
  3038. {
  3039. return pref + src;
  3040. }
  3041. }
  3042. else
  3043. {
  3044. if (index < dest.Length)
  3045. {
  3046. suff = dest.GetSublist(index,-1);
  3047. return src + suff;
  3048. }
  3049. else
  3050. {
  3051. return src;
  3052. }
  3053. }
  3054. }
  3055. /// <summary>
  3056. /// Returns the index of the first occurrence of test
  3057. /// in src.
  3058. /// </summary>
  3059. public LSL_Types.LSLInteger llListFindList(LSL_Types.list src, LSL_Types.list test)
  3060. {
  3061. int index = -1;
  3062. int length = src.Length - test.Length + 1;
  3063. m_host.AddScriptLPS(1);
  3064. // If either list is empty, do not match
  3065. if (src.Length != 0 && test.Length != 0)
  3066. {
  3067. for (int i = 0; i < length; i++)
  3068. {
  3069. if (src.Data[i].Equals(test.Data[0]))
  3070. {
  3071. int j;
  3072. for (j = 1; j < test.Length; j++)
  3073. if (!src.Data[i+j].Equals(test.Data[j]))
  3074. break;
  3075. if (j == test.Length)
  3076. {
  3077. index = i;
  3078. break;
  3079. }
  3080. }
  3081. }
  3082. }
  3083. return index;
  3084. }
  3085. public string llGetObjectName()
  3086. {
  3087. m_host.AddScriptLPS(1);
  3088. return m_host.Name!=null?m_host.Name:String.Empty;
  3089. }
  3090. public void llSetObjectName(string name)
  3091. {
  3092. m_host.AddScriptLPS(1);
  3093. m_host.Name = name!=null?name:String.Empty;
  3094. }
  3095. public string llGetDate()
  3096. {
  3097. m_host.AddScriptLPS(1);
  3098. DateTime date = DateTime.Now.ToUniversalTime();
  3099. string result = date.ToString("yyyy-MM-dd");
  3100. return result;
  3101. }
  3102. public LSL_Types.LSLInteger llEdgeOfWorld(LSL_Types.Vector3 pos, LSL_Types.Vector3 dir)
  3103. {
  3104. m_host.AddScriptLPS(1);
  3105. NotImplemented("llEdgeOfWorld");
  3106. return 0;
  3107. }
  3108. public LSL_Types.LSLInteger llGetAgentInfo(string id)
  3109. {
  3110. m_host.AddScriptLPS(1);
  3111. NotImplemented("llGetAgentInfo");
  3112. return 0;
  3113. }
  3114. public void llAdjustSoundVolume(double volume)
  3115. {
  3116. m_host.AddScriptLPS(1);
  3117. m_host.AdjustSoundGain(volume);
  3118. }
  3119. public void llSetSoundQueueing(int queue)
  3120. {
  3121. m_host.AddScriptLPS(1);
  3122. NotImplemented("llSetSoundQueueing");
  3123. }
  3124. public void llSetSoundRadius(double radius)
  3125. {
  3126. m_host.AddScriptLPS(1);
  3127. NotImplemented("llSetSoundRadius");
  3128. }
  3129. public string llKey2Name(string id)
  3130. {
  3131. m_host.AddScriptLPS(1);
  3132. LLUUID key = new LLUUID();
  3133. if (LLUUID.TryParse(id,out key))
  3134. {
  3135. ScenePresence presence = World.GetScenePresence(key);
  3136. if (presence != null)
  3137. {
  3138. return presence.Name;
  3139. }
  3140. if (World.GetSceneObjectPart(key) != null)
  3141. {
  3142. return World.GetSceneObjectPart(key).Name;
  3143. }
  3144. }
  3145. return String.Empty;
  3146. }
  3147. public void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate)
  3148. {
  3149. m_host.AddScriptLPS(1);
  3150. Primitive.TextureAnimation pTexAnim = new Primitive.TextureAnimation();
  3151. pTexAnim.Flags =(uint) mode;
  3152. //ALL_SIDES
  3153. if (face == -1)
  3154. face = 255;
  3155. pTexAnim.Face = (uint)face;
  3156. pTexAnim.Length = (float)length;
  3157. pTexAnim.Rate = (float)rate;
  3158. pTexAnim.SizeX = (uint)sizex;
  3159. pTexAnim.SizeY = (uint)sizey;
  3160. pTexAnim.Start = (float)start;
  3161. m_host.AddTextureAnimation(pTexAnim);
  3162. m_host.SendFullUpdateToAllClients();
  3163. }
  3164. public void llTriggerSoundLimited(string sound, double volume, LSL_Types.Vector3 top_north_east,
  3165. LSL_Types.Vector3 bottom_south_west)
  3166. {
  3167. m_host.AddScriptLPS(1);
  3168. NotImplemented("llTriggerSoundLimited");
  3169. }
  3170. public void llEjectFromLand(string pest)
  3171. {
  3172. m_host.AddScriptLPS(1);
  3173. NotImplemented("llEjectFromLand");
  3174. }
  3175. public LSL_Types.list llParseString2List(string str, LSL_Types.list separators, LSL_Types.list spacers)
  3176. {
  3177. m_host.AddScriptLPS(1);
  3178. LSL_Types.list ret = new LSL_Types.list();
  3179. object[] delimiters = new object[separators.Length + spacers.Length];
  3180. separators.Data.CopyTo(delimiters, 0);
  3181. spacers.Data.CopyTo(delimiters, separators.Length);
  3182. bool dfound = false;
  3183. do
  3184. {
  3185. dfound = false;
  3186. int cindex = -1;
  3187. string cdeli = "";
  3188. for (int i = 0; i < delimiters.Length; i++)
  3189. {
  3190. int index = str.IndexOf(delimiters[i].ToString());
  3191. bool found = index != -1;
  3192. if (found)
  3193. {
  3194. if ((cindex > index) || (cindex == -1))
  3195. {
  3196. cindex = index;
  3197. cdeli = (string)delimiters[i];
  3198. }
  3199. dfound = dfound || found;
  3200. }
  3201. }
  3202. if (cindex != -1)
  3203. {
  3204. if (cindex > 0)
  3205. {
  3206. ret.Add(str.Substring(0, cindex));
  3207. if (spacers.Contains(cdeli))
  3208. {
  3209. ret.Add(cdeli);
  3210. }
  3211. }
  3212. if (cindex == 0 && spacers.Contains(cdeli))
  3213. {
  3214. ret.Add(cdeli);
  3215. }
  3216. str = str.Substring(cindex + cdeli.Length);
  3217. }
  3218. } while (dfound);
  3219. if (str != "")
  3220. {
  3221. ret.Add(str);
  3222. }
  3223. return ret;
  3224. }
  3225. public LSL_Types.LSLInteger llOverMyLand(string id)
  3226. {
  3227. m_host.AddScriptLPS(1);
  3228. LLUUID key = new LLUUID();
  3229. if (LLUUID.TryParse(id,out key))
  3230. {
  3231. SceneObjectPart obj = new SceneObjectPart();
  3232. obj = World.GetSceneObjectPart(World.Entities[key].LocalId);
  3233. if (obj.OwnerID == World.GetLandOwner(obj.AbsolutePosition.X, obj.AbsolutePosition.Y))
  3234. {
  3235. return 1;
  3236. }
  3237. else
  3238. {
  3239. return 0;
  3240. }
  3241. }
  3242. else
  3243. {
  3244. return 0;
  3245. }
  3246. }
  3247. public string llGetLandOwnerAt(LSL_Types.Vector3 pos)
  3248. {
  3249. m_host.AddScriptLPS(1);
  3250. return World.GetLandOwner((float)pos.x, (float)pos.y).ToString();
  3251. }
  3252. public string llGetNotecardLine(string name, int line)
  3253. {
  3254. m_host.AddScriptLPS(1);
  3255. // TODO: this script function should actually return
  3256. // the requested notecard line via the dataserver event
  3257. // once it is implemented - krtaylor
  3258. String[] notecardLines = GetNotecardLines(name);
  3259. line--; // array starts at 0
  3260. if ((!String.IsNullOrEmpty(notecardLines[0])) &&
  3261. (line >= 0) &&
  3262. (line < notecardLines.Length))
  3263. {
  3264. return notecardLines[line];
  3265. }
  3266. else
  3267. {
  3268. return String.Empty;
  3269. }
  3270. }
  3271. private String[] GetNotecardLines(string name)
  3272. {
  3273. bool found = false;
  3274. int notecardIndex = 0;
  3275. String[] notecardLines = { "0" };
  3276. notecardLines[0] = String.Empty;
  3277. foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
  3278. {
  3279. if ((inv.Value.Name == name) && (inv.Value.InvType == (int)InventoryType.Notecard))
  3280. {
  3281. // OK, it has the right name and it is a notecard
  3282. // so get the asset that contains the notecard raw data
  3283. // and convert it into a string
  3284. AssetBase notecardAsset = World.AssetCache.GetAsset(inv.Value.AssetID, false);
  3285. String dataString = System.Text.Encoding.ASCII.GetString(notecardAsset.Data);
  3286. if (!String.IsNullOrEmpty(dataString))
  3287. {
  3288. // good, we have the notecard data as a string
  3289. // now parse the text lines using the Linden Text delimiters
  3290. notecardIndex = dataString.IndexOf("}\nText length ");
  3291. if (notecardIndex > 0)
  3292. {
  3293. notecardIndex = notecardIndex + 2; //get past delimiter
  3294. notecardIndex = dataString.IndexOf("\n", notecardIndex);
  3295. if (notecardIndex > 0)
  3296. {
  3297. // Finally got to the first line of the notecard
  3298. // now find the end of the notecard text delimited by }<LF>
  3299. // parse the lines, delimited by <LF>
  3300. notecardIndex = dataString.IndexOf("\n", notecardIndex);
  3301. notecardIndex++; // get past delimiter
  3302. int notecardLength = dataString.Length - notecardIndex - 3;
  3303. // create new string to parse that only consists of the actual lines in the asset
  3304. Char[] notecardCharArray = dataString.ToCharArray(notecardIndex, notecardLength);
  3305. String notecardString = new String(notecardCharArray);
  3306. // split the lines of the notecard into separate strings
  3307. char[] delimChar = { '\n' };
  3308. notecardLines = notecardString.Split(delimChar);
  3309. return notecardLines;
  3310. }
  3311. }
  3312. }
  3313. }
  3314. }
  3315. return notecardLines;
  3316. }
  3317. public LSL_Types.Vector3 llGetAgentSize(string id)
  3318. {
  3319. m_host.AddScriptLPS(1);
  3320. NotImplemented("llGetAgentSize");
  3321. return new LSL_Types.Vector3();
  3322. }
  3323. public LSL_Types.LSLInteger llSameGroup(string agent)
  3324. {
  3325. m_host.AddScriptLPS(1);
  3326. NotImplemented("llSameGroup");
  3327. return 0;
  3328. }
  3329. public void llUnSit(string id)
  3330. {
  3331. m_host.AddScriptLPS(1);
  3332. LLUUID key = new LLUUID();
  3333. if (LLUUID.TryParse(id, out key))
  3334. {
  3335. ScenePresence av = World.GetScenePresence(key);
  3336. if (av != null)
  3337. {
  3338. if (llAvatarOnSitTarget() == id)
  3339. {
  3340. // if the avatar is sitting on this object, then
  3341. // we can unsit them. We don't want random scripts unsitting random people
  3342. // Lets avoid the popcorn avatar scenario.
  3343. av.StandUp();
  3344. }
  3345. else
  3346. {
  3347. // If the object owner also owns the parcel
  3348. // or
  3349. // if the land is group owned and the object is group owned by the same group
  3350. // or
  3351. // if the object is owned by a person with estate access.
  3352. ILandObject parcel = World.LandChannel.GetLandObject(av.AbsolutePosition.X, av.AbsolutePosition.Y);
  3353. if (parcel != null)
  3354. {
  3355. if (m_host.ObjectOwner == parcel.landData.ownerID ||
  3356. (m_host.OwnerID == m_host.GroupID && m_host.GroupID == parcel.landData.groupID
  3357. && parcel.landData.isGroupOwned) || World.ExternalChecks.ExternalChecksCanBeGodLike(m_host.OwnerID))
  3358. {
  3359. av.StandUp();
  3360. }
  3361. }
  3362. }
  3363. }
  3364. }
  3365. }
  3366. public LSL_Types.Vector3 llGroundSlope(LSL_Types.Vector3 offset)
  3367. {
  3368. m_host.AddScriptLPS(1);
  3369. NotImplemented("llGroundSlope");
  3370. return new LSL_Types.Vector3();
  3371. }
  3372. public LSL_Types.Vector3 llGroundNormal(LSL_Types.Vector3 offset)
  3373. {
  3374. m_host.AddScriptLPS(1);
  3375. NotImplemented("llGroundNormal");
  3376. return new LSL_Types.Vector3();
  3377. }
  3378. public LSL_Types.Vector3 llGroundContour(LSL_Types.Vector3 offset)
  3379. {
  3380. m_host.AddScriptLPS(1);
  3381. NotImplemented("llGroundContour");
  3382. return new LSL_Types.Vector3();
  3383. }
  3384. public LSL_Types.LSLInteger llGetAttached()
  3385. {
  3386. m_host.AddScriptLPS(1);
  3387. NotImplemented("llGetAttached");
  3388. return 0;
  3389. }
  3390. public LSL_Types.LSLInteger llGetFreeMemory()
  3391. {
  3392. m_host.AddScriptLPS(1);
  3393. NotImplemented("llGetFreeMemory");
  3394. return 0;
  3395. }
  3396. public string llGetRegionName()
  3397. {
  3398. m_host.AddScriptLPS(1);
  3399. return World.RegionInfo.RegionName;
  3400. }
  3401. public double llGetRegionTimeDilation()
  3402. {
  3403. m_host.AddScriptLPS(1);
  3404. return (double)World.TimeDilation;
  3405. }
  3406. public double llGetRegionFPS()
  3407. {
  3408. m_host.AddScriptLPS(1);
  3409. //TODO: return actual FPS
  3410. return 10.0f;
  3411. }
  3412. /* particle system rules should be coming into this routine as doubles, that is
  3413. rule[0] should be an integer from this list and rule[1] should be the arg
  3414. for the same integer. wiki.secondlife.com has most of this mapping, but some
  3415. came from http://www.caligari-designs.com/p4u2
  3416. We iterate through the list for 'Count' elements, incrementing by two for each
  3417. iteration and set the members of Primitive.ParticleSystem, one at a time.
  3418. */
  3419. public enum PrimitiveRule : int
  3420. {
  3421. PSYS_PART_FLAGS = 0,
  3422. PSYS_PART_START_COLOR = 1,
  3423. PSYS_PART_START_ALPHA = 2,
  3424. PSYS_PART_END_COLOR = 3,
  3425. PSYS_PART_END_ALPHA = 4,
  3426. PSYS_PART_START_SCALE = 5,
  3427. PSYS_PART_END_SCALE = 6,
  3428. PSYS_PART_MAX_AGE = 7,
  3429. PSYS_SRC_ACCEL = 8,
  3430. PSYS_SRC_PATTERN = 9,
  3431. PSYS_SRC_TEXTURE = 12,
  3432. PSYS_SRC_BURST_RATE = 13,
  3433. PSYS_SRC_BURST_PART_COUNT = 15,
  3434. PSYS_SRC_BURST_RADIUS = 16,
  3435. PSYS_SRC_BURST_SPEED_MIN = 17,
  3436. PSYS_SRC_BURST_SPEED_MAX = 18,
  3437. PSYS_SRC_MAX_AGE = 19,
  3438. PSYS_SRC_TARGET_KEY = 20,
  3439. PSYS_SRC_OMEGA = 21,
  3440. PSYS_SRC_ANGLE_BEGIN = 22,
  3441. PSYS_SRC_ANGLE_END = 23
  3442. }
  3443. internal Primitive.ParticleSystem.ParticleDataFlags ConvertUINTtoFlags(uint flags)
  3444. {
  3445. Primitive.ParticleSystem.ParticleDataFlags returnval = Primitive.ParticleSystem.ParticleDataFlags.None;
  3446. return returnval;
  3447. }
  3448. public void llParticleSystem(LSL_Types.list rules)
  3449. {
  3450. m_host.AddScriptLPS(1);
  3451. Primitive.ParticleSystem prules = new Primitive.ParticleSystem();
  3452. LSL_Types.Vector3 tempv = new LSL_Types.Vector3();
  3453. float tempf = 0;
  3454. for (int i = 0; i < rules.Length; i += 2)
  3455. {
  3456. switch ((int)rules.Data[i])
  3457. {
  3458. case (int)BuiltIn_Commands_BaseClass.PSYS_PART_FLAGS:
  3459. prules.PartDataFlags = (Primitive.ParticleSystem.ParticleDataFlags)((uint)Convert.ToInt32(rules.Data[i + 1].ToString()));
  3460. break;
  3461. case (int)BuiltIn_Commands_BaseClass.PSYS_PART_START_COLOR:
  3462. tempv = (LSL_Types.Vector3)rules.Data[i + 1];
  3463. prules.PartStartColor.R = (float)tempv.x;
  3464. prules.PartStartColor.G = (float)tempv.y;
  3465. prules.PartStartColor.B = (float)tempv.z;
  3466. break;
  3467. case (int)BuiltIn_Commands_BaseClass.PSYS_PART_START_ALPHA:
  3468. tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
  3469. prules.PartStartColor.A = (float)tempf;
  3470. break;
  3471. case (int)BuiltIn_Commands_BaseClass.PSYS_PART_END_COLOR:
  3472. tempv = (LSL_Types.Vector3)rules.Data[i + 1];
  3473. //prules.PartEndColor = new LLColor(tempv.x,tempv.y,tempv.z,1);
  3474. prules.PartEndColor.R = (float)tempv.x;
  3475. prules.PartEndColor.G = (float)tempv.y;
  3476. prules.PartEndColor.B = (float)tempv.z;
  3477. break;
  3478. case (int)BuiltIn_Commands_BaseClass.PSYS_PART_END_ALPHA:
  3479. tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
  3480. prules.PartEndColor.A = (float)tempf;
  3481. break;
  3482. case (int)BuiltIn_Commands_BaseClass.PSYS_PART_START_SCALE:
  3483. tempv = (LSL_Types.Vector3)rules.Data[i + 1];
  3484. prules.PartStartScaleX = (float)tempv.x;
  3485. prules.PartStartScaleY = (float)tempv.y;
  3486. break;
  3487. case (int)BuiltIn_Commands_BaseClass.PSYS_PART_END_SCALE:
  3488. tempv = (LSL_Types.Vector3)rules.Data[i + 1];
  3489. prules.PartEndScaleX = (float)tempv.x;
  3490. prules.PartEndScaleY = (float)tempv.y;
  3491. break;
  3492. case (int)BuiltIn_Commands_BaseClass.PSYS_PART_MAX_AGE:
  3493. tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
  3494. prules.PartMaxAge = (float)tempf;
  3495. break;
  3496. case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_ACCEL:
  3497. tempv = (LSL_Types.Vector3)rules.Data[i + 1];
  3498. prules.PartAcceleration.X = (float)tempv.x;
  3499. prules.PartAcceleration.Y = (float)tempv.y;
  3500. prules.PartAcceleration.Z = (float)tempv.z;
  3501. break;
  3502. case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_PATTERN:
  3503. int tmpi = int.Parse(rules.Data[i + 1].ToString());
  3504. prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi;
  3505. break;
  3506. // Xantor 03-May-2008
  3507. // Wiki: PSYS_SRC_TEXTURE string inventory item name or key of the particle texture
  3508. // "" = default texture.
  3509. case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_TEXTURE:
  3510. LLUUID tkey = LLUUID.Zero;
  3511. // if we can parse the string as a key, use it.
  3512. if (LLUUID.TryParse(rules.Data[i + 1].ToString(), out tkey))
  3513. {
  3514. prules.Texture = tkey;
  3515. }
  3516. // else try to locate the name in inventory of object. found returns key,
  3517. // not found returns LLUUID.Zero which will translate to the default particle texture
  3518. else
  3519. {
  3520. prules.Texture = InventoryKey(rules.Data[i+1].ToString());
  3521. }
  3522. break;
  3523. case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_BURST_RATE:
  3524. tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
  3525. prules.BurstRate = (float)tempf;
  3526. break;
  3527. case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_BURST_PART_COUNT:
  3528. prules.BurstPartCount = (byte)Convert.ToByte(rules.Data[i + 1].ToString());
  3529. break;
  3530. case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_BURST_RADIUS:
  3531. tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
  3532. prules.BurstRadius = (float)tempf;
  3533. break;
  3534. case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_BURST_SPEED_MIN:
  3535. tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
  3536. prules.BurstSpeedMin = (float)tempf;
  3537. break;
  3538. case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_BURST_SPEED_MAX:
  3539. tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
  3540. prules.BurstSpeedMax = (float)tempf;
  3541. break;
  3542. case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_MAX_AGE:
  3543. tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
  3544. prules.MaxAge = (float)tempf;
  3545. break;
  3546. case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_TARGET_KEY:
  3547. LLUUID key = LLUUID.Zero;
  3548. if (LLUUID.TryParse(rules.Data[i + 1].ToString(), out key))
  3549. {
  3550. prules.Target = key;
  3551. }
  3552. else
  3553. {
  3554. prules.Target = m_host.UUID;
  3555. }
  3556. break;
  3557. case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_OMEGA:
  3558. // AL: This is an assumption, since it is the only thing that would match.
  3559. tempv = (LSL_Types.Vector3)rules.Data[i + 1];
  3560. prules.AngularVelocity.X = (float)tempv.x;
  3561. prules.AngularVelocity.Y = (float)tempv.y;
  3562. prules.AngularVelocity.Z = (float)tempv.z;
  3563. //cast?? prules.MaxAge = (float)rules[i + 1];
  3564. break;
  3565. case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_ANGLE_BEGIN:
  3566. tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
  3567. prules.InnerAngle = (float)tempf;
  3568. break;
  3569. case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_ANGLE_END:
  3570. tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
  3571. prules.OuterAngle = (float)tempf;
  3572. break;
  3573. }
  3574. }
  3575. prules.CRC = 1;
  3576. m_host.AddNewParticleSystem(prules);
  3577. m_host.SendFullUpdateToAllClients();
  3578. }
  3579. public void llGroundRepel(double height, int water, double tau)
  3580. {
  3581. m_host.AddScriptLPS(1);
  3582. NotImplemented("llGroundRepel");
  3583. }
  3584. public void llGiveInventoryList(string destination, string category, LSL_Types.list inventory)
  3585. {
  3586. m_host.AddScriptLPS(1);
  3587. NotImplemented("llGiveInventoryList");
  3588. }
  3589. public void llSetVehicleType(int type)
  3590. {
  3591. m_host.AddScriptLPS(1);
  3592. NotImplemented("llSetVehicleType");
  3593. }
  3594. public void llSetVehicledoubleParam(int param, double value)
  3595. {
  3596. m_host.AddScriptLPS(1);
  3597. NotImplemented("llSetVehicledoubleParam");
  3598. }
  3599. public void llSetVehicleFloatParam(int param, float value)
  3600. {
  3601. m_host.AddScriptLPS(1);
  3602. NotImplemented("llSetVehicleFloatParam");
  3603. }
  3604. public void llSetVehicleVectorParam(int param, LSL_Types.Vector3 vec)
  3605. {
  3606. m_host.AddScriptLPS(1);
  3607. NotImplemented("llSetVehicleVectorParam");
  3608. }
  3609. public void llSetVehicleRotationParam(int param, LSL_Types.Quaternion rot)
  3610. {
  3611. m_host.AddScriptLPS(1);
  3612. NotImplemented("llSetVehicleRotationParam");
  3613. }
  3614. public void llSetVehicleFlags(int flags)
  3615. {
  3616. m_host.AddScriptLPS(1);
  3617. NotImplemented("llSetVehicleFlags");
  3618. }
  3619. public void llRemoveVehicleFlags(int flags)
  3620. {
  3621. m_host.AddScriptLPS(1);
  3622. NotImplemented("llRemoveVehicleFlags");
  3623. }
  3624. public void llSitTarget(LSL_Types.Vector3 offset, LSL_Types.Quaternion rot)
  3625. {
  3626. m_host.AddScriptLPS(1);
  3627. // LSL quaternions can normalize to 0, normal Quaternions can't.
  3628. if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0)
  3629. rot.z = 1; // ZERO_ROTATION = 0,0,0,1
  3630. m_host.SetSitTarget(new Vector3((float)offset.x, (float)offset.y, (float)offset.z), new Quaternion((float)rot.s, (float)rot.x, (float)rot.y, (float)rot.z));
  3631. }
  3632. public string llAvatarOnSitTarget()
  3633. {
  3634. m_host.AddScriptLPS(1);
  3635. return m_host.GetAvatarOnSitTarget().ToString();
  3636. //LLUUID AVID = m_host.GetAvatarOnSitTarget();
  3637. //if (AVID != LLUUID.Zero)
  3638. // return AVID.ToString();
  3639. //else
  3640. // return String.Empty;
  3641. }
  3642. public void llAddToLandPassList(string avatar, double hours)
  3643. {
  3644. m_host.AddScriptLPS(1);
  3645. LLUUID key;
  3646. LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).landData;
  3647. if (land.ownerID == m_host.OwnerID)
  3648. {
  3649. ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
  3650. if (LLUUID.TryParse(avatar, out key))
  3651. {
  3652. entry.AgentID = key;
  3653. entry.Flags = ParcelManager.AccessList.Access;
  3654. entry.Time = DateTime.Now.AddHours(hours);
  3655. land.parcelAccessList.Add(entry);
  3656. }
  3657. }
  3658. }
  3659. public void llSetTouchText(string text)
  3660. {
  3661. m_host.AddScriptLPS(1);
  3662. m_host.TouchName = text;
  3663. }
  3664. public void llSetSitText(string text)
  3665. {
  3666. m_host.AddScriptLPS(1);
  3667. m_host.SitName = text;
  3668. }
  3669. public void llSetCameraEyeOffset(LSL_Types.Vector3 offset)
  3670. {
  3671. m_host.AddScriptLPS(1);
  3672. NotImplemented("llSetCameraEyeOffset");
  3673. }
  3674. public void llSetCameraAtOffset(LSL_Types.Vector3 offset)
  3675. {
  3676. m_host.AddScriptLPS(1);
  3677. NotImplemented("llSetCameraAtOffset");
  3678. }
  3679. public string llDumpList2String(LSL_Types.list src, string seperator)
  3680. {
  3681. m_host.AddScriptLPS(1);
  3682. if (src.Length == 0)
  3683. {
  3684. return String.Empty;
  3685. }
  3686. string ret = String.Empty;
  3687. foreach (object o in src.Data)
  3688. {
  3689. ret = ret + o.ToString() + seperator;
  3690. }
  3691. ret = ret.Substring(0, ret.Length - seperator.Length);
  3692. return ret;
  3693. }
  3694. public LSL_Types.LSLInteger llScriptDanger(LSL_Types.Vector3 pos)
  3695. {
  3696. m_host.AddScriptLPS(1);
  3697. bool result = World.scriptDanger(m_host.LocalId, new LLVector3((float)pos.x, (float)pos.y, (float)pos.z));
  3698. if (result)
  3699. {
  3700. return 1;
  3701. }
  3702. else
  3703. {
  3704. return 0;
  3705. }
  3706. }
  3707. public void llDialog(string avatar, string message, LSL_Types.list buttons, int chat_channel)
  3708. {
  3709. m_host.AddScriptLPS(1);
  3710. LLUUID av = new LLUUID();
  3711. if (!LLUUID.TryParse(avatar,out av))
  3712. {
  3713. LSLError("First parameter to llDialog needs to be a key");
  3714. return;
  3715. }
  3716. if (buttons.Length > 12)
  3717. {
  3718. LSLError("No more than 12 buttons can be shown");
  3719. return;
  3720. }
  3721. string[] buts = new string[buttons.Length];
  3722. for (int i = 0; i < buttons.Length; i++)
  3723. {
  3724. if (buttons.Data[i].ToString() == String.Empty)
  3725. {
  3726. LSLError("button label cannot be blank");
  3727. return;
  3728. }
  3729. if (buttons.Data[i].ToString().Length > 24)
  3730. {
  3731. LSLError("button label cannot be longer than 24 characters");
  3732. return;
  3733. }
  3734. buts[i] = buttons.Data[i].ToString();
  3735. }
  3736. World.SendDialogToUser(av, m_host.Name, m_host.UUID, m_host.OwnerID, message, new LLUUID("00000000-0000-2222-3333-100000001000"), chat_channel, buts);
  3737. }
  3738. public void llVolumeDetect(int detect)
  3739. {
  3740. m_host.AddScriptLPS(1);
  3741. NotImplemented("llVolumeDetect");
  3742. }
  3743. /// <summary>
  3744. /// Reset the named script. The script must be present
  3745. /// in the same prim.
  3746. /// </summary>
  3747. public void llResetOtherScript(string name)
  3748. {
  3749. LLUUID item;
  3750. ScriptManager sm;
  3751. IScript script = null;
  3752. m_host.AddScriptLPS(8000);
  3753. // These functions are supposed to be robust,
  3754. // so get the state one step at a time.
  3755. if ((item = ScriptByName(name)) != LLUUID.Zero)
  3756. if ((sm = m_ScriptEngine.m_ScriptManager) != null)
  3757. sm.ResetScript(m_localID, item);
  3758. // Required by SL
  3759. if (script == null)
  3760. ShoutError("llResetOtherScript: script "+name+" not found");
  3761. // If we didn't find it, then it's safe to
  3762. // assume it is not running.
  3763. }
  3764. public LSL_Types.LSLInteger llGetScriptState(string name)
  3765. {
  3766. LLUUID item;
  3767. ScriptManager sm;
  3768. IScript script = null;
  3769. m_host.AddScriptLPS(1);
  3770. // These functions are supposed to be robust,
  3771. // so get the state one step at a time.
  3772. if ((item = ScriptByName(name)) != LLUUID.Zero)
  3773. {
  3774. if ((sm = m_ScriptEngine.m_ScriptManager) != null)
  3775. {
  3776. if ((script = sm.GetScript(m_localID, item)) != null)
  3777. {
  3778. return script.Exec.Running?1:0;
  3779. }
  3780. }
  3781. }
  3782. // Required by SL
  3783. if (script == null)
  3784. ShoutError("llGetScriptState: script "+name+" not found");
  3785. // If we didn't find it, then it's safe to
  3786. // assume it is not running.
  3787. return 0;
  3788. }
  3789. public void llRemoteLoadScript()
  3790. {
  3791. m_host.AddScriptLPS(1);
  3792. Deprecated("llRemoteLoadScript");
  3793. }
  3794. public void llSetRemoteScriptAccessPin(int pin)
  3795. {
  3796. m_host.AddScriptLPS(1);
  3797. NotImplemented("llSetRemoteScriptAccessPin");
  3798. }
  3799. public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param)
  3800. {
  3801. m_host.AddScriptLPS(1);
  3802. NotImplemented("llRemoteLoadScriptPin");
  3803. }
  3804. // remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval)
  3805. // Not sure where these constants should live:
  3806. // REMOTE_DATA_CHANNEL = 1
  3807. // REMOTE_DATA_REQUEST = 2
  3808. // REMOTE_DATA_REPLY = 3
  3809. public void llOpenRemoteDataChannel()
  3810. {
  3811. m_host.AddScriptLPS(1);
  3812. IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
  3813. if (xmlrpcMod.IsEnabled())
  3814. {
  3815. LLUUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID, LLUUID.Zero);
  3816. object[] resobj = new object[] { new LSL_Types.LSLInteger(1), new LSL_Types.LSLString(channelID.ToString()), new LSL_Types.LSLString(LLUUID.Zero.ToString()), new LSL_Types.LSLString(String.Empty), new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(String.Empty) };
  3817. m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(m_localID, m_itemID, "remote_data", EventQueueManager.llDetectNull, resobj);
  3818. }
  3819. }
  3820. public string llSendRemoteData(string channel, string dest, int idata, string sdata)
  3821. {
  3822. m_host.AddScriptLPS(1);
  3823. IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
  3824. return (xmlrpcMod.SendRemoteData(m_localID, m_itemID, channel, dest, idata, sdata)).ToString();
  3825. }
  3826. public void llRemoteDataReply(string channel, string message_id, string sdata, int idata)
  3827. {
  3828. m_host.AddScriptLPS(1);
  3829. IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
  3830. xmlrpcMod.RemoteDataReply(channel, message_id, sdata, idata);
  3831. }
  3832. public void llCloseRemoteDataChannel(string channel)
  3833. {
  3834. m_host.AddScriptLPS(1);
  3835. IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
  3836. xmlrpcMod.CloseXMLRPCChannel(channel);
  3837. }
  3838. public string llMD5String(string src, int nonce)
  3839. {
  3840. m_host.AddScriptLPS(1);
  3841. return Util.Md5Hash(src + ":" + nonce.ToString());
  3842. }
  3843. public void llSetPrimitiveParams(LSL_Types.list rules)
  3844. {
  3845. llSetLinkPrimitiveParams(m_host.LinkNum+1, rules);
  3846. }
  3847. public void llSetLinkPrimitiveParams(int linknumber, LSL_Types.list rules)
  3848. {
  3849. m_host.AddScriptLPS(1);
  3850. SceneObjectPart part=null;
  3851. if (m_host.LinkNum+1 != linknumber)
  3852. {
  3853. foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts())
  3854. {
  3855. if ((partInst.LinkNum + 1) == linknumber)
  3856. {
  3857. part = partInst;
  3858. break;
  3859. }
  3860. }
  3861. }
  3862. else
  3863. {
  3864. part = m_host;
  3865. }
  3866. if (part == null)
  3867. return;
  3868. int idx = 0;
  3869. while (idx < rules.Length)
  3870. {
  3871. int code = Convert.ToInt32(rules.Data[idx++]);
  3872. int remain = rules.Length - idx;
  3873. int face;
  3874. LSL_Types.Vector3 v;
  3875. switch (code)
  3876. {
  3877. case 6: // PRIM_POSITION
  3878. if (remain < 1)
  3879. return;
  3880. v=new LSL_Types.Vector3(rules.Data[idx++].ToString());
  3881. SetPos(part, v);
  3882. break;
  3883. case 8: // PRIM_ROTATION
  3884. if (remain < 1)
  3885. return;
  3886. LSL_Types.Quaternion q = new LSL_Types.Quaternion(rules.Data[idx++].ToString());
  3887. SetRot(part, q);
  3888. break;
  3889. case 17: // PRIM_TEXTURE
  3890. if (remain < 5)
  3891. return;
  3892. face=Convert.ToInt32(rules.Data[idx++]);
  3893. string tex=rules.Data[idx++].ToString();
  3894. LSL_Types.Vector3 repeats=new LSL_Types.Vector3(rules.Data[idx++].ToString());
  3895. LSL_Types.Vector3 offsets=new LSL_Types.Vector3(rules.Data[idx++].ToString());
  3896. double rotation=Convert.ToDouble(rules.Data[idx++]);
  3897. SetTexture(part, tex, face);
  3898. ScaleTexture(part, repeats.x, repeats.y, face);
  3899. OffsetTexture(part, offsets.x, offsets.y, face);
  3900. RotateTexture(part, rotation, face);
  3901. break;
  3902. case 18: // PRIM_COLOR
  3903. if (remain < 3)
  3904. return;
  3905. face=Convert.ToInt32(rules.Data[idx++]);
  3906. LSL_Types.Vector3 color=new LSL_Types.Vector3(rules.Data[idx++].ToString());
  3907. double alpha=Convert.ToDouble(rules.Data[idx++]);
  3908. SetColor(part, color, face);
  3909. SetAlpha(part, alpha, face);
  3910. break;
  3911. case 7: // PRIM_SIZE
  3912. if (remain < 1)
  3913. return;
  3914. v=new LSL_Types.Vector3(rules.Data[idx++].ToString());
  3915. SetScale(part, v);
  3916. break;
  3917. }
  3918. }
  3919. }
  3920. public string llStringToBase64(string str)
  3921. {
  3922. m_host.AddScriptLPS(1);
  3923. try
  3924. {
  3925. byte[] encData_byte = new byte[str.Length];
  3926. encData_byte = Encoding.UTF8.GetBytes(str);
  3927. string encodedData = Convert.ToBase64String(encData_byte);
  3928. return encodedData;
  3929. }
  3930. catch (Exception e)
  3931. {
  3932. throw new Exception("Error in base64Encode" + e.Message);
  3933. }
  3934. }
  3935. public string llBase64ToString(string str)
  3936. {
  3937. m_host.AddScriptLPS(1);
  3938. UTF8Encoding encoder = new UTF8Encoding();
  3939. Decoder utf8Decode = encoder.GetDecoder();
  3940. try
  3941. {
  3942. byte[] todecode_byte = Convert.FromBase64String(str);
  3943. int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
  3944. char[] decoded_char = new char[charCount];
  3945. utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
  3946. string result = new String(decoded_char);
  3947. return result;
  3948. }
  3949. catch (Exception e)
  3950. {
  3951. throw new Exception("Error in base64Decode" + e.Message);
  3952. }
  3953. }
  3954. public void llXorBase64Strings()
  3955. {
  3956. m_host.AddScriptLPS(1);
  3957. Deprecated("llXorBase64Strings");
  3958. }
  3959. public void llRemoteDataSetRegion()
  3960. {
  3961. m_host.AddScriptLPS(1);
  3962. NotImplemented("llRemoteDataSetRegion");
  3963. }
  3964. public double llLog10(double val)
  3965. {
  3966. m_host.AddScriptLPS(1);
  3967. return (double)Math.Log10(val);
  3968. }
  3969. public double llLog(double val)
  3970. {
  3971. m_host.AddScriptLPS(1);
  3972. return (double)Math.Log(val);
  3973. }
  3974. public LSL_Types.list llGetAnimationList(string id)
  3975. {
  3976. m_host.AddScriptLPS(1);
  3977. NotImplemented("llGetAnimationList");
  3978. return new LSL_Types.list();
  3979. }
  3980. public void llSetParcelMusicURL(string url)
  3981. {
  3982. m_host.AddScriptLPS(1);
  3983. LLUUID landowner = World.GetLandOwner(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
  3984. if (landowner == LLUUID.Zero)
  3985. {
  3986. return;
  3987. }
  3988. if (landowner != m_host.ObjectOwner)
  3989. {
  3990. return;
  3991. }
  3992. World.SetLandMusicURL(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, url);
  3993. }
  3994. public void osSetParcelMediaURL(string url)
  3995. {
  3996. m_host.AddScriptLPS(1);
  3997. LLUUID landowner = World.GetLandOwner(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
  3998. if (landowner == LLUUID.Zero)
  3999. {
  4000. return;
  4001. }
  4002. if (landowner != m_host.ObjectOwner)
  4003. {
  4004. return;
  4005. }
  4006. World.SetLandMediaURL(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, url);
  4007. }
  4008. public LSL_Types.Vector3 llGetRootPosition()
  4009. {
  4010. m_host.AddScriptLPS(1);
  4011. return new LSL_Types.Vector3(m_host.ParentGroup.AbsolutePosition.X, m_host.ParentGroup.AbsolutePosition.Y, m_host.ParentGroup.AbsolutePosition.Z);
  4012. }
  4013. public LSL_Types.Quaternion llGetRootRotation()
  4014. {
  4015. m_host.AddScriptLPS(1);
  4016. return new LSL_Types.Quaternion(m_host.ParentGroup.GroupRotation.X, m_host.ParentGroup.GroupRotation.Y, m_host.ParentGroup.GroupRotation.Z, m_host.ParentGroup.GroupRotation.W);
  4017. }
  4018. public string llGetObjectDesc()
  4019. {
  4020. return m_host.Description!=null?m_host.Description:String.Empty;
  4021. }
  4022. public void llSetObjectDesc(string desc)
  4023. {
  4024. m_host.AddScriptLPS(1);
  4025. m_host.Description = desc!=null?desc:String.Empty;
  4026. }
  4027. public string llGetCreator()
  4028. {
  4029. m_host.AddScriptLPS(1);
  4030. return m_host.ObjectCreator.ToString();
  4031. }
  4032. public string llGetTimestamp()
  4033. {
  4034. m_host.AddScriptLPS(1);
  4035. return DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ");
  4036. }
  4037. public void llSetLinkAlpha(int linknumber, double alpha, int face)
  4038. {
  4039. m_host.AddScriptLPS(1);
  4040. SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknumber);
  4041. if (linknumber > -1)
  4042. {
  4043. LLObject.TextureEntry tex = part.Shape.Textures;
  4044. LLColor texcolor;
  4045. if (face > -1)
  4046. {
  4047. texcolor = tex.CreateFace((uint)face).RGBA;
  4048. texcolor.A = (float)Math.Abs(alpha - 1);
  4049. tex.FaceTextures[face].RGBA = texcolor;
  4050. part.UpdateTexture(tex);
  4051. return;
  4052. }
  4053. else if (face == -1)
  4054. {
  4055. texcolor = tex.DefaultTexture.RGBA;
  4056. texcolor.A = (float)Math.Abs(alpha - 1);
  4057. tex.DefaultTexture.RGBA = texcolor;
  4058. for (uint i = 0; i < 32; i++)
  4059. {
  4060. if (tex.FaceTextures[i] != null)
  4061. {
  4062. texcolor = tex.FaceTextures[i].RGBA;
  4063. texcolor.A = (float)Math.Abs(alpha - 1);
  4064. tex.FaceTextures[i].RGBA = texcolor;
  4065. }
  4066. }
  4067. texcolor = tex.DefaultTexture.RGBA;
  4068. texcolor.A = (float)Math.Abs(alpha - 1);
  4069. tex.DefaultTexture.RGBA = texcolor;
  4070. part.UpdateTexture(tex);
  4071. return;
  4072. }
  4073. return;
  4074. }
  4075. else if (linknumber == -1)
  4076. {
  4077. int num = m_host.ParentGroup.PrimCount;
  4078. for (int w = 0; w < num; w++)
  4079. {
  4080. linknumber = w;
  4081. part = m_host.ParentGroup.GetLinkNumPart(linknumber);
  4082. LLObject.TextureEntry tex = part.Shape.Textures;
  4083. LLColor texcolor;
  4084. if (face > -1)
  4085. {
  4086. texcolor = tex.CreateFace((uint)face).RGBA;
  4087. texcolor.A = (float)Math.Abs(alpha - 1);
  4088. tex.FaceTextures[face].RGBA = texcolor;
  4089. part.UpdateTexture(tex);
  4090. }
  4091. else if (face == -1)
  4092. {
  4093. texcolor = tex.DefaultTexture.RGBA;
  4094. texcolor.A = (float)Math.Abs(alpha - 1);
  4095. tex.DefaultTexture.RGBA = texcolor;
  4096. for (uint i = 0; i < 32; i++)
  4097. {
  4098. if (tex.FaceTextures[i] != null)
  4099. {
  4100. texcolor = tex.FaceTextures[i].RGBA;
  4101. texcolor.A = (float)Math.Abs(alpha - 1);
  4102. tex.FaceTextures[i].RGBA = texcolor;
  4103. }
  4104. }
  4105. texcolor = tex.DefaultTexture.RGBA;
  4106. texcolor.A = (float)Math.Abs(alpha - 1);
  4107. tex.DefaultTexture.RGBA = texcolor;
  4108. part.UpdateTexture(tex);
  4109. }
  4110. }
  4111. return;
  4112. }
  4113. }
  4114. public LSL_Types.LSLInteger llGetNumberOfPrims()
  4115. {
  4116. m_host.AddScriptLPS(1);
  4117. return m_host.ParentGroup.PrimCount;
  4118. }
  4119. public int llGetNumberOfNotecardLines(string name)
  4120. {
  4121. m_host.AddScriptLPS(1);
  4122. // TODO: this script function should actually return
  4123. // the number of lines via the dataserver event
  4124. // once it is implemented - krtaylor
  4125. String[] notecardLines = GetNotecardLines(name);
  4126. if (!String.IsNullOrEmpty(notecardLines[0]))
  4127. {
  4128. return notecardLines.Length;
  4129. }
  4130. else
  4131. {
  4132. return 0;
  4133. }
  4134. }
  4135. public LSL_Types.list llGetBoundingBox(string obj)
  4136. {
  4137. m_host.AddScriptLPS(1);
  4138. NotImplemented("llGetBoundingBox");
  4139. return new LSL_Types.list();
  4140. }
  4141. public LSL_Types.Vector3 llGetGeometricCenter()
  4142. {
  4143. return new LSL_Types.Vector3(m_host.GetGeometricCenter().X, m_host.GetGeometricCenter().Y, m_host.GetGeometricCenter().Z);
  4144. }
  4145. public LSL_Types.list llGetPrimitiveParams(LSL_Types.list rules)
  4146. {
  4147. m_host.AddScriptLPS(1);
  4148. LSL_Types.list res = new LSL_Types.list();
  4149. int idx=0;
  4150. while (idx < rules.Length)
  4151. {
  4152. int code=Convert.ToInt32(rules.Data[idx++]);
  4153. int remain=rules.Length-idx;
  4154. switch (code)
  4155. {
  4156. case 2: // PRIM_MATERIAL
  4157. res.Add(new LSL_Types.LSLInteger(m_host.Material));
  4158. break;
  4159. case 3: // PRIM_PHYSICS
  4160. if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Physics) != 0)
  4161. res.Add(new LSL_Types.LSLInteger(1));
  4162. else
  4163. res.Add(new LSL_Types.LSLInteger(0));
  4164. break;
  4165. case 4: // PRIM_TEMP_ON_REZ
  4166. if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.TemporaryOnRez) != 0)
  4167. res.Add(new LSL_Types.LSLInteger(1));
  4168. else
  4169. res.Add(new LSL_Types.LSLInteger(0));
  4170. break;
  4171. case 5: // PRIM_PHANTOM
  4172. if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Phantom) != 0)
  4173. res.Add(new LSL_Types.LSLInteger(1));
  4174. else
  4175. res.Add(new LSL_Types.LSLInteger(0));
  4176. break;
  4177. case 6: // PRIM_POSITION
  4178. res.Add(new LSL_Types.Vector3(m_host.AbsolutePosition.X,
  4179. m_host.AbsolutePosition.Y,
  4180. m_host.AbsolutePosition.Z));
  4181. break;
  4182. case 7: // PRIM_SIZE
  4183. res.Add(new LSL_Types.Vector3(m_host.Scale.X,
  4184. m_host.Scale.Y,
  4185. m_host.Scale.Z));
  4186. break;
  4187. case 8: // PRIM_ROTATION
  4188. res.Add(new LSL_Types.Quaternion(m_host.RotationOffset.X,
  4189. m_host.RotationOffset.Y,
  4190. m_host.RotationOffset.Z,
  4191. m_host.RotationOffset.W));
  4192. break;
  4193. case 9: // PRIM_TYPE
  4194. // TODO--------------
  4195. res.Add(new LSL_Types.LSLInteger(0));
  4196. break;
  4197. case 17: // PRIM_TEXTURE
  4198. if (remain < 1)
  4199. return res;
  4200. int face=Convert.ToInt32(rules.Data[idx++]);
  4201. if (face == -1)
  4202. face = 0;
  4203. LLObject.TextureEntry tex = m_host.Shape.Textures;
  4204. LLObject.TextureEntryFace texface = tex.GetFace((uint)face);
  4205. res.Add(new LSL_Types.LSLString(texface.TextureID.ToString()));
  4206. res.Add(new LSL_Types.Vector3(texface.RepeatU,
  4207. texface.RepeatV,
  4208. 0));
  4209. res.Add(new LSL_Types.Vector3(texface.OffsetU,
  4210. texface.OffsetV,
  4211. 0));
  4212. res.Add(new LSL_Types.LSLFloat(texface.Rotation));
  4213. break;
  4214. case 18: // PRIM_COLOR
  4215. if (remain < 1)
  4216. return res;
  4217. face=Convert.ToInt32(rules.Data[idx++]);
  4218. tex = m_host.Shape.Textures;
  4219. LLColor texcolor;
  4220. if (face == -1) // TMP: Until we can determine number of sides, ALL_SIDES (-1) will return default color
  4221. texcolor = tex.DefaultTexture.RGBA;
  4222. else
  4223. texcolor = tex.GetFace((uint)face).RGBA;
  4224. res.Add(new LSL_Types.Vector3((255 - (texcolor.R * 255)) / 255,
  4225. (255 - (texcolor.G * 255)) / 255,
  4226. (255 - (texcolor.B * 255)) / 255));
  4227. res.Add(new LSL_Types.LSLFloat((texcolor.A * 255) / 255));
  4228. break;
  4229. case 19: // PRIM_BUMP_SHINY
  4230. // TODO--------------
  4231. if (remain < 1)
  4232. return res;
  4233. face=Convert.ToInt32(rules.Data[idx++]);
  4234. res.Add(new LSL_Types.LSLInteger(0));
  4235. res.Add(new LSL_Types.LSLInteger(0));
  4236. break;
  4237. case 20: // PRIM_FULLBRIGHT
  4238. // TODO--------------
  4239. if (remain < 1)
  4240. return res;
  4241. face=Convert.ToInt32(rules.Data[idx++]);
  4242. res.Add(new LSL_Types.LSLInteger(0));
  4243. break;
  4244. case 21: // PRIM_FLEXIBLE
  4245. PrimitiveBaseShape shape = m_host.Shape;
  4246. if (shape.FlexiEntry)
  4247. res.Add(new LSL_Types.LSLInteger(1)); // active
  4248. else
  4249. res.Add(new LSL_Types.LSLInteger(0));
  4250. res.Add(new LSL_Types.LSLInteger(shape.FlexiSoftness));// softness
  4251. res.Add(new LSL_Types.LSLFloat(shape.FlexiGravity)); // gravity
  4252. res.Add(new LSL_Types.LSLFloat(shape.FlexiDrag)); // friction
  4253. res.Add(new LSL_Types.LSLFloat(shape.FlexiWind)); // wind
  4254. res.Add(new LSL_Types.LSLFloat(shape.FlexiTension)); // tension
  4255. res.Add(new LSL_Types.Vector3(shape.FlexiForceX, // force
  4256. shape.FlexiForceY,
  4257. shape.FlexiForceZ));
  4258. break;
  4259. case 22: // PRIM_TEXGEN
  4260. // TODO--------------
  4261. // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR)
  4262. if (remain < 1)
  4263. return res;
  4264. face=Convert.ToInt32(rules.Data[idx++]);
  4265. res.Add(new LSL_Types.LSLInteger(0));
  4266. break;
  4267. case 23: // PRIM_POINT_LIGHT:
  4268. shape = m_host.Shape;
  4269. if (shape.LightEntry)
  4270. res.Add(new LSL_Types.LSLInteger(1)); // active
  4271. else
  4272. res.Add(new LSL_Types.LSLInteger(0));
  4273. res.Add(new LSL_Types.Vector3(shape.LightColorR, // color
  4274. shape.LightColorG,
  4275. shape.LightColorB));
  4276. res.Add(new LSL_Types.LSLFloat(shape.LightIntensity)); // intensity
  4277. res.Add(new LSL_Types.LSLFloat(shape.LightRadius)); // radius
  4278. res.Add(new LSL_Types.LSLFloat(shape.LightFalloff)); // falloff
  4279. break;
  4280. case 24: // PRIM_GLOW
  4281. // TODO--------------
  4282. if (remain < 1)
  4283. return res;
  4284. face=Convert.ToInt32(rules.Data[idx++]);
  4285. res.Add(new LSL_Types.LSLFloat(0));
  4286. break;
  4287. }
  4288. }
  4289. return res;
  4290. }
  4291. // <remarks>
  4292. // <para>
  4293. // The .NET definition of base 64 is:
  4294. // <list>
  4295. // <item>
  4296. // Significant: A-Z a-z 0-9 + -
  4297. // </item>
  4298. // <item>
  4299. // Whitespace: \t \n \r ' '
  4300. // </item>
  4301. // <item>
  4302. // Valueless: =
  4303. // </item>
  4304. // <item>
  4305. // End-of-string: \0 or '=='
  4306. // </item>
  4307. // </list>
  4308. // </para>
  4309. // <para>
  4310. // Each point in a base-64 string represents
  4311. // a 6 bit value. A 32-bit integer can be
  4312. // represented using 6 characters (with some
  4313. // redundancy).
  4314. // </para>
  4315. // <para>
  4316. // LSL requires a base64 string to be 8
  4317. // characters in length. LSL also uses '/'
  4318. // rather than '-' (MIME compliant).
  4319. // </para>
  4320. // <para>
  4321. // RFC 1341 used as a reference (as specified
  4322. // by the SecondLife Wiki).
  4323. // </para>
  4324. // <para>
  4325. // SL do not record any kind of exception for
  4326. // these functions, so the string to integer
  4327. // conversion returns '0' if an invalid
  4328. // character is encountered during conversion.
  4329. // </para>
  4330. // <para>
  4331. // References
  4332. // <list>
  4333. // <item>
  4334. // http://lslwiki.net/lslwiki/wakka.php?wakka=Base64
  4335. // </item>
  4336. // <item>
  4337. // </item>
  4338. // </list>
  4339. // </para>
  4340. // </remarks>
  4341. // <summary>
  4342. // Table for converting 6-bit integers into
  4343. // base-64 characters
  4344. // </summary>
  4345. private static readonly char[] i2ctable =
  4346. {
  4347. 'A','B','C','D','E','F','G','H',
  4348. 'I','J','K','L','M','N','O','P',
  4349. 'Q','R','S','T','U','V','W','X',
  4350. 'Y','Z',
  4351. 'a','b','c','d','e','f','g','h',
  4352. 'i','j','k','l','m','n','o','p',
  4353. 'q','r','s','t','u','v','w','x',
  4354. 'y','z',
  4355. '0','1','2','3','4','5','6','7',
  4356. '8','9',
  4357. '+','/'
  4358. };
  4359. // <summary>
  4360. // Table for converting base-64 characters
  4361. // into 6-bit integers.
  4362. // </summary>
  4363. private static readonly int[] c2itable =
  4364. {
  4365. -1,-1,-1,-1,-1,-1,-1,-1, // 0x
  4366. -1,-1,-1,-1,-1,-1,-1,-1,
  4367. -1,-1,-1,-1,-1,-1,-1,-1, // 1x
  4368. -1,-1,-1,-1,-1,-1,-1,-1,
  4369. -1,-1,-1,-1,-1,-1,-1,-1, // 2x
  4370. -1,-1,-1,63,-1,-1,-1,64,
  4371. 53,54,55,56,57,58,59,60, // 3x
  4372. 61,62,-1,-1,-1,0,-1,-1,
  4373. -1,1,2,3,4,5,6,7, // 4x
  4374. 8,9,10,11,12,13,14,15,
  4375. 16,17,18,19,20,21,22,23, // 5x
  4376. 24,25,26,-1,-1,-1,-1,-1,
  4377. -1,27,28,29,30,31,32,33, // 6x
  4378. 34,35,36,37,38,39,40,41,
  4379. 42,43,44,45,46,47,48,49, // 7x
  4380. 50,51,52,-1,-1,-1,-1,-1,
  4381. -1,-1,-1,-1,-1,-1,-1,-1, // 8x
  4382. -1,-1,-1,-1,-1,-1,-1,-1,
  4383. -1,-1,-1,-1,-1,-1,-1,-1, // 9x
  4384. -1,-1,-1,-1,-1,-1,-1,-1,
  4385. -1,-1,-1,-1,-1,-1,-1,-1, // Ax
  4386. -1,-1,-1,-1,-1,-1,-1,-1,
  4387. -1,-1,-1,-1,-1,-1,-1,-1, // Bx
  4388. -1,-1,-1,-1,-1,-1,-1,-1,
  4389. -1,-1,-1,-1,-1,-1,-1,-1, // Cx
  4390. -1,-1,-1,-1,-1,-1,-1,-1,
  4391. -1,-1,-1,-1,-1,-1,-1,-1, // Dx
  4392. -1,-1,-1,-1,-1,-1,-1,-1,
  4393. -1,-1,-1,-1,-1,-1,-1,-1, // Ex
  4394. -1,-1,-1,-1,-1,-1,-1,-1,
  4395. -1,-1,-1,-1,-1,-1,-1,-1, // Fx
  4396. -1,-1,-1,-1,-1,-1,-1,-1
  4397. };
  4398. // <summary>
  4399. // Converts a 32-bit integer into a Base64
  4400. // character string. Base64 character strings
  4401. // are always 8 characters long. All iinteger
  4402. // values are acceptable.
  4403. // </summary>
  4404. // <param name="number">
  4405. // 32-bit integer to be converted.
  4406. // </param>
  4407. // <returns>
  4408. // 8 character string. The 1st six characters
  4409. // contain the encoded number, the last two
  4410. // characters are padded with "=".
  4411. // </returns>
  4412. public string llIntegerToBase64(int number)
  4413. {
  4414. // uninitialized string
  4415. char[] imdt = new char[8];
  4416. m_host.AddScriptLPS(1);
  4417. // Manually unroll the loop
  4418. imdt[7] = '=';
  4419. imdt[6] = '=';
  4420. imdt[5] = i2ctable[number<<4 & 0x3F];
  4421. imdt[4] = i2ctable[number>>2 & 0x3F];
  4422. imdt[3] = i2ctable[number>>8 & 0x3F];
  4423. imdt[2] = i2ctable[number>>14 & 0x3F];
  4424. imdt[1] = i2ctable[number>>20 & 0x3F];
  4425. imdt[0] = i2ctable[number>>26 & 0x3F];
  4426. return new string(imdt);
  4427. }
  4428. // <summary>
  4429. // Converts an eight character base-64 string
  4430. // into a 32-bit integer.
  4431. // </summary>
  4432. // <param name="str">
  4433. // 8 characters string to be converted. Other
  4434. // length strings return zero.
  4435. // </param>
  4436. // <returns>
  4437. // Returns an integer representing the
  4438. // encoded value providedint he 1st 6
  4439. // characters of the string.
  4440. // </returns>
  4441. // <remarks>
  4442. // This is coded to behave like LSL's
  4443. // implementation (I think), based upon the
  4444. // information available at the Wiki.
  4445. // If more than 8 characters are supplied,
  4446. // zero is returned.
  4447. // If a NULL string is supplied, zero will
  4448. // be returned.
  4449. // If fewer than 6 characters are supplied, then
  4450. // the answer will reflect a partial
  4451. // accumulation.
  4452. // <para>
  4453. // The 6-bit segments are
  4454. // extracted left-to-right in big-endian mode,
  4455. // which means that segment 6 only contains the
  4456. // two low-order bits of the 32 bit integer as
  4457. // its high order 2 bits. A short string therefore
  4458. // means loss of low-order information. E.g.
  4459. //
  4460. // |<---------------------- 32-bit integer ----------------------->|<-Pad->|
  4461. // |<--Byte 0----->|<--Byte 1----->|<--Byte 2----->|<--Byte 3----->|<-Pad->|
  4462. // |3|3|2|2|2|2|2|2|2|2|2|2|1|1|1|1|1|1|1|1|1|1| | | | | | | | | | |P|P|P|P|
  4463. // |1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0|P|P|P|P|
  4464. // | str[0] | str[1] | str[2] | str[3] | str[4] | str[6] |
  4465. //
  4466. // </para>
  4467. // </remarks>
  4468. public LSL_Types.LSLInteger llBase64ToInteger(string str)
  4469. {
  4470. int number = 0;
  4471. int digit;
  4472. m_host.AddScriptLPS(1);
  4473. // Require a well-fromed base64 string
  4474. if (str.Length > 8)
  4475. return 0;
  4476. // The loop is unrolled in the interests
  4477. // of performance and simple necessity.
  4478. //
  4479. // MUST find 6 digits to be well formed
  4480. // -1 == invalid
  4481. // 0 == padding
  4482. if ((digit=c2itable[str[0]])<=0)
  4483. {
  4484. return digit<0?(int)0:number;
  4485. }
  4486. number += --digit<<26;
  4487. if ((digit=c2itable[str[1]])<=0)
  4488. {
  4489. return digit<0?(int)0:number;
  4490. }
  4491. number += --digit<<20;
  4492. if ((digit=c2itable[str[2]])<=0)
  4493. {
  4494. return digit<0?(int)0:number;
  4495. }
  4496. number += --digit<<14;
  4497. if ((digit=c2itable[str[3]])<=0)
  4498. {
  4499. return digit<0?(int)0:number;
  4500. }
  4501. number += --digit<<8;
  4502. if ((digit=c2itable[str[4]])<=0)
  4503. {
  4504. return digit<0?(int)0:number;
  4505. }
  4506. number += --digit<<2;
  4507. if ((digit=c2itable[str[5]])<=0)
  4508. {
  4509. return digit<0?(int)0:number;
  4510. }
  4511. number += --digit>>4;
  4512. // ignore trailing padding
  4513. return number;
  4514. }
  4515. public double llGetGMTclock()
  4516. {
  4517. m_host.AddScriptLPS(1);
  4518. return DateTime.UtcNow.TimeOfDay.TotalSeconds;
  4519. }
  4520. public string llGetSimulatorHostname()
  4521. {
  4522. m_host.AddScriptLPS(1);
  4523. return System.Environment.MachineName;
  4524. }
  4525. public void llSetLocalRot(LSL_Types.Quaternion rot)
  4526. {
  4527. m_host.AddScriptLPS(1);
  4528. m_host.RotationOffset = new LLQuaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s);
  4529. }
  4530. // <summary>
  4531. // Scan the string supplied in 'src' and
  4532. // tokenize it based upon two sets of
  4533. // tokenizers provided in two lists,
  4534. // separators and spacers.
  4535. // </summary>
  4536. //
  4537. // <remarks>
  4538. // Separators demarcate tokens and are
  4539. // elided as they are encountered. Spacers
  4540. // also demarcate tokens, but are themselves
  4541. // retained as tokens.
  4542. //
  4543. // Both separators and spacers may be arbitrarily
  4544. // long strings. i.e. ":::".
  4545. //
  4546. // The function returns an ordered list
  4547. // representing the tokens found in the supplied
  4548. // sources string. If two successive tokenizers
  4549. // are encountered, then a NULL entry is added
  4550. // to the list.
  4551. //
  4552. // It is a precondition that the source and
  4553. // toekizer lisst are non-null. If they are null,
  4554. // then a null pointer exception will be thrown
  4555. // while their lengths are being determined.
  4556. //
  4557. // A small amount of working memoryis required
  4558. // of approximately 8*#tokenizers.
  4559. //
  4560. // There are many ways in which this function
  4561. // can be implemented, this implementation is
  4562. // fairly naive and assumes that when the
  4563. // function is invooked with a short source
  4564. // string and/or short lists of tokenizers, then
  4565. // performance will not be an issue.
  4566. //
  4567. // In order to minimize the perofrmance
  4568. // effects of long strings, or large numbers
  4569. // of tokeizers, the function skips as far as
  4570. // possible whenever a toekenizer is found,
  4571. // and eliminates redundant tokenizers as soon
  4572. // as is possible.
  4573. //
  4574. // The implementation tries to avoid any copying
  4575. // of arrays or other objects.
  4576. // </remarks>
  4577. public LSL_Types.list llParseStringKeepNulls(string src, LSL_Types.list separators, LSL_Types.list spacers)
  4578. {
  4579. int beginning = 0;
  4580. int srclen = src.Length;
  4581. int seplen = separators.Length;
  4582. object[] separray = separators.Data;
  4583. int spclen = spacers.Length;
  4584. object[] spcarray = spacers.Data;
  4585. int mlen = seplen+spclen;
  4586. int[] offset = new int[mlen+1];
  4587. bool[] active = new bool[mlen];
  4588. int best;
  4589. int j;
  4590. // Initial capacity reduces resize cost
  4591. LSL_Types.list tokens = new LSL_Types.list();
  4592. m_host.AddScriptLPS(1);
  4593. // All entries are initially valid
  4594. for (int i = 0; i < mlen; i++)
  4595. active[i] = true;
  4596. offset[mlen] = srclen;
  4597. while (beginning < srclen)
  4598. {
  4599. best = mlen; // as bad as it gets
  4600. // Scan for separators
  4601. for (j = 0; j < seplen; j++)
  4602. {
  4603. if (active[j])
  4604. {
  4605. // scan all of the markers
  4606. if ((offset[j] = src.IndexOf((string)separray[j],beginning)) == -1)
  4607. {
  4608. // not present at all
  4609. active[j] = false;
  4610. }
  4611. else
  4612. {
  4613. // present and correct
  4614. if (offset[j] < offset[best])
  4615. {
  4616. // closest so far
  4617. best = j;
  4618. if (offset[best] == beginning)
  4619. break;
  4620. }
  4621. }
  4622. }
  4623. }
  4624. // Scan for spacers
  4625. if (offset[best] != beginning)
  4626. {
  4627. for (j = seplen; (j < mlen) && (offset[best] > beginning); j++)
  4628. {
  4629. if (active[j])
  4630. {
  4631. // scan all of the markers
  4632. if ((offset[j] = src.IndexOf((string)spcarray[j-seplen],beginning)) == -1)
  4633. {
  4634. // not present at all
  4635. active[j] = false;
  4636. }
  4637. else
  4638. {
  4639. // present and correct
  4640. if (offset[j] < offset[best])
  4641. {
  4642. // closest so far
  4643. best = j;
  4644. }
  4645. }
  4646. }
  4647. }
  4648. }
  4649. // This is the normal exit from the scanning loop
  4650. if (best == mlen)
  4651. {
  4652. // no markers were found on this pass
  4653. // so we're pretty much done
  4654. tokens.Add(src.Substring(beginning, srclen-beginning));
  4655. break;
  4656. }
  4657. // Otherwise we just add the newly delimited token
  4658. // and recalculate where the search should continue.
  4659. tokens.Add(src.Substring(beginning,offset[best]-beginning));
  4660. if (best < seplen)
  4661. {
  4662. beginning = offset[best]+((string)separray[best]).Length;
  4663. }
  4664. else
  4665. {
  4666. beginning = offset[best]+((string)spcarray[best-seplen]).Length;
  4667. tokens.Add(spcarray[best-seplen]);
  4668. }
  4669. }
  4670. // This an awkward an not very intuitive boundary case. If the
  4671. // last substring is a tokenizer, then there is an implied trailing
  4672. // null list entry. Hopefully the single comparison will not be too
  4673. // arduous. Alternatively the 'break' could be replced with a return
  4674. // but that's shabby programming.
  4675. if (beginning == srclen)
  4676. {
  4677. if (srclen != 0)
  4678. tokens.Add("");
  4679. }
  4680. return tokens;
  4681. }
  4682. public void llRezAtRoot(string inventory, LSL_Types.Vector3 position, LSL_Types.Vector3 velocity,
  4683. LSL_Types.Quaternion rot, int param)
  4684. {
  4685. m_host.AddScriptLPS(1);
  4686. NotImplemented("llRezAtRoot");
  4687. }
  4688. public LSL_Types.LSLInteger llGetObjectPermMask(int mask)
  4689. {
  4690. m_host.AddScriptLPS(1);
  4691. int permmask = 0;
  4692. if (mask == BuiltIn_Commands_BaseClass.MASK_BASE)//0
  4693. {
  4694. permmask = (int)m_host.BaseMask;
  4695. }
  4696. else if (mask == BuiltIn_Commands_BaseClass.MASK_OWNER)//1
  4697. {
  4698. permmask = (int)m_host.OwnerMask;
  4699. }
  4700. else if (mask == BuiltIn_Commands_BaseClass.MASK_GROUP)//2
  4701. {
  4702. permmask = (int)m_host.GroupMask;
  4703. }
  4704. else if (mask == BuiltIn_Commands_BaseClass.MASK_EVERYONE)//3
  4705. {
  4706. permmask = (int)m_host.EveryoneMask;
  4707. }
  4708. else if (mask == BuiltIn_Commands_BaseClass.MASK_NEXT)//4
  4709. {
  4710. permmask = (int)m_host.NextOwnerMask;
  4711. }
  4712. return permmask;
  4713. }
  4714. public void llSetObjectPermMask(int mask, int value)
  4715. {
  4716. m_host.AddScriptLPS(1);
  4717. if (mask == BuiltIn_Commands_BaseClass.MASK_BASE)//0
  4718. {
  4719. m_host.BaseMask = (uint)value;
  4720. }
  4721. else if (mask == BuiltIn_Commands_BaseClass.MASK_OWNER)//1
  4722. {
  4723. m_host.OwnerMask = (uint)value;
  4724. }
  4725. else if (mask == BuiltIn_Commands_BaseClass.MASK_GROUP)//2
  4726. {
  4727. m_host.GroupMask = (uint)value;
  4728. }
  4729. else if (mask == BuiltIn_Commands_BaseClass.MASK_EVERYONE)//3
  4730. {
  4731. m_host.EveryoneMask = (uint)value;
  4732. }
  4733. else if (mask == BuiltIn_Commands_BaseClass.MASK_NEXT)//4
  4734. {
  4735. m_host.NextOwnerMask = (uint)value;
  4736. }
  4737. }
  4738. public LSL_Types.LSLInteger llGetInventoryPermMask(string item, int mask)
  4739. {
  4740. m_host.AddScriptLPS(1);
  4741. foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
  4742. {
  4743. if (inv.Value.Name == item)
  4744. {
  4745. switch (mask)
  4746. {
  4747. case 0:
  4748. return (int)inv.Value.BaseMask;
  4749. case 1:
  4750. return (int)inv.Value.OwnerMask;
  4751. case 2:
  4752. return (int)inv.Value.GroupMask;
  4753. case 3:
  4754. return (int)inv.Value.EveryoneMask;
  4755. case 4:
  4756. return (int)inv.Value.NextOwnerMask;
  4757. }
  4758. }
  4759. }
  4760. return -1;
  4761. }
  4762. public void llSetInventoryPermMask(string item, int mask, int value)
  4763. {
  4764. m_host.AddScriptLPS(1);
  4765. NotImplemented("llSetInventoryPermMask");
  4766. }
  4767. public string llGetInventoryCreator(string item)
  4768. {
  4769. m_host.AddScriptLPS(1);
  4770. foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
  4771. {
  4772. if (inv.Value.Name == item)
  4773. {
  4774. return inv.Value.CreatorID.ToString();
  4775. }
  4776. }
  4777. llSay(0, "No item name '" + item + "'");
  4778. return String.Empty;
  4779. }
  4780. public void llOwnerSay(string msg)
  4781. {
  4782. m_host.AddScriptLPS(1);
  4783. World.SimChatBroadcast(Helpers.StringToField(msg),
  4784. ChatTypeEnum.Owner, 0, m_host.AbsolutePosition,
  4785. m_host.Name, m_host.UUID, false);
  4786. IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
  4787. wComm.DeliverMessage(ChatTypeEnum.Owner, 0, m_host.Name, m_host.UUID, msg);
  4788. }
  4789. public string llRequestSimulatorData(string simulator, int data)
  4790. {
  4791. m_host.AddScriptLPS(1);
  4792. string reply = String.Empty;
  4793. RegionInfo info = m_ScriptEngine.World.RequestClosestRegion(simulator);
  4794. switch (data)
  4795. {
  4796. case 5: // DATA_SIM_POS
  4797. if (info == null)
  4798. return LLUUID.Zero.ToString();
  4799. reply = new LSL_Types.Vector3(
  4800. info.RegionLocX * Constants.RegionSize,
  4801. info.RegionLocY * Constants.RegionSize,
  4802. 0).ToString();
  4803. break;
  4804. case 6: // DATA_SIM_STATUS
  4805. if (info != null)
  4806. reply = "up"; // Duh!
  4807. else
  4808. reply = "unknown";
  4809. break;
  4810. case 7: // DATA_SIM_RATING
  4811. if (info == null)
  4812. return LLUUID.Zero.ToString();
  4813. int access = (int)info.EstateSettings.simAccess;
  4814. if (access == 21)
  4815. reply = "MATURE";
  4816. else if (access == 13)
  4817. reply = "MATURE";
  4818. else
  4819. reply = "UNKNOWN";
  4820. break;
  4821. default:
  4822. return LLUUID.Zero.ToString(); // Raise no event
  4823. }
  4824. LLUUID rq = LLUUID.Random();
  4825. LLUUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager.
  4826. m_Dataserver.RegisterRequest(m_localID,
  4827. m_itemID, rq.ToString());
  4828. m_ScriptEngine.m_ASYNCLSLCommandManager.
  4829. m_Dataserver.DataserverReply(rq.ToString(), reply);
  4830. return tid.ToString();
  4831. }
  4832. public void llForceMouselook(int mouselook)
  4833. {
  4834. m_host.AddScriptLPS(1);
  4835. NotImplemented("llForceMouselook");
  4836. }
  4837. public double llGetObjectMass(string id)
  4838. {
  4839. m_host.AddScriptLPS(1);
  4840. LLUUID key = new LLUUID();
  4841. if (LLUUID.TryParse(id,out key))
  4842. {
  4843. return (double)World.GetSceneObjectPart(World.Entities[key].LocalId).GetMass();
  4844. }
  4845. return 0;
  4846. }
  4847. /// <summary>
  4848. /// illListReplaceList removes the sub-list defined by the inclusive indices
  4849. /// start and end and inserts the src list in its place. The inclusive
  4850. /// nature of the indices means that at least one element must be deleted
  4851. /// if the indices are within the bounds of the existing list. I.e. 2,2
  4852. /// will remove the element at index 2 and replace it with the source
  4853. /// list. Both indices may be negative, with the usual interpretation. An
  4854. /// interesting case is where end is lower than start. As these indices
  4855. /// bound the list to be removed, then 0->end, and start->lim are removed
  4856. /// and the source list is added as a suffix.
  4857. /// </summary>
  4858. public LSL_Types.list llListReplaceList(LSL_Types.list dest, LSL_Types.list src, int start, int end)
  4859. {
  4860. LSL_Types.list pref = null;
  4861. m_host.AddScriptLPS(1);
  4862. // Note that although we have normalized, both
  4863. // indices could still be negative.
  4864. if (start < 0)
  4865. {
  4866. start = start+dest.Length;
  4867. }
  4868. if (end < 0)
  4869. {
  4870. end = end+dest.Length;
  4871. }
  4872. // The comventional case, remove a sequence starting with
  4873. // start and ending with end. And then insert the source
  4874. // list.
  4875. if (start <= end)
  4876. {
  4877. // If greater than zero, then there is going to be a
  4878. // surviving prefix. Otherwise the inclusive nature
  4879. // of the indices mean that we're going to add the
  4880. // source list as a prefix.
  4881. if (start > 0)
  4882. {
  4883. pref = dest.GetSublist(0,start-1);
  4884. // Only add a suffix if there is something
  4885. // beyond the end index (it's inclusive too).
  4886. if (end+1 < dest.Length)
  4887. {
  4888. return pref + src + dest.GetSublist(end+1,-1);
  4889. }
  4890. else
  4891. {
  4892. return pref + src;
  4893. }
  4894. }
  4895. // If start is less than or equal to zero, then
  4896. // the new list is simply a prefix. We still need to
  4897. // figure out any necessary surgery to the destination
  4898. // based upon end. Note that if end exceeds the upper
  4899. // bound in this case, the entire destination list
  4900. // is removed.
  4901. else
  4902. {
  4903. if (end+1 < dest.Length)
  4904. {
  4905. return src + dest.GetSublist(end+1,-1);
  4906. }
  4907. else
  4908. {
  4909. return src;
  4910. }
  4911. }
  4912. }
  4913. // Finally, if start > end, we strip away a prefix and
  4914. // a suffix, to leave the list that sits <between> ens
  4915. // and start, and then tag on the src list. AT least
  4916. // that's my interpretation. We can get sublist to do
  4917. // this for us. Note that one, or both of the indices
  4918. // might have been negative.
  4919. else
  4920. {
  4921. return dest.GetSublist(end+1,start-1)+src;
  4922. }
  4923. }
  4924. public void llLoadURL(string avatar_id, string message, string url)
  4925. {
  4926. m_host.AddScriptLPS(1);
  4927. LLUUID avatarId = new LLUUID(avatar_id);
  4928. m_ScriptEngine.World.SendUrlToUser(avatarId, m_host.Name, m_host.UUID, m_host.ObjectOwner, false, message,
  4929. url);
  4930. }
  4931. public void llParcelMediaCommandList(LSL_Types.list commandList)
  4932. {
  4933. m_host.AddScriptLPS(1);
  4934. NotImplemented("llParcelMediaCommandList");
  4935. }
  4936. public void llParcelMediaQuery()
  4937. {
  4938. m_host.AddScriptLPS(1);
  4939. NotImplemented("llParcelMediaQuery");
  4940. }
  4941. public LSL_Types.LSLInteger llModPow(int a, int b, int c)
  4942. {
  4943. m_host.AddScriptLPS(1);
  4944. Int64 tmp = 0;
  4945. Math.DivRem(Convert.ToInt64(Math.Pow(a, b)), c, out tmp);
  4946. return Convert.ToInt32(tmp);
  4947. }
  4948. public LSL_Types.LSLInteger llGetInventoryType(string name)
  4949. {
  4950. m_host.AddScriptLPS(1);
  4951. foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
  4952. {
  4953. if (inv.Value.Name == name)
  4954. {
  4955. return inv.Value.InvType;
  4956. }
  4957. }
  4958. return -1;
  4959. }
  4960. public void llSetPayPrice(int price, LSL_Types.list quick_pay_buttons)
  4961. {
  4962. m_host.AddScriptLPS(1);
  4963. if (quick_pay_buttons.Data.Length != 4)
  4964. {
  4965. LSLError("List must have 4 elements");
  4966. return;
  4967. }
  4968. m_host.ParentGroup.RootPart.PayPrice[0]=price;
  4969. m_host.ParentGroup.RootPart.PayPrice[1]=(int)quick_pay_buttons.Data[0];
  4970. m_host.ParentGroup.RootPart.PayPrice[2]=(int)quick_pay_buttons.Data[1];
  4971. m_host.ParentGroup.RootPart.PayPrice[3]=(int)quick_pay_buttons.Data[2];
  4972. m_host.ParentGroup.RootPart.PayPrice[4]=(int)quick_pay_buttons.Data[3];
  4973. }
  4974. public LSL_Types.Vector3 llGetCameraPos()
  4975. {
  4976. m_host.AddScriptLPS(1);
  4977. NotImplemented("llGetCameraPos");
  4978. return new LSL_Types.Vector3();
  4979. }
  4980. public LSL_Types.Quaternion llGetCameraRot()
  4981. {
  4982. m_host.AddScriptLPS(1);
  4983. NotImplemented("llGetCameraRot");
  4984. return new LSL_Types.Quaternion();
  4985. }
  4986. public void llSetPrimURL()
  4987. {
  4988. m_host.AddScriptLPS(1);
  4989. NotImplemented("llSetPrimURL");
  4990. }
  4991. public void llRefreshPrimURL()
  4992. {
  4993. m_host.AddScriptLPS(1);
  4994. NotImplemented("llRefreshPrimURL");
  4995. }
  4996. public string llEscapeURL(string url)
  4997. {
  4998. m_host.AddScriptLPS(1);
  4999. try
  5000. {
  5001. return Uri.EscapeUriString(url);
  5002. }
  5003. catch (Exception ex)
  5004. {
  5005. return "llEscapeURL: " + ex.ToString();
  5006. }
  5007. }
  5008. public string llUnescapeURL(string url)
  5009. {
  5010. m_host.AddScriptLPS(1);
  5011. try
  5012. {
  5013. return Uri.UnescapeDataString(url);
  5014. }
  5015. catch (Exception ex)
  5016. {
  5017. return "llUnescapeURL: " + ex.ToString();
  5018. }
  5019. }
  5020. public void llMapDestination(string simname, LSL_Types.Vector3 pos, LSL_Types.Vector3 look_at)
  5021. {
  5022. m_host.AddScriptLPS(1);
  5023. NotImplemented("llMapDestination");
  5024. }
  5025. public void llAddToLandBanList(string avatar, double hours)
  5026. {
  5027. m_host.AddScriptLPS(1);
  5028. LLUUID key;
  5029. LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).landData;
  5030. if (land.ownerID == m_host.OwnerID)
  5031. {
  5032. ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
  5033. if (LLUUID.TryParse(avatar, out key))
  5034. {
  5035. entry.AgentID = key;
  5036. entry.Flags = ParcelManager.AccessList.Ban;
  5037. entry.Time = DateTime.Now.AddHours(hours);
  5038. land.parcelAccessList.Add(entry);
  5039. }
  5040. }
  5041. }
  5042. public void llRemoveFromLandPassList(string avatar)
  5043. {
  5044. m_host.AddScriptLPS(1);
  5045. LLUUID key;
  5046. LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).landData;
  5047. if (land.ownerID == m_host.OwnerID)
  5048. {
  5049. if (LLUUID.TryParse(avatar, out key))
  5050. {
  5051. foreach (ParcelManager.ParcelAccessEntry entry in land.parcelAccessList)
  5052. {
  5053. if (entry.AgentID == key && entry.Flags == ParcelManager.AccessList.Access)
  5054. {
  5055. land.parcelAccessList.Remove(entry);
  5056. break;
  5057. }
  5058. }
  5059. }
  5060. }
  5061. }
  5062. public void llRemoveFromLandBanList(string avatar)
  5063. {
  5064. m_host.AddScriptLPS(1);
  5065. LLUUID key;
  5066. LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).landData;
  5067. if (land.ownerID == m_host.OwnerID)
  5068. {
  5069. if (LLUUID.TryParse(avatar, out key))
  5070. {
  5071. foreach (ParcelManager.ParcelAccessEntry entry in land.parcelAccessList)
  5072. {
  5073. if (entry.AgentID == key && entry.Flags == ParcelManager.AccessList.Ban)
  5074. {
  5075. land.parcelAccessList.Remove(entry);
  5076. break;
  5077. }
  5078. }
  5079. }
  5080. }
  5081. }
  5082. public void llSetCameraParams(LSL_Types.list rules)
  5083. {
  5084. m_host.AddScriptLPS(1);
  5085. NotImplemented("llSetCameraParams");
  5086. }
  5087. public void llClearCameraParams()
  5088. {
  5089. m_host.AddScriptLPS(1);
  5090. NotImplemented("llClearCameraParams");
  5091. }
  5092. public double llListStatistics(int operation, LSL_Types.list src)
  5093. {
  5094. m_host.AddScriptLPS(1);
  5095. LSL_Types.list nums = LSL_Types.list.ToDoubleList(src);
  5096. switch (operation)
  5097. {
  5098. case BuiltIn_Commands_BaseClass.LIST_STAT_RANGE:
  5099. return nums.Range();
  5100. case BuiltIn_Commands_BaseClass.LIST_STAT_MIN:
  5101. return nums.Min();
  5102. case BuiltIn_Commands_BaseClass.LIST_STAT_MAX:
  5103. return nums.Max();
  5104. case BuiltIn_Commands_BaseClass.LIST_STAT_MEAN:
  5105. return nums.Mean();
  5106. case BuiltIn_Commands_BaseClass.LIST_STAT_MEDIAN:
  5107. return nums.Median();
  5108. case BuiltIn_Commands_BaseClass.LIST_STAT_NUM_COUNT:
  5109. return nums.NumericLength();
  5110. case BuiltIn_Commands_BaseClass.LIST_STAT_STD_DEV:
  5111. return nums.StdDev();
  5112. case BuiltIn_Commands_BaseClass.LIST_STAT_SUM:
  5113. return nums.Sum();
  5114. case BuiltIn_Commands_BaseClass.LIST_STAT_SUM_SQUARES:
  5115. return nums.SumSqrs();
  5116. case BuiltIn_Commands_BaseClass.LIST_STAT_GEOMETRIC_MEAN:
  5117. return nums.GeometricMean();
  5118. case BuiltIn_Commands_BaseClass.LIST_STAT_HARMONIC_MEAN:
  5119. return nums.HarmonicMean();
  5120. default:
  5121. return 0.0;
  5122. }
  5123. }
  5124. public LSL_Types.LSLInteger llGetUnixTime()
  5125. {
  5126. m_host.AddScriptLPS(1);
  5127. return Util.UnixTimeSinceEpoch();
  5128. }
  5129. public LSL_Types.LSLInteger llGetParcelFlags(LSL_Types.Vector3 pos)
  5130. {
  5131. m_host.AddScriptLPS(1);
  5132. return (int)World.LandChannel.GetLandObject((float)pos.x, (float)pos.y).landData.landFlags;
  5133. }
  5134. public LSL_Types.LSLInteger llGetRegionFlags()
  5135. {
  5136. m_host.AddScriptLPS(1);
  5137. return (int)World.RegionInfo.EstateSettings.regionFlags;
  5138. }
  5139. public string llXorBase64StringsCorrect(string str1, string str2)
  5140. {
  5141. m_host.AddScriptLPS(1);
  5142. string ret = String.Empty;
  5143. string src1 = llBase64ToString(str1);
  5144. string src2 = llBase64ToString(str2);
  5145. int c = 0;
  5146. for (int i = 0; i < src1.Length; i++)
  5147. {
  5148. ret += src1[i] ^ src2[c];
  5149. c++;
  5150. if (c > src2.Length)
  5151. c = 0;
  5152. }
  5153. return llStringToBase64(ret);
  5154. }
  5155. public string llHTTPRequest(string url, LSL_Types.list parameters, string body)
  5156. {
  5157. // Partial implementation: support for parameter flags needed
  5158. // see http://wiki.secondlife.com/wiki/LlHTTPRequest
  5159. // parameter flags support are implemented in ScriptsHttpRequests.cs
  5160. // in StartHttpRequest
  5161. m_host.AddScriptLPS(1);
  5162. IHttpRequests httpScriptMod =
  5163. m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>();
  5164. List<string> param = new List<string>();
  5165. foreach (object o in parameters.Data)
  5166. {
  5167. param.Add(o.ToString());
  5168. }
  5169. LLUUID reqID = httpScriptMod.
  5170. StartHttpRequest(m_localID, m_itemID, url, param, body);
  5171. if (reqID != LLUUID.Zero)
  5172. return reqID.ToString();
  5173. else
  5174. return null;
  5175. }
  5176. public void llResetLandBanList()
  5177. {
  5178. m_host.AddScriptLPS(1);
  5179. LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).landData;
  5180. if (land.ownerID == m_host.OwnerID)
  5181. {
  5182. foreach (ParcelManager.ParcelAccessEntry entry in land.parcelAccessList)
  5183. {
  5184. if (entry.Flags == ParcelManager.AccessList.Ban)
  5185. {
  5186. land.parcelAccessList.Remove(entry);
  5187. }
  5188. }
  5189. }
  5190. }
  5191. public void llResetLandPassList()
  5192. {
  5193. m_host.AddScriptLPS(1);
  5194. LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).landData;
  5195. if (land.ownerID == m_host.OwnerID)
  5196. {
  5197. foreach (ParcelManager.ParcelAccessEntry entry in land.parcelAccessList)
  5198. {
  5199. if (entry.Flags == ParcelManager.AccessList.Access)
  5200. {
  5201. land.parcelAccessList.Remove(entry);
  5202. }
  5203. }
  5204. }
  5205. }
  5206. public LSL_Types.LSLInteger llGetParcelPrimCount(LSL_Types.Vector3 pos, int category, int sim_wide)
  5207. {
  5208. m_host.AddScriptLPS(1);
  5209. LandData land = World.GetLandData((float)pos.x, (float)pos.y);
  5210. if (land == null)
  5211. {
  5212. return 0;
  5213. }
  5214. else
  5215. {
  5216. if (sim_wide == 1)
  5217. {
  5218. if (category == 0)
  5219. {
  5220. return land.simwidePrims;
  5221. }
  5222. else
  5223. {
  5224. //public int simwideArea = 0;
  5225. return 0;
  5226. }
  5227. }
  5228. else
  5229. {
  5230. if (category == 0)//Total Prims
  5231. {
  5232. return 0;//land.
  5233. }
  5234. else if (category == 1)//Owner Prims
  5235. {
  5236. return land.ownerPrims;
  5237. }
  5238. else if (category == 2)//Group Prims
  5239. {
  5240. return land.groupPrims;
  5241. }
  5242. else if (category == 3)//Other Prims
  5243. {
  5244. return land.otherPrims;
  5245. }
  5246. else if (category == 4)//Selected
  5247. {
  5248. return land.selectedPrims;
  5249. }
  5250. else if (category == 5)//Temp
  5251. {
  5252. return 0;//land.
  5253. }
  5254. }
  5255. }
  5256. return 0;
  5257. }
  5258. public LSL_Types.list llGetParcelPrimOwners(LSL_Types.Vector3 pos)
  5259. {
  5260. m_host.AddScriptLPS(1);
  5261. LandObject land = (LandObject)World.LandChannel.GetLandObject((float)pos.x, (float)pos.y);
  5262. LSL_Types.list ret = new LSL_Types.list();
  5263. if (land != null)
  5264. {
  5265. foreach (KeyValuePair<LLUUID, int> d in land.getLandObjectOwners())
  5266. {
  5267. ret.Add(d.Key.ToString());
  5268. ret.Add(d.Value);
  5269. }
  5270. }
  5271. return ret;
  5272. }
  5273. public LSL_Types.LSLInteger llGetObjectPrimCount(string object_id)
  5274. {
  5275. m_host.AddScriptLPS(1);
  5276. SceneObjectPart part = World.GetSceneObjectPart(new LLUUID(object_id));
  5277. if (part == null)
  5278. {
  5279. return 0;
  5280. }
  5281. else
  5282. {
  5283. return part.ParentGroup.Children.Count;
  5284. }
  5285. }
  5286. public LSL_Types.LSLInteger llGetParcelMaxPrims(LSL_Types.Vector3 pos, int sim_wide)
  5287. {
  5288. m_host.AddScriptLPS(1);
  5289. // Alondria: This currently just is utilizing the normal grid's 0.22 prims/m2 calculation
  5290. // Which probably will be irrelevent in OpenSim....
  5291. LandData land = World.GetLandData((float)pos.x, (float)pos.y);
  5292. float bonusfactor = World.RegionInfo.EstateSettings.objectBonusFactor;
  5293. if (land == null)
  5294. {
  5295. return 0;
  5296. }
  5297. if (sim_wide == 1)
  5298. {
  5299. decimal v = land.simwideArea * (decimal)(0.22) * (decimal)bonusfactor;
  5300. return (int)v;
  5301. }
  5302. else
  5303. {
  5304. decimal v = land.area * (decimal)(0.22) * (decimal)bonusfactor;
  5305. return (int)v;
  5306. }
  5307. }
  5308. public LSL_Types.list llGetParcelDetails(LSL_Types.Vector3 pos, LSL_Types.list param)
  5309. {
  5310. m_host.AddScriptLPS(1);
  5311. LandData land = World.GetLandData((float)pos.x, (float)pos.y);
  5312. if (land == null)
  5313. {
  5314. return new LSL_Types.list(0);
  5315. }
  5316. LSL_Types.list ret = new LSL_Types.list();
  5317. foreach (object o in param.Data)
  5318. {
  5319. switch (o.ToString())
  5320. {
  5321. case "0":
  5322. ret = ret + new LSL_Types.list(land.landName);
  5323. break;
  5324. case "1":
  5325. ret = ret + new LSL_Types.list(land.landDesc);
  5326. break;
  5327. case "2":
  5328. ret = ret + new LSL_Types.list(land.ownerID.ToString());
  5329. break;
  5330. case "3":
  5331. ret = ret + new LSL_Types.list(land.groupID.ToString());
  5332. break;
  5333. case "4":
  5334. ret = ret + new LSL_Types.list(land.area);
  5335. break;
  5336. default:
  5337. ret = ret + new LSL_Types.list(0);
  5338. break;
  5339. }
  5340. }
  5341. return ret;
  5342. }
  5343. public void llSetLinkTexture(int linknumber, string texture, int face)
  5344. {
  5345. m_host.AddScriptLPS(1);
  5346. NotImplemented("llSetLinkTexture");
  5347. }
  5348. public string llStringTrim(string src, int type)
  5349. {
  5350. m_host.AddScriptLPS(1);
  5351. if (type == (int)BuiltIn_Commands_BaseClass.STRING_TRIM_HEAD) { return src.TrimStart(); }
  5352. if (type == (int)BuiltIn_Commands_BaseClass.STRING_TRIM_TAIL) { return src.TrimEnd(); }
  5353. if (type == (int)BuiltIn_Commands_BaseClass.STRING_TRIM) { return src.Trim(); }
  5354. return src;
  5355. }
  5356. public LSL_Types.list llGetObjectDetails(string id, LSL_Types.list args)
  5357. {
  5358. m_host.AddScriptLPS(1);
  5359. LSL_Types.list ret = new LSL_Types.list();
  5360. LLUUID key = new LLUUID();
  5361. if (LLUUID.TryParse(id, out key))
  5362. {
  5363. ScenePresence av = World.GetScenePresence(key);
  5364. if (av != null)
  5365. {
  5366. foreach (object o in args.Data)
  5367. {
  5368. switch (o.ToString())
  5369. {
  5370. case "1":
  5371. ret.Add(av.Firstname + " " + av.Lastname);
  5372. break;
  5373. case "2":
  5374. ret.Add("");
  5375. break;
  5376. case "3":
  5377. ret.Add(new LSL_Types.Vector3((double)av.AbsolutePosition.X, (double)av.AbsolutePosition.Y, (double)av.AbsolutePosition.Z));
  5378. break;
  5379. case "4":
  5380. ret.Add(new LSL_Types.Quaternion((double)av.Rotation.x, (double)av.Rotation.y, (double)av.Rotation.z, (double)av.Rotation.w));
  5381. break;
  5382. case "5":
  5383. ret.Add(new LSL_Types.Vector3(av.Velocity.X,av.Velocity.Y,av.Velocity.Z));
  5384. break;
  5385. case "6":
  5386. ret.Add(id);
  5387. break;
  5388. case "7":
  5389. ret.Add(LLUUID.Zero.ToString());
  5390. break;
  5391. case "8":
  5392. ret.Add(LLUUID.Zero.ToString());
  5393. break;
  5394. }
  5395. }
  5396. return ret;
  5397. }
  5398. SceneObjectPart obj = World.GetSceneObjectPart(key);
  5399. if (obj != null)
  5400. {
  5401. foreach (object o in args.Data)
  5402. {
  5403. switch (o.ToString())
  5404. {
  5405. case "1":
  5406. ret.Add(obj.Name);
  5407. break;
  5408. case "2":
  5409. ret.Add(obj.Description);
  5410. break;
  5411. case "3":
  5412. ret.Add(new LSL_Types.Vector3(obj.AbsolutePosition.X,obj.AbsolutePosition.Y,obj.AbsolutePosition.Z));
  5413. break;
  5414. case "4":
  5415. ret.Add(new LSL_Types.Quaternion(obj.RotationOffset.X, obj.RotationOffset.Y, obj.RotationOffset.Z, obj.RotationOffset.W));
  5416. break;
  5417. case "5":
  5418. ret.Add(new LSL_Types.Vector3(obj.Velocity.X, obj.Velocity.Y, obj.Velocity.Z));
  5419. break;
  5420. case "6":
  5421. ret.Add(obj.OwnerID.ToString());
  5422. break;
  5423. case "7":
  5424. ret.Add(obj.GroupID.ToString());
  5425. break;
  5426. case "8":
  5427. ret.Add(obj.CreatorID.ToString());
  5428. break;
  5429. }
  5430. }
  5431. return ret;
  5432. }
  5433. }
  5434. return new LSL_Types.list();
  5435. }
  5436. internal LLUUID ScriptByName(string name)
  5437. {
  5438. foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
  5439. {
  5440. if (item.Type == 10 && item.Name == name)
  5441. return item.ItemID;
  5442. }
  5443. return LLUUID.Zero;
  5444. }
  5445. internal void ShoutError(string msg)
  5446. {
  5447. llShout(BuiltIn_Commands_BaseClass.DEBUG_CHANNEL, msg);
  5448. }
  5449. internal void NotImplemented(string command)
  5450. {
  5451. if (throwErrorOnNotImplemented)
  5452. throw new NotImplementedException("Command not implemented: " + command);
  5453. }
  5454. internal void Deprecated(string command)
  5455. {
  5456. throw new Exception("Command deprecated: " + command);
  5457. }
  5458. internal void LSLError(string msg)
  5459. {
  5460. throw new Exception("LSL Runtime Error: " + msg);
  5461. }
  5462. }
  5463. }