can construct 2 allow code in the game

0 favourites
  • 5 posts
From the Asset Store
Casino? money? who knows? but the target is the same!
  • I want to build a game that allow players to code in the game, but i do not know is that possible

  • I want to build a game that allow players to code in the game, but i do not know is that possible

    You are probably going to need to provide more information about what you mean. What you have asked is very vague.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • > I want to build a game that allow players to code in the game, but i do not know is that possible

    >

    You are probably going to need to provide more information about what you mean. What you have asked is very vague.

    I am trying to make a game that allow the players to write code in order to progress the game. i.e. This game is like "code in game". What I want is to let players code in a text box and compile what they coded then give some feedback to them. Simulating what compiler do but using game to present this. BTW the statement that below your answer was really nice. XD

  • You could run the contents of the editbox as JavaScript using the browser object's execjs action. That is the simplest but the feedback would basically just be a return value. I suppose you could add some functions that call c2 functions to provide more feedback. But arbitrarily running js is an issue since absolutely any js can be run, which can be an issue.

    You can look at the browser and function objects in the manual to see what I talk about above.

    A more advanced thing you could do is make your own parser that reads the editbox a character at a time to do your own coding language. This gives much more control or what can and can't be done by the user. This can be as complex or as simple as you like. Probably not easy if it's not something you've done before.

    I've done some expression parsers before that you can find on the forum, but reading outside sources may be more useful.

    I guess it depends on what you actually want the code to do specifically and look like specifically.

  • Here is a sample capx of loading external js file then executing these js code.

    It is easy to modify this capx, to get js code from textbox.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)