Jump to content

Replace erroneous entity script function ending comment ]]-- with --]]


Lunarovich
 Share

Recommended Posts

When created, every entity script starts with a code like this:

 

--[[
function Script:Start()

end
]]--

--[[
function Script:UpdateWorld()

end
]]--

--[[
function Script:UpdatePhysics()

end
]]--

-- etc.

 

Now, according to PIL, a common trick to comment out a block of code goes like this

 

--[[
print(10)		 -- no action (comment)
--]]

 

If we add a hyphen to the first comment line, we get this:

 

---[[
print(10)		 --> 10
--]]

 

Unfortunately, with a LE current default comment, we cannot do this. That's because the author of the default script was thinkng of Lua comments in the vein of C++ /* and */, which is, however, a wrong approach, since Lua comments do not function in that way. So, if you add a hyphen, you'll get this:

 

---[[
function Script:Start()
end
]]--

--[[
function Script:UpdateWorld()

end
]]--

--[[
function Script:UpdatePhysics()

end
]]--

-- etc.

 

and that's obviously unwanted and error-generating result, since Lua does not know what to do with ]] part of the ]]--. So, please correct this, so we can quickly comment out entity functions.

 

Thanks.

  • Upvote 2
Link to comment
Share on other sites

You can actually do this yourself if you like.

 

It's simply one of the template scripts. You can find it here:

{your Leadwerks install dir}\Templates\Common\Scripts\Objects\Cameras\New script.lua

This script is the template loaded when you click the "New\Script" popup menu item.

 

NOTE: There is at least two other script templates that employ this erroneous convention (could be more, didn't really check all) - the other script in that same directory as above (3rdPersonFollow.lua) as well as the following:

{your Leadwerks install dir}\Templates\Common\Scripts\AnimationManager.lua

 

So if you want to correct all of them, you could use Notepad (or your favorite text editor) and do a search/replace on all the script template files for the occurance of "]]--" with "--]]".

Link to comment
Share on other sites

You don't have to do it "each" time. It's a one time thing. After you edit those entries, then Leadwerks simply copies them in to the data when you create a new project.

 

You "might" have to modify them again after a Leadwerks update. Just depends on if it makes changes to the template files with a new upgrade.

  • Upvote 1
Link to comment
Share on other sites

Whoa I had no idea you could do that.

Yea, its a pretty common thing with most development tools. Just about all of them have template files for things like "new project" or "comment insertion", etc. At least that's been my experience over my 36 years of development. For example, both Microsoft Visual C++ and Embarcadero RAD Studio have that feature. Many other product do as well, so its not surprising it can be done here too.

 

Sometimes they are simply text files, other times XML, and sometimes proprietary but proprietary data files (DBs or otherwise) have become pretty unpopular with developers since we always want ways to make our job easier. LOL

 

Game development is a new area for me, I'm used to building low level system tools, utilities, and other applications. Leadwerks appears to be a nice platform for wetting my appetite with game dev. :)

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.
Note: Your post will require moderator approval before it will be visible.

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.

 Share

×
×
  • Create New...