• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code Drag and drop from GMS1.4 to 2 not converting right

quattj

Member
I have a game project from GMS1.4. It uses a mixture of drag & drop and code.

Why is GMS2 converting my old drag & drop "if" blocks into code that looks like this?
Code:
var __b__;
__b__ = action_if_variable(land, 0, 0);
if __b__
{
direction += random(20)-10;
}
This is a drag and drop if statement that logically should be easily converted upon import in to:
Code:
if (land == 0)
{
  direction += random(20)-10;
}
(or just left as a drag and drop object)

The "land" variable is set in the create event.

I have 531 objects, a large portion of which use drag & drop if statements around blocks of code. Currently, the converted file is a giant mess wherever these blocks are present.
 

rwkay

GameMaker Staff
GameMaker Dev.
This is exactly how the 1.4 DnD code works (it is converted to GML code in exactly this way) and yes they are obsolete functions now (and replaced by compatibility scripts if they are found to be used) as you should find when you import any older code into GMS2, so the documentation is not incorrect.

Russell
 

quattj

Member
If that is in fact the case, I think we need to add a feature to convert it either directly in to the new drag and drop style, or convert it logically in to what it should be.

if (land == 0)

This is exactly what the drag and drop box of old SHOULD be doing, and this is what the code for it SHOULD look like after conversion (and consequently, if that's how 1.4 handled it I see why you chose to completely rewrite from scratch)
 

rwkay

GameMaker Staff
GameMaker Dev.
We have no plans for doing any conversion of 1.4 DnD to 2.0 DnD, while they are similar the fundamentals are quite different and we have a lot of other higher priority items in the pipeline.

Russell
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
If you want to fix up particularly problematic bits of DnD, I made a tool that offers a cleaner conversion: https://yellowafterlife.itch.io/gmvisualizer

The difference is that instead of converting DnD to the according function calls (which is how things actually work), it has specifically written "templates" for every DnD action that it fills out on conversion.

It'll still look nasty if you had stuff like if-conditions with "apply to" set, but it generally looks better.
 

quattj

Member
If it will not convert to drag and drop, can there at least be a more sensible conversion? It's a really basic if statement. There's no need for it to be super complicated. Sure I can go through all 500+ objects in my game and find every single instance of the converted if blocks, delete all the unnecessary extraneous additions, and resave it all, but there has to be a much simpler way. I understand not all old drag and drop objects will convert to nice code, but the more basic ones should.

Even when I click on the "show information" tab of my object in GMS 1.4, it shows this for that same if block:

if land is equal to 0

so why can't GMS 2 just do that except with symbols instead, instead of declaring a new variable, assigning it to a compatibility function, then checking the value of the compatibility function instead of the variable that already existed in the first place?

A "var" block converts to the exact code you would expect. I have a "var" block that sets "blocktype" to "1" It gets converted in GMS 2 to

blocktype = 2;

No fuss, no muss.
 

rwkay

GameMaker Staff
GameMaker Dev.
Unfortunately the underlying mechanism for the 1.4 DnD is not as easily converted in the general case as you imply and be 100% compatible and frankly we have better things to do for the future. There are other tools out there that can be used (as YellowAfterLife has pointed out above) if you really want it to be nicely done then I would suggest you use those.

Russell
 
Top