Hacking Blaxxun multiuser VRML for offline use: Difference between revisions
No edit summary |
m (Fixed formatting) |
||
Line 8: | Line 8: | ||
Worlds will often define on their own what a <code>SharedEvent</code> is, using code copied-and-pasted. The definition begins with <code>PROTO SharedZone</code>. | Worlds will often define on their own what a <code>SharedEvent</code> is, using code copied-and-pasted. The definition begins with <code>PROTO SharedZone</code>. | ||
If the definition defines <code>local</code>, you're in luck, and you just need to change it as follows | If the definition defines <code>local</code>, you're in luck, and you just need to change it as follows: | ||
<pre> | <pre> | ||
PROTO SharedEvent [ | PROTO SharedEvent [ | ||
Line 16: | Line 15: | ||
field SFBool debug FALSE | field SFBool debug FALSE | ||
</pre> | </pre> | ||
change <code>local FALSE</code> to <code>local TRUE</code>, so it reads as follows: | change <code>local FALSE</code> to <code>local TRUE</code>, so it reads as follows: | ||
<pre> | <pre> | ||
PROTO SharedEvent [ | PROTO SharedEvent [ | ||
Line 26: | Line 23: | ||
field SFBool debug FALSE | field SFBool debug FALSE | ||
</pre> | </pre> | ||
and make sure the <code>SharedZone</code> doesn't have <code>local FALSE</code> in its <code>SharedEvent</code> usages. | and make sure the <code>SharedZone</code> doesn't have <code>local FALSE</code> in its <code>SharedEvent</code> usages. | ||
Line 34: | Line 30: | ||
Add the definition to the <code>PROTO</code>: | Add the definition to the <code>PROTO</code>: | ||
<pre> | <pre> | ||
PROTO SharedEvent [ | PROTO SharedEvent [ | ||
field SFBool local TRUE | field SFBool local TRUE | ||
</pre> | </pre> | ||
Find the <code>Script</code> node which should be after the <code>]{</code> that separates the PROTO's fields from its definition, and add <code>local</code> | Find the <code>Script</code> node which should be after the <code>]{</code> that separates the PROTO's fields from its definition, and add <code>local</code> | ||
<pre> | <pre> | ||
Script { | Script { | ||
field SFBool local IS local | field SFBool local IS local | ||
</pre> | </pre> | ||
Below that, after <code>url "vrmlscript:</code>, should be some code, including a block of up to 9 functions with similar names | Below that, after <code>url "vrmlscript:</code>, should be some code, including a block of up to 9 functions with similar names | ||
<pre> | <pre> | ||
function set_bool (value, time) { boolToServer = value; } | function set_bool (value, time) { boolToServer = value; } | ||
Line 64: | Line 55: | ||
function set_vec3f (value, time) { vec3fToServer = value; } | function set_vec3f (value, time) { vec3fToServer = value; } | ||
</pre> | </pre> | ||
It is | It is OK if they are in a different order or if some are missing, but be careful not to change other functions that might have similar names. | ||
Change that block of functions to: | Change that block of functions to: | ||
<pre> | <pre> | ||
function set_bool (value, time){ boolToServer = value; if(local){boolFromServer(value,time);}} | function set_bool (value, time){ boolToServer = value; if(local){boolFromServer(value,time);}} | ||
Line 82: | Line 71: | ||
function set_vec3f (value, time){ vec3fToServer = value; if(local){vec3fFromServer(value,time);}} | function set_vec3f (value, time){ vec3fToServer = value; if(local){vec3fFromServer(value,time);}} | ||
</pre> | </pre> | ||
Revision as of 06:50, 18 March 2021
VRML worlds designed for Blaxxun Contact were often intended to be used in a multiuser context. Without the Blaxxun server running, some things might not work as expected. Light switches might not toggle, minigames might not work properly, pool covers might not open. In their original context, the buttons to trigger these would send off events to the server, which would send a message back to everyone connected to the world at the time (or sometimes later), including the original person.
This page will hopefully explain how to hack VRML that uses Blaxxun multiuser features to work properly while offline.
Any world that uses Blaxxun multiuser features will have a node named SharedZone
, and hence have DEF SharedZone
somewhere. The SharedZone
will usually contain one or more SharedEvent
s. While this is not strictly necessary, it is the case most of the time, and anything outside of that is out-of-scope for this document.
Worlds will often define on their own what a SharedEvent
is, using code copied-and-pasted. The definition begins with PROTO SharedZone
.
If the definition defines local
, you're in luck, and you just need to change it as follows:
PROTO SharedEvent [ field SFBool local FALSE field SFBool debug FALSE
change local FALSE
to local TRUE
, so it reads as follows:
PROTO SharedEvent [ field SFBool local TRUE field SFBool debug FALSE
and make sure the SharedZone
doesn't have local FALSE
in its SharedEvent
usages.
If the SharedEvent
doesn't contain local
, you will need to add it yourself:
Add the definition to the PROTO
:
PROTO SharedEvent [ field SFBool local TRUE
Find the Script
node which should be after the ]{
that separates the PROTO's fields from its definition, and add local
Script { field SFBool local IS local
Below that, after url "vrmlscript:
, should be some code, including a block of up to 9 functions with similar names
function set_bool (value, time) { boolToServer = value; } function set_color (value, time) { colorToServer = value; } function set_float (value, time) { floatToServer = value; } function set_int32 (value, time) { int32ToServer = value; } function set_rotation (value, time) { rotationToServer = value; } function set_string (value, time) { stringToServer = value; } function set_time (value, time) { timeToServer = value; } function set_vec2f (value, time) { vec2fToServer = value; } function set_vec3f (value, time) { vec3fToServer = value; }
It is OK if they are in a different order or if some are missing, but be careful not to change other functions that might have similar names.
Change that block of functions to:
function set_bool (value, time){ boolToServer = value; if(local){boolFromServer(value,time);}} function set_color (value, time){ colorToServer = value; if(local){colorFromServer(value,time);}} function set_float (value, time){ floatToServer = value; if(local){floatFromServer(value,time);}} function set_int32 (value, time){ int32ToServer = value; if(local){int32FromServer(value,time);}} function set_rotation (value, time){ rotationToServer = value; if(local){rotationFromServer(value,time);}} function set_string (value, time){ stringToServer = value; if(local){stringFromServer(value,time);}} function set_time (value, time){ timeToServer = value; if(local){timeFromServer(value,time);}} function set_vec2f (value, time){ vec2fToServer = value; if(local){vec2fFromServer(value,time);}} function set_vec3f (value, time){ vec3fToServer = value; if(local){vec3fFromServer(value,time);}}