• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Dryden Richardson · Mar 06, 2011 at 10:29 PM · runtime

Allowing Players To Code INSIDE your games?

Hi, i'm just wondering if it's possible to allow players to code inside your games, for example, say you made a game like second life, the reason why second life is still here today is because it is run by the players, they can build and code with Linden Lab's special programming language.

Can someone tell me if this is possible?

Example (Java) Someone codes a box to move away when approached.

Example (Java) Someone codes a box to change colors.

Thanks for reading.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Legoperson2 · Mar 06, 2011 at 11:47 PM 0
Share

That is an incredible idea, although I have no idea about how to do that, I would imagine it to be very difficult. If you wanted to have full control of unity type programs, you would have to make it so that the user can go into a script, then it would need to be compiled and then installed. It would be incredible if this was possible, but it seems extremely difficult and computationally intensive to allow the players to actually change a program. Depending on the complexity, it might be possible for you to write a script to check what the user has entered and then you create functions based on what the user has entered that activate certain elements of the game.

Even very, very basic coding would probably work and would be quite enjoyable on a mobile device.

avatar image Eric5h5 · Mar 07, 2011 at 12:32 AM 0
Share

Please use reasonable tags. Also, Unity doesn't use Java.

4 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by Statement · Mar 07, 2011 at 12:16 AM

Either you can allow C# and compile the code on the fly or you can use some scripting language such as lua, angelscript, python or make your own (this book teaches you to make a full scriptable language). Scripts would be run by some interpreter or virtual machine, usually provided as a library for the different languages. To create a virtual machine is pretty trivial, even making an assembler is quite easy. The hard part if you want to create your own language is the high level language since you have to keep quite a lot of things in mind.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bravini · Mar 07, 2011 at 01:44 AM 0
Share

that would make a good product for asset store

avatar image
2

Answer by Eric5h5 · Mar 07, 2011 at 12:35 AM

You can use eval() in Javascript, but that leaves really huge security holes open, so you'd better not. Better to implement your own scripting language.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by yoyo · Mar 07, 2011 at 05:38 AM

lua is a small, free, open source scripting language that has frequently been used in game engines. This project seeks to integrate it with .NET, which could be helpful for use from Unity.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image anomalous_underdog · Mar 08, 2011 at 03:37 AM 0
Share

So.. where's the download link for Lua .NET in that page? Is Lua .NET open source?

avatar image yoyo · Mar 08, 2011 at 05:10 AM 0
Share

Looks like the project, or part of it, is hosted here -- http://code.google.com/p/luainterface/

avatar image yoyo · Mar 08, 2011 at 05:11 AM 0
Share

Seems to be the same project you've already been working with ...

avatar image
0

Answer by anomalous_underdog · Mar 07, 2011 at 05:58 AM

I was able to make Lua run inside Unity using LuaInterface 1.5.3.

With this, you can let players add lua scripts as code. The hard part is having to expose your game's innards to Lua so players can modify your game to the extent that you want.

See forum post here: http://forum.unity3d.com/threads/53199-Using-Lua-scripting-in-Unity

Ok, after some fiddling, the good news, I got it working. The bad news, not with the latest version of LuaInterface, but with version 1.5.3, the last 1.x version.

Versions I've tried and failed to make it work: 2.0.1, 2.0.3

Versions I've tried and made it work: 1.2, 1.3.0, 1.4.0*, 1.5.3

*: the lua dlls supplied in 1.4.0 were not being recognized, so I simply used the lua dlls from 1.3.0 to make it work, but the LuaInterface code version 1.4.0 works

To make it work in the Unity Editor, the main lua dll plus an additional luanet.dll has to be somewhere Unity can find. In Windows, I copied them to the folder where Unity.exe resides. Additionally, to make it work on standalone release builds, those two dlls have to be somewhere your .exe file can find. The easiest is to copy them to the same folder where the .exe file is. I assume for Mac standalones you have to do something similar.

The downloadable 1.x versions of LuaInterface also come with its source code bundled along, so you can use the source code version of LuaInterface if you don't want it as a dll.

LuaInterface153Test.unitypackage: http://forum.unity3d.com/attachment.php?attachmentid=17063&d=1296335390

I'm in the process of turning this into a package for the asset store, watch out for it!

UPDATE: Here's a link: http://u3d.as/content/anomalous-underdog/unity-lua-interface-library/1AY

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DaveA · Feb 11, 2012 at 01:25 AM 0
Share

It's very very dangerous. Unless you prohibit certain actions. They could script all sorts of bad behaviour, including viruses, trojans, s$$anonymous$$l data, corrupt files, all the bad things. PLEASE be careful.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Export objects to a .3DS file at runtime 1 Answer

LoadImageIntoTexture Runtime Change 1 Answer

Assigning sharedMaterial to object built at runtime 2 Answers

INDECIPHERABLE rendering order problem when modifying material property on Runtime 1 Answer

Am I inside a volume? (Without ray cast and default colliders?) 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges