[Battle Scripting] Help with battle scripting

Discussion in 'Server and Client Scripting' started by greymatter1234, Apr 14, 2015.

  1. greymatter1234

    greymatter1234 Trimmin' the tall grass.

    Joined:
    Feb 1, 2015
    Messages:
    35
    Likes Received:
    2
    PO Trainer Name:
    greymatter
    Okay so I wanted to make a bot to do very simple functions in a battle. Like a sending a message.
    So far, nothing works.

    Can someone tell me --extremely clearly-- what I'm supposed to do?
    I know JavaScript well enough, but I don't know much Java. (I have no idea which language I'm supposed to use. Some say Java, others say Javascript -_-)

    I decided to begin at level zero and enabled Scripts Window in plugin manager. In the 'Battle Scripts' tab, I pasted this:

    battle.battleMessage(battle.id, "Good Luck");

    ...it didn't work. I thought it was lacking a trigger, and did this:

    onBeginTurn(turn)
    {
    if(turn==1)
    battle.battleMessage(battle.id, "Good Luck");
    }

    and that too didn't work. I understood the onSendOut() is triggered at the start of the battle, but I'm getting a but confused about the variables, so I opted for a simpler event instead.

    So help? What am I doing wrong? Which language am I supposed to use?
     
  2. MidwayMarshall

    MidwayMarshall woof Forum Moderator Developer Forum Moderator Developer

    Joined:
    Jun 13, 2014
    Messages:
    303
    Likes Received:
    170
    Declare them as functions (This is javascript) and encapsulate. Copy this in to help you get started.
    Code (javascript):
    1. ({
    2.   onBeginTurn : function(turn) {
    3.     battle.battleMessage(battle.id, "turn");
    4. },
    5.   onTierNotification : function (tier) {
    6.     battle.battleMessage(battle.id, "hello");
    7.     battle.battleMessage(battle.id, client.windowActive());
    8. }
    9. });
     
  3. greymatter1234

    greymatter1234 Trimmin' the tall grass.

    Joined:
    Feb 1, 2015
    Messages:
    35
    Likes Received:
    2
    PO Trainer Name:
    greymatter
    Thanks! That helped!
    So the language we are supposed to use is JavaScript and not Java?
     
  4. MidwayMarshall

    MidwayMarshall woof Forum Moderator Developer Forum Moderator Developer

    Joined:
    Jun 13, 2014
    Messages:
    303
    Likes Received:
    170
    You use JavaScript.

    "Java and Javascript are similar like Car and Carpet are similar"