Welcome to Realtime Technologies Support Forum


  Reply to this topicStart new topicStart Poll

> Creating new tiles with sensors
dkidd3
Posted: Jul 8 2009, 10:20 AM
Quote Post


Member
**

Group: Members
Posts: 23
Member No.: 29
Joined: 15-March 07



Is it possible to create a custom tile that has proximity sensors such that the javascript file associated with the proximity sensor is exposed/editable after the tile has been published?
PMEmail Poster
Top
hstoner
Posted: Jul 9 2009, 06:08 AM
Quote Post


SimVista Forum Moderator
***

Group: Admin
Posts: 97
Member No.: 16
Joined: 5-September 06



Yes there is.

Create your visual world (tile) as you normally would. Then add in your proximity sensor. Next follow the instructions from the manaul (pg 15 in v2.28) on how to publish the scene as object into your SaveAsObjects. When you have the option to expose fields make sure the userScript field is exposed when you are saving the scene as a release object. Then when you drag it into a new scene from your object gallery you will have the userscript available to reference any javascript file.


PMEmail Poster
Top
dkidd3
Posted: Jul 17 2009, 08:50 AM
Quote Post


Member
**

Group: Members
Posts: 23
Member No.: 29
Joined: 15-March 07



If a sensor has been saved into a tile can it still be referenced to in the same manner in JavaScript?

For example, say I have two box proximity sensors named "EventSensor" and "TurnSensor". The javascript for "TurnSensor" references a variable named "startevent" that was created in the "EventSensor". This is done using the following code in the TurnSensor javascript:

newvariable = Scenario.EventSensor.startevent;

However, if I save both sensors as part of a larger tile do I still reference this variable the same?

My concern is now that the box sensor is now part of a larger object that it would lose its unique name and I would need to reference the entire tile that it is embodied in such as

newvariable = Scenario.NewLargeTile.startevent;

Can anyone provide any insight?
PMEmail Poster
Top
hstoner
Posted: Jul 17 2009, 11:18 AM
Quote Post


SimVista Forum Moderator
***

Group: Admin
Posts: 97
Member No.: 16
Joined: 5-September 06



Another approach you could take is to assign your variable to the global space. Then you do not have to worry about what sensor it came from.

For example, in one sensor say:

CODE

Scenario.localVar.VariableName = 5;


Then in all other sensors you can get or set the variable using the same name. It is no longer dependent on what sensor called it first.
PMEmail Poster
Top

Topic Options Reply to this topicStart new topicStart Poll

 



[ Script Execution time: 0.0332 ]   [ 10 queries used ]   [ GZIP Enabled ]