scripting java


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: scripting java

  1. #1
    Join Date
    Oct 2004
    Posts
    311

    scripting java

    Been a while since I've been here last, so I don't know if this has been discussed before.

    I'm currently working on a game where I need to setup a scripting engine. The scripting engine will be fed scripts which are defined by the user.
    Sample script:
    Code:
    encounter begin
      if (global('alarmrasied')=true)
        add(3,'goblin');
      endif;
      add(3,'goblin');
    end;
    Explenation:
    There is an encounter, when the alarm has been raised (this is stored in a global variable, when a trap is triggered), 3 goblins are added to the encounter. finally 3 golbins are added to the encounter whether the alarm has been raised or not.

    This script is provided in a text file, but the functionality has to be mapped to actual Java. I'm not quite sure how to do this. I was thinking of setting up an encounter class, with internal classes for each method. (these can then be accessed via a factory). But I'm not quite sure this is the way to go, since it produces a lot of overhead.

    Any help would be appreciated.

    PS. if anyone is interesteed in helping out with the game, please PM me.

    Mark

  2. #2
    Join Date
    Sep 2004
    Posts
    223
    I think an encounter class would work good, you will need to specify different types of encounters, so you could make the encounter class a super class of a whole lot of sub classes which inherit common methods from the encounter class, such as addEnemies and such...??
    A kram a day keeps the doctor......guessing

  3. #3
    Join Date
    Oct 2004
    Posts
    311
    found a link on devx about this subject that might prove usefull:
    http://www.devx.com/Java/Article/7866/1954?pf=true
    going to try this approach later today, see if this is a better waqy to go about it. Form a first glance, it looks like a nicer way to do this, although I will stiull need an Encounter class, I should be able to find a simpler way of invoing methods on that class.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center