stuffradio Posted November 19, 2007 Share Posted November 19, 2007 Is it possible to hack php to make it so you can write a little mini type language for Browser based games? I don't know how to explain it exactly... but just write something that lets you write some things, and certain things will happen in the game. Quote Link to comment Share on other sites More sharing options...
trq Posted November 19, 2007 Share Posted November 19, 2007 You could write a simple language using php, nothing to do with hacking php's core though. Quote Link to comment Share on other sites More sharing options...
stuffradio Posted November 19, 2007 Author Share Posted November 19, 2007 How would I do that? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 19, 2007 Share Posted November 19, 2007 Looks like you need some tutorials http://www.w3schools.com/php/default.asp www.tizag.com Quote Link to comment Share on other sites More sharing options...
stuffradio Posted November 19, 2007 Author Share Posted November 19, 2007 Those tutorials have nothing to do with what I want to do. I already know PHP, I just don't know how to give people custom commands that would allow them to do some special things. Textarea: Foobar - "Make room on x page" Foobar - "Change Title of page to 'Titlename'" Foobar - "I want to battle x" etc. I want to write something that allows users to write some easy to use language that won't hack the site, yet give users the feeling they're coding on the site. Quote Link to comment Share on other sites More sharing options...
trq Posted November 19, 2007 Share Posted November 19, 2007 There really is lots of ways of doing such a thing. It really depends on what you want and how far you want to take it. Think outside the square a little. Given a textarea with... /cmd foo bar bob /say hello there in it. Something like.... <?php function foo() { echo "this is foo"; } function bar() { echo "this is bar"; } function bob() { echo "this is bob"; } if (isset($_POST['textarea'])) { $lines = explode("\n", $_POST['textarea']); foreach ($lines as $line) { $cmds = explode(" ", $line); if (current($cmds) == '/cmd') { next($cmds); foreach ($cmds as $cmd) { $cmd(); } } elseif (current($cmds) == '/say') { next($cmds); echo implode(" ",$cmds); } } } ?> might parse it. We really can't describe how to build your language. Hope this simple example gives you some ideas though. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 19, 2007 Share Posted November 19, 2007 why you gotta go reinvent the wheel. This has been done with BBCode so to speak, and cms like joomla and so forth, if you want to design a cms then do it, but don't try and make a complex system for no reason Quote Link to comment Share on other sites More sharing options...
stuffradio Posted November 20, 2007 Author Share Posted November 20, 2007 thanks for now thorpe... it's the same idea as a MUD I had to make for my Java programming class I took last year. Using an iterator and parsing through the text. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.