Jump to content
MakeWebGames

Converter helper tool - From V2 to NWE


a_bertrand

Recommended Posts

Some of you was looking for a tutorial how to convert McCode V2 mods to NWE. I thought, maybe it is possible to at least partially help the conversion, therefore I started to write down a little tool to help you guys. It will not produce a good NWE mod and I would say that most of the time the conversion made by the tool will not work, yet it helps for the first and most annoying steps like changing all the $db->query into $db->Execute and such.

The project is pretty much experimental, and may very well be improved over time, yet it's a start point:

http://www.nw-engine.com/index.php?c=mc2_converter

So what is supported:

- $userid => $userID

- $ir['something'] => $userStats['something']->value

- removes the include of global.php

- removes the $h->endpage

- mysql_query('something') => $db->Execute('something')

- $db->query('something') => $db->Execute('something')

- mysql_insert_id => $db->LastId()

- mysql_num_rows($q) => $q->NbRows

- $db->num_rows($q) => $q->NbRows

- item_add(...) => Item::InventoryAdd(...)

- item_remove(...) => Item::IventoryRemove(...)

- event_add(...) => SotrePersonalLog(...)

- Adds the Translate function around the echo and print strings.

So, for the time being, that's what it does. More functions can be added and things like get_rank can be either implemented as additional function automatically added to the converted code or an equivalent function can be added to the engine itself.

What it doesn't do:

- Convert the links / buttons

- Put the query values as parameters of the $db->Execute

- Uses the table header / table footer

- Generates the menu.php or whatever other files

- Convert the db structure

Let me know if you find it any useful, but don't expect to simply copy / paste your code there and have your mod fully working for NWE.

Link to comment
Share on other sites

This will help some quite a lot.

My tutorial will still appear however its peak season for me at my shop plus events/festivals at weekends so im doing what i can when i can.

I had a look at this and indeed dont expect a cut and paste job you will need to work through the conversion as on my test it also stripped out some = signs among other things.

But it will give you a good idea on how to change.

Until my tutorial appears then feel free to drop me a message if you wish if you get stuck or add to the post here

Link to comment
Share on other sites

I managed to implement yet another piece inside the mod converter. It shall add the Translate function around string which are used for echo or print. It shall extract also variables from it, however it will not keep the HTML outside of the translate yet. I may be able to do that too but for the time being it's not all that bad. Just for that it's 210 lines of code... But I'm happy... it shall handle PHP strings correctly. HEREDOC strings are currently skipped btw.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...