Jump to content


YellowAfterlife

Member Since 28 Jan 2010
Offline Last Active Private

Topics I've Started

[Extension] Dynamic JavaScript

22 May 2012 - 06:40 AM

Download: http://www.solidfile...m/d/12f3a87f53/
Blog post: (link)

This extension uses fact that JavaScript functions can be legally created from string to open a 'gate' from GameMaker:HTML5 (and HTML5 runner of Studio) to JavaScript.
To explain it simple, think of it as execute_string variant. Except in other language. And at times more powerful than GML.
Installation: Include extension in project.

Functions:
dj_init - resets all currently loaded functions in extension.
dj_add(name, code) - adds a new function to index.
Index can be both number or string.
Parameter 'code' is JavaScript code, to be contained in function.
Code can be also created dynamically (same as you would do with execute_string)
dj_call(name) - calls loaded function, returning it's value.
dj_addN(index, ..., code) - similar to dj_add, but allows to specify names of parameters.
With those, you will be able to access them by given names in function.
dj_callN(index, ...) - to be used in pair with above, calls function, providing it given parameters.
dj_exists(index) - returns if a function is bound to given index.
dj_count() - returns total number of functions loaded at the moment.
dj_run(code) - creates and executes piece of code without storing it anywhere. Is intended to be used with functions that are used only once through the game or are not worth storing.

Examples:
Add line of text to GameMaker debug console:
dj_run("document.getElementById( 'debug_console').value += 'Found by JavaScript.\n';")
Create and use a function to change page's background color:
dj_add3('color', 'r', 'g', 'b', "document.body.style.backgroundColor = 'rgba('+r+ ','+g+ ','+b+ ',1)';");
dj_call3('color', 64, 64, 64);
Create function from concatenated strings:
index = 'some'
dj_add('get_' + index, "return '" + index + "';")
show_message(dj_call('get_some'))

Remarks:
* It is quite easy to crash your game with this extension, since errors are not handled anyhow by default.
I've actually removed that because it was hard to determine why something was not working with errors being ignored silently.
JavaScript errors are sent to debug console, which can be accessed in Chrome and Internet Explorer by pressing F12, Ctrl+Shift+I in Opera, and F12 in Firefox after installing Firebug or equivalent extension.
* Other loaded functions can be accessed as 'dj_data[index](...)'.
* It is recommended that you do not include line breaks in loaded code (either wrap lines by "'+(next line)+'", or string_replace_all them) - mis-matches in string format between loaded string and game itself may cause errors.
* While this allows 'dynamic' code, there is no defined way to access in-game resources without embedding them into functions or passing them as arguments.

YellowAfterlife's blog

25 February 2012 - 12:09 PM

Posted Image
yal.cc


So, this is my site. And blog. Mainly blog.
It contains (in order of frequency):
  • Examples & scripts for GameMaker
  • Posts about my developments
  • Reviews
  • Resources
  • Examples for other programming languages, and\or using them with GameMaker
Also I update it often. Rather often, except for times when volume of things to do does not allow writing posts.

Being the third re-creation of my site, I can say that I'm doing most things right this time.

Feedback & comments are welcome.

[contribution] GameMaker resource packs refactored

19 January 2012 - 07:26 PM

(also see blog post here)

Basically, if you have ever downloaded resource packs from YoYoGames - Sandbox - Make - Resources - Official, you might have noticed that they contain some amount of useful resources, however on practice these take some amount of time to edit before you can plug them into the game.
Since I've faced same thing multiple times, I've made a edit of these packs, which combines (sorted & categorized) usable resources from all 5, includes some fixes for tilesets and sprites, adds naming prefixes (i.e. if tileset is named 32x_*, you can tell that single tile dimensions are 32x32px), and other things to make it more practical.

Download: (SolidFiles)
Readme.txt in top level of archive lists all changes and other things that you might want to know.

Have a nice day.
Comments are probably welcome.

GM:HTML5 Theme - NRoom

18 December 2011 - 01:55 AM

Theme name: NRoom
Download: download (25KB)
Screenshot:
Posted Image
Description: Similar to my previous contribution, this is an adaptation of Ubuntu theme.
This time, theme of choice was 'DarkRoom', which received fair amount of edits and a green color.
I haven't yet developed a separate coder editor color scheme for this yet, so it comes with scheme based on "Zenburn" color scheme for Akelpad.

I believe that this is a decent (smoother, well-colored) replacement for standard 'GMGreen' theme.

Feedback is welcome.
Hopefully this theme will receive more than 2 downloads in next days.

GM:HTML5 Theme - ClearLooks Green

16 December 2011 - 10:44 PM

Theme name: ClearLooks Green
Download: download (25KB)
Screenshot:
Posted Image
Description:

A very precise port of liked theme configuration of Ubuntu (components: "ClearLooks"; window border: "Human"; custom colors).
Supports all existing components. Comes with code editor color scheme (best viewed with "Consolas" 8..10pt font and "Use BOLD on script keywords").

Technical:
Spoiler

Comments and feedback are welcome.
You know, the longer you work on something, the more they matter.