Join the forums now, and start posting to receive access to our Scripts Vault!
function parse_template(url,rData) { $.ajax({ type: 'POST', url: url, data : rData, success: function(response) { if(typeof(response) != 'object') { response = "("+response+")"; } cObj = eval(response); if(cObj.view != false) { cEjs = new EJS({url: cObj.view}).render(cObj.vars); $("#"+cObj.destination).html(cEjs); cEjs = ''; } } });}
$r['view'] = '/path/to/your/ejs/file.ejs';$r['destination'] = 'id of your html element';$r['data'] = $your_php_data_array;echo json_encode($r);
<ul><% for(var i=0; i<supplies.length; i++) {%> <li><%= supplies[i] %></li><% } %></ul>
Lets think about it. You are sending all, sector, maze, map data into client. And generate output from this data. For example, walking in the maze, searching start sectors etc.In my case, I send, entire star sector data (2.5 mb (after 5mb browser had crash)), which has 100 star systems and every star system and planet was different. Players can sweep entire sector without generating any server requests (except images).
Yes, let's think about it indeed.As a player, I now have all the game data in my hands. I don't have to explore the sector through the game interface, I can dump the data to disk and write a trivial script to rummage through the data directly and, within a matter of milliseconds, tell me exactly where the richest/least-defended/whatever locations are so I can head there directly.