Docs: Difference between revisions
Appearance
m added more vars |
mNo edit summary |
||
| Line 15: | Line 15: | ||
!Description | !Description | ||
!Example Usage | !Example Usage | ||
!Code | !Code In Use | ||
|- | |- | ||
|YourWorld | |YourWorld | ||
| Line 226: | Line 226: | ||
|<syntaxhighlight lang="javascript" line="1" start="61"> | |<syntaxhighlight lang="javascript" line="1" start="61"> | ||
var nextObjId = 1; | var nextObjId = 1; | ||
</syntaxhighlight> | |||
|- | |||
|owotWidth, | |||
owotHeight | |||
|The current width and height of the DOM window. | |||
|<syntaxhighlight lang="javascript"> | |||
//Estimate the total number of fully visible cells that could exist on the screen | |||
const cellAmount = Math.floor(owotHeight/cellH * owotWidth/cellW); | |||
</syntaxhighlight> | |||
|<syntaxhighlight lang="javascript" line="1" start="1170"> | |||
owotWidth = Math.round(window_width * ratio); | |||
owotHeight = Math.round(window_height * ratio); | |||
</syntaxhighlight> | |||
|- | |||
|js_alert_active | |||
|A bool stating if the javascript alert window is open. | |||
| | |||
|<syntaxhighlight lang="javascript" line="1" start="64"> | |||
var js_alert_active = false; | |||
</syntaxhighlight> | |||
|- | |||
|worldFocused | |||
|A bool stating if the owot canvas is in focus. | |||
|<syntaxhighlight lang="javascript"> | |||
//check every 100ms if the owot canvas was last clicked, if it was then randomly change the public tile color. | |||
setInterval(function() { | |||
if (worldFocused) { | |||
styles.public = "#" + Math.floor(Math.random() * 16777215).toString(16).toUpperCase(); | |||
w.redraw() | |||
} | |||
}, 100) | |||
</syntaxhighlight> | |||
|<syntaxhighlight lang="javascript" line="1" start="1737"> | |||
if(closest(target, getChatfield()) || target == elm.chatbar || target == elm.confirm_js_code) { | |||
worldFocused = false; | |||
} else { | |||
worldFocused = true; | |||
} | |||
</syntaxhighlight> | |||
|- | |||
|chatResizing | |||
|A bool stating if the chat window is being resized. | |||
|<syntaxhighlight lang="javascript"> | |||
//check every 100ms if the chat is resizing, if it is, change the public tile color | |||
setInterval(function() { | |||
if (chatResizing) { | |||
styles.public = "#" + Math.floor(Math.random() * 16777215).toString(16).toUpperCase(); | |||
w.redraw() | |||
} | |||
}, 100) | |||
</syntaxhighlight> | |||
|<syntaxhighlight lang="javascript" line="1" start="441"> | |||
draggable_element(elm.chat_window, null, [ | |||
elm.chatbar, elm.chatsend, elm.chat_close, elm.chat_page_tab, elm.chat_global_tab, elm.page_chatfield, elm.global_chatfield | |||
], function() { | |||
if(chatResizing) { | |||
return -1; | |||
} | |||
}); | |||
</syntaxhighlight> | |||
|- | |||
|tiles | |||
|An object containing all the loaded tiles. | |||
|<syntaxhighlight lang="javascript"> | |||
//Return any visible links | |||
const [X,Y] = cursorCoords; | |||
tiles[`${X},${Y}`].properties.cell_props | |||
</syntaxhighlight> | |||
|<syntaxhighlight lang="javascript" line="1" start="1416"> | |||
Tile.set = function(tileX, tileY, data) { | |||
var str = tileY + "," + tileX; | |||
if(!(str in tiles)) { | |||
w.tile.count++; | |||
} | |||
tiles[str] = data; | |||
expandLocalBoundary(tileX, tileY); | |||
return data; | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
|} | |} | ||