diff --git a/maps/tests/deprecated_functions.json b/maps/tests/deprecated_functions.json new file mode 100644 index 00000000..a4c035f7 --- /dev/null +++ b/maps/tests/deprecated_functions.json @@ -0,0 +1,164 @@ +{ "compressionlevel":-1, + "height":10, + "infinite":false, + "layers":[ + { + "data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + "height":10, + "id":1, + "name":"floor", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":10, + "x":0, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":10, + "id":6, + "name":"triggerZone", + "opacity":1, + "properties":[ + { + "name":"zone", + "type":"string", + "value":"myTrigger" + }], + "type":"tilelayer", + "visible":true, + "width":10, + "x":0, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":10, + "id":7, + "name":"popupZone", + "opacity":1, + "properties":[ + { + "name":"zone", + "type":"string", + "value":"popupZone" + }], + "type":"tilelayer", + "visible":true, + "width":10, + "x":0, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":10, + "id":2, + "name":"start", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":10, + "x":0, + "y":0 + }, + { + "draworder":"topdown", + "id":3, + "name":"floorLayer", + "objects":[ + { + "height":147.135497146101, + "id":1, + "name":"myPopup2", + "rotation":0, + "type":"", + "visible":true, + "width":104.442827410047, + "x":142.817125079855, + "y":147.448134926559 + }, + { + "height":132.434722966794, + "id":2, + "name":"myPopup1", + "rotation":0, + "type":"", + "visible":true, + "width":125.735549178518, + "x":13.649632619596, + "y":50.8502491249093 + }, + { + "height":67, + "id":3, + "name":"", + "rotation":0, + "text": + { + "fontfamily":"Sans Serif", + "pixelsize":11, + "text":"Test:\nWalk on top carpet\nResult:\nA message \"Don't step on my carpet\" is displayed\nIn the console, deprecation warnings MUST be displayed", + "wrap":true + }, + "type":"", + "visible":true, + "width":252.4375, + "x":2.78125, + "y":2.5 + }, + { + "height":67, + "id":4, + "name":"", + "rotation":0, + "text": + { + "fontfamily":"Sans Serif", + "pixelsize":11, + "text":"Test:\nWalk on bottom carpet\nResult:\nA series of 2 popups open. A bubble opens. The player cannot move until popup closes.\nWhen the player leaves the zone, the bubble closes.\nIn the console, deprecation warnings MUST be displayed", + "wrap":true + }, + "type":"", + "visible":true, + "width":252.438, + "x":-1.71899999999999, + "y":163.5 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + }], + "nextlayerid":8, + "nextobjectid":5, + "orientation":"orthogonal", + "properties":[ + { + "name":"script", + "type":"string", + "value":"deprecated_script.js" + }], + "renderorder":"right-down", + "tiledversion":"2021.03.23", + "tileheight":32, + "tilesets":[ + { + "columns":11, + "firstgid":1, + "image":"tileset1.png", + "imageheight":352, + "imagewidth":352, + "margin":0, + "name":"tileset1", + "spacing":0, + "tilecount":121, + "tileheight":32, + "tilewidth":32 + }], + "tilewidth":32, + "type":"map", + "version":1.5, + "width":10 +} \ No newline at end of file diff --git a/maps/tests/deprecated_script.js b/maps/tests/deprecated_script.js new file mode 100644 index 00000000..4a889a8a --- /dev/null +++ b/maps/tests/deprecated_script.js @@ -0,0 +1,79 @@ +console.log('SCRIPT LAUNCHED'); +//WA.sendChatMessage('Hi, my name is Poly and I repeat what you say!', 'Poly Parrot'); +var isFirstTimeTuto = false; +var textFirstPopup = 'Hey ! This is how to open start a discussion with someone ! You can be 4 max in a booble'; +var textSecondPopup = 'You can also use the chat to communicate ! '; +var targetObjectTutoBubble ='myPopup1'; +var targetObjectTutoChat ='myPopup2'; +var popUpExplanation = undefined; +function launchTuto (){ + WA.openPopup(targetObjectTutoBubble, textFirstPopup, [ + { + label: "Next", + className: "popUpElement", + callback: (popup) => { + popup.close(); + + WA.openPopup(targetObjectTutoChat, textSecondPopup, [ + { + label: "Open Chat", + className: "popUpElement", + callback: (popup1) => { + WA.sendChatMessage("Hey you can talk here too ! ", 'WA Guide'); + popup1.close(); + WA.restorePlayerControls(); + } + } + + ]) + } + } + ]); + WA.disablePlayerControls(); + +} +WA.onChatMessage((message => { + console.log('CHAT MESSAGE RECEIVED BY SCRIPT'); + WA.sendChatMessage('Poly Parrot says: "'+message+'"', 'Poly Parrot'); +})); + +WA.onEnterZone('myTrigger', () => { + WA.sendChatMessage("Don't step on my carpet!", 'Poly Parrot'); +}) + +WA.onLeaveZone('popupZone', () => { +}) + +WA.onEnterZone('notExist', () => { + WA.sendChatMessage("YOU SHOULD NEVER SEE THIS", 'Poly Parrot'); +}) + +WA.onEnterZone('popupZone', () => { + WA.displayBubble(); + if (!isFirstTimeTuto) { + isFirstTimeTuto = true; + launchTuto(); + } + else popUpExplanation = WA.openPopup(targetObjectTutoChat,'Do you want to review the explanation ? ', [ + { + label: "No", + className: "popUpElementReviewexplanation", + callback: (popup) => { + popup.close(); + } + }, + { + label: "Yes", + className: "popUpElementReviewexplanation", + callback: (popup) => { + popup.close(); + launchTuto(); + } + } + ]) +}); + +WA.onLeaveZone('popupZone', () => { + if (popUpExplanation !== undefined) popUpExplanation.close(); + WA.removeBubble(); +}) diff --git a/maps/tests/index.html b/maps/tests/index.html index af70151e..2a27e78f 100644 --- a/maps/tests/index.html +++ b/maps/tests/index.html @@ -42,12 +42,12 @@ Testing scripting API with a script - + - Success Failure Pending + Success Failure Pending - Testing scripting API with a script + Testing goToPage script Api @@ -58,6 +58,14 @@ Testing scripting API loadSound() function + + + Success Failure Pending + + + Testing scripting API deprecated function + + Success Failure Pending diff --git a/maps/tests/script.js b/maps/tests/script.js index 4a889a8a..b300700f 100644 --- a/maps/tests/script.js +++ b/maps/tests/script.js @@ -7,21 +7,21 @@ var targetObjectTutoBubble ='myPopup1'; var targetObjectTutoChat ='myPopup2'; var popUpExplanation = undefined; function launchTuto (){ - WA.openPopup(targetObjectTutoBubble, textFirstPopup, [ + WA.ui.openPopup(targetObjectTutoBubble, textFirstPopup, [ { label: "Next", className: "popUpElement", callback: (popup) => { popup.close(); - WA.openPopup(targetObjectTutoChat, textSecondPopup, [ + WA.ui.openPopup(targetObjectTutoChat, textSecondPopup, [ { label: "Open Chat", className: "popUpElement", callback: (popup1) => { - WA.sendChatMessage("Hey you can talk here too ! ", 'WA Guide'); + WA.chat.sendChatMessage("Hey you can talk here too ! ", 'WA Guide'); popup1.close(); - WA.restorePlayerControls(); + WA.controls.restorePlayerControls(); } } @@ -29,32 +29,32 @@ function launchTuto (){ } } ]); - WA.disablePlayerControls(); + WA.controls.disablePlayerControls(); } -WA.onChatMessage((message => { +WA.chat.onChatMessage((message => { console.log('CHAT MESSAGE RECEIVED BY SCRIPT'); - WA.sendChatMessage('Poly Parrot says: "'+message+'"', 'Poly Parrot'); + WA.chat.sendChatMessage('Poly Parrot says: "'+message+'"', 'Poly Parrot'); })); -WA.onEnterZone('myTrigger', () => { - WA.sendChatMessage("Don't step on my carpet!", 'Poly Parrot'); +WA.room.onEnterZone('myTrigger', () => { + WA.chat.sendChatMessage("Don't step on my carpet!", 'Poly Parrot'); }) -WA.onLeaveZone('popupZone', () => { +WA.room.onLeaveZone('popupZone', () => { }) -WA.onEnterZone('notExist', () => { - WA.sendChatMessage("YOU SHOULD NEVER SEE THIS", 'Poly Parrot'); +WA.room.onEnterZone('notExist', () => { + WA.chat.sendChatMessage("YOU SHOULD NEVER SEE THIS", 'Poly Parrot'); }) -WA.onEnterZone('popupZone', () => { - WA.displayBubble(); +WA.room.onEnterZone('popupZone', () => { + WA.ui.displayBubble(); if (!isFirstTimeTuto) { isFirstTimeTuto = true; launchTuto(); } - else popUpExplanation = WA.openPopup(targetObjectTutoChat,'Do you want to review the explanation ? ', [ + else popUpExplanation = WA.ui.openPopup(targetObjectTutoChat,'Do you want to review the explanation ? ', [ { label: "No", className: "popUpElementReviewexplanation", @@ -73,7 +73,7 @@ WA.onEnterZone('popupZone', () => { ]) }); -WA.onLeaveZone('popupZone', () => { +WA.room.onLeaveZone('popupZone', () => { if (popUpExplanation !== undefined) popUpExplanation.close(); - WA.removeBubble(); + WA.ui.removeBubble(); })