Site  •  Wiki  •  FAQ  •  Login

Plugin Language

<<

AofST

User avatar

Posts: 183

Joined: June 7th, 2009, 9:53 pm

Location: In the End of the World News

Post January 25th, 2010, 2:17 pm

Plugin Language

I was thinking of developing a php style triggering language so that making plugins is easier.

The point is to make creating plugins as intuitive and easy as possible; similar to how triggers are coded.

I've mainly been developing the language style of this new idea, and this is what I've come up with:

  Code:
/* Globals */
//--The player's gas and resources will be globals
gas[]
   /*
   Takes a numerical value as a parameter.
   Ex.
      for(playerID=0; playerID < 8; playerID++)
      {
         gas[playerID]++;
      }
   */
minerals[]
   /*
   Takes a numerical value as a parameter.
   */


/* The query funcion */
query()
   /*
   Takes a command as a parameter.
      The command is set up as such:
         'SEARCH _table_name_ for _condition_'
   Returns an array of pointers
   
   Ex.
      $result = query('SEARCH UNIT for health=256'); //Returns an array of unit structs
      $result[0]->health++;
   */
count()
   /*
   Takes a query() as a parameter
   Returns the amount of items in the array
   
   Ex.
      $result = query('SEARCH UNIT for health=256');
      $total = count($result); //Returns number of units whose health is 1.
   */
   
   
/* Extra functions */
print(text, attributes)
   /*
   Takes text as parameter and optional attributes
   
   Ex.
      print('Hello World', red);
   */
sound()
   /*
   Takes a number or wav string as a parameter
   
   Ex.
      sound(23);
   */

patch()
   /*
   Takes no parameters
   Returns patch version as string
   */
   
//Example Script
/*
When compiled, this script will run every frame and give 100 minerals for each marine to the player that owns them
*/

$result = query('SEARCH UNIT for unitID=0');
for($total = 0; $total < count($result); $total++) {
   minerals[$result[$total]->playerID] += 100;
}

/*
This is the same script without the new language markup
*/

bool nextFrame() {
   UNIT*               unit;
   for(unit = &unitTable[0]; unit <= &unitTable[1700]; unit++) {
      if (unit->unitId == 0) {
         resources->playermin[unit->playerId] += 100;
      }
   }
}

/*
Clearly, the new markup is much more intuitive and quicker.
With the new query function, the frequency of using if statements lessens and the number of lines is reduced.
*/


Any ideas, questions, comments, concerns?
Support my new site:
http://ideabirth.co.cc/
<<

Hydrolisk

User avatar

Posts: 165

Joined: June 17th, 2009, 2:42 pm

Location: Peak of the spire.

Post January 27th, 2010, 9:58 pm

Re: Plugin Language

Could you further elaborate on the examples and what the code is doing? As of now, I see the objective of the language and I see how it can be more efficient, and I am interested in its future development. I can't say much more than that, though.
Am I correct in thinking the language you are creating simplifies the coding process by allowing modders to use different, shorter, expressions to the same effect as traditional plug-in code?
<<

Hercanic

User avatar

Site Admin

Posts: 478

Joined: June 6th, 2009, 12:25 am

Location: Korea

Post January 27th, 2010, 11:53 pm

Re: Plugin Language

My initial interpretation was a way to present plugin writting in a user-friendly manner through PHP -- something like a website with dropdown selections and variable fields to construct plugin arguments without needing to know actual coding, like map triggering. Is that accurate, or is it more like what Hydrolisk is thinking?
<<

AofST

User avatar

Posts: 183

Joined: June 7th, 2009, 9:53 pm

Location: In the End of the World News

Post January 28th, 2010, 4:15 pm

Re: Plugin Language

The point would be to create a very flexible language: easy enough for beginners, but advanced enougn for experts. If I feel ambitious enough, I will create drop down menus and such, untill then, im mainly going to parse the new language into c++ and create a plugin with that.
Support my new site:
http://ideabirth.co.cc/

Return to Discuss

Who is online

Users browsing this forum: No registered users and 1 guest

cron
phpBBST Software