Author Topic: My questions for coding (for now)  (Read 2248 times)

/title

I would look at other game-modes, but they have other functions that activate it and so on. I tried to search is up but nothing really appears.

May someone please place a script code that makes an actual mini-game just by placing it in a zip and enabling it? That will help me see the mini-game function build a bit more clearly at a concentrated form instead of having other pieces of a random code associated with the mini-game.

Thanks!
« Last Edit: January 23, 2015, 10:34:04 PM by chubaka452 »

Gamemodes automagically create a minigame from the settings in gamemode.txt. If your addon is a gamemode, you can simply use that, and reference it by $defaultMinigame.

A minigame is just a scriptObject. Create a minigame and do findClientByName("chubaka").minigame.dump(); to get a list of the variables used, then use new ScriptObject() { variable = value; }; to create one.

Mini game object reference, from the coding resource thread: http://forum.blockland.us/index.php?topic=225595.0

Is the modulo sign the same meaning as in python?


CreateMiniGameSO()
I forgot what the arguments are, I'm sure someone can fill them in

Gamemodes automagically create a minigame from the settings in gamemode.txt. If your addon is a gamemode, you can simply use that, and reference it by $defaultMinigame.

A minigame is just a scriptObject. Create a minigame and do findClientByName("chubaka").minigame.dump(); to get a list of the variables used, then use new ScriptObject() { variable = value; }; to create one.

This wasn't what I asked for, but whatever. I asked for the layout to build a minigame in script format already there as a demonstration.

This won't totally help, but consider using slayer minigames for a gamemode (if you're planning on using teams and stuff). http://forum.blockland.us/index.php?topic=251031.msg7257038#msg7257038

I don't think that defines $defaultMinigame, so you're going to need to find a way around that.
« Last Edit: January 24, 2015, 12:11:43 AM by Honorabl3 »

This wasn't what I asked for, but whatever. I asked for the layout to build a minigame in script format already there as a demonstration.

I told you how to find out the solution you want. Nobody wants to spoon feed anybody answers, because then they'll come back with another similar problem in a few days and expect somebody to spoon feed them again. Spoon feeding isn't how you learn to code, you've got to learn to find things out yourself.

I told you how to find out the solution you want.
Give a man a fish he can eat for a day. Teach a man to fish and he can eat for the rest of his life.

I told you how to find out the solution you want. Nobody wants to spoon feed anybody answers, because then they'll come back with another similar problem in a few days and expect somebody to spoon feed them again. Spoon feeding isn't how you learn to code, you've got to learn to find things out yourself.
Whatever, I guess. But I do have a question... Do you need a statement to run the function or do I execute it from a server.cs...?
« Last Edit: January 24, 2015, 04:13:30 PM by chubaka452 »

Run the function? You mean creating the ScriptObject?

Run the function? You mean creating the ScriptObject?
Like

If I were to place

Code: [Select]
function makeminigame()
{
    ScriptObject(Chewsminigame)
        {
            variable = value;
        }
{
If I wrote this wrong, correct me please.

Do I have to execute that function somehow? Like though a server.cs execute(); or something? Or do I just place it in a .zip and run it like that?

First off you need the new keyword to create a new object. Second, you need a semicolon after the instantiation of your object. Finally, your closing bracket was accidentally an open bracket. So your code would have to be:

Code: [Select]
function makeminigame()
{
    new ScriptObject(Chewsminigame)
    {
        variable = value;
    };
}

Second, you would have to run makeminigame(); to execute that function. If you wanted that ScriptObject to be created automatically when the file is executed, remove the function declaration so your code just looks like this:

Code: [Select]
new ScriptObject(Chewsminigame)
{
    variable = value;
};

Alternatively you can get all the fields by creating a minigame and using the .save() method on the scriptObject. If your player is currently in a minigame, you can do findclientbyname("Honor").minigame.save("config/server/temp/temp.txt"); to save all the information.

After navigating to the directory, you should find a file with information similar too:
Code: [Select]
//--- OBJECT WRITE BEGIN ---
new ScriptObject() {
   class = "MiniGameSO";
      UseSpawnBricks = "1";
      EnableBuilding = "1";
      Points_Die = "0";
      FallingDamage = "1";
      Points_BreakBrick = "0";
      BrickDamage = "1";
      StartEquip3 = "728";
      Points_PlantBrick = "0";
      StartEquip0 = "65";
      EnablePainting = "1";
      title = "Honor\'s Mini-Game";
      lastResetTime = "3707494";
      numMembers = "1";
      Points_KillPlayer = "1";
      WeaponDamage = "1";
      RespawnTime = "1000";
      lastMessage = "$findclientbyname(honor).minigame.save(\"config/server/temp/temp.txt\");";
      owner = "35788";
      VehicleRespawnTime = "5000";
      BotDamage = "1";
      StartEquip4 = "888";
      Points_KillSelf = "-1";
      StartEquip1 = "75";
      colorIdx = "0";
      resetSchedule = "0";
      InviteOnly = "0";
      BrickRespawnTime = "30000";
      SelfDamage = "1";
      UseAllPlayersBricks = "0";
      Points_KillBot = "1";
      PlayersUseOwnBricks = "0";
      EnableWand = "1";
      TimeLimit = "0";
      timeLimitSchedule = "0";
      BotRespawnTime = "5000";
      VehicleDamage = "1";
      StartEquip2 = "383";
      member0 = "35788";
      PlayerDataBlock = "38";
};
//--- OBJECT WRITE END ---