Poll

Poll closed

N/A
N/A

Author Topic: CityMod  (Read 81710 times)

It has come to my attention that to best benefit and move forward this mod and the Blockland community as a whole, add-ons people create should be open-sourced.  This is beneficial for everyone in many ways.  Beginners can easily absorb and learn from other coders' knowledge; a coder who wants to contribute a feature to his favorite add-on now can; the community as a whole can also better mold an add-on into what they would like to see.

In light of this, CityMod will now be open-sourced.

CityMod will be released as open-source under the Creative Commons BY-NC-SA license.  This basically states that you are to give credit where credit is due and that this code-base may not be used for monetary, or otherwise, profit.

And now I present, the repo.
« Last Edit: September 21, 2014, 01:52:26 PM by Vaux »

I'm still working on that bank fyi

It add-on or game mode for Blockland?



Vaux, Im confused with it but it not show up in game add-ons list

Vaux, Im confused with it but it not show up in game add-ons list
That's because it's really unfinished, and still needs work done on it.


CityMod's database system is a complete rehash of my Jassy system which I used in CRP. Here's a side by side comparison.
Quote from: Database.cs
function CityModPDB::onAdd(%this)
{
   %this.Name = %this.getName();
   if(%this.filePath $= "")
   {
      %this.schedule(0, "delete");
      echo(%this.name @" needs a filepath.");
      return 0;
   }
   %this.fieldCount = 0;
   %this.AutoLoadCount = 0;
   if(%this.AutomaticLoading && isfile(%this.filepath @"AutoLoad.txt"))
   {
      %file = new fileObject();
      %file.openForRead(%this.filepath @"AutoLoad.txt");
      while(!%file.isEOF())
      {
         %loadcount++;
         %line = %file.readLine();
         %this.LoadData(%line);
         %this.AutoLoad[%this.AutoLoadCount] = %line;
         %this.AutoLoadCount++;
      }
      %file.close();
      %file.delete();
      warn("[CMDB] :: CityMod has loaded " @ %loadcount @ " keys.");
   }
}
function CityModPDB::addField(%this, %name, %default)
{
   if(%name $= "" || %this.FieldExist[%name])
      warn("[CMDB] :: Field "@ %name @" already exists.");
   %this.FieldName[%this.FieldCount] = %name;
   %this.FieldValue[%this.FieldCount] = %default;
   %this.FieldDefault[%name] = %default;
   %this.FieldExist[%name] = 1;
   %this.FieldCount++;
}
function CityModPDB::loadData(%this,%key)
{
   if(isObject(%this.Data[%key]))
   {
      warn("[CMDB] :: Key " @ %key @ " has already been loaded.");
      return 0;
   }
   if(!isFile(%this.filepath @ %key @".dat"))
      return %this.addData(%key);
   %this.Data[%key] = new ScriptObject(){class = "CityModPDBData";};
   %file = new fileObject();
   %file.openForRead(%this.filepath @ %key @".dat");
   while(!%file.isEOF())
   {
      %line = %file.readLine();
      %equalpos = striPos(%line,":");
      %this.Data[%key].Value[getSubStr(%line,0,%equalpos)] = getSubStr(%line,%equalpos+1,500);
   }
   %file.close();
   %file.delete();
}
function CityModPDB::AddData(%this,%key)
{
   if(isObject(%this.Data[%key]) || isFile(%this.filepath @ %key @".dat"))
   {
      warn("[CMDB] :: Key "@ %key @" already exists.");
      return 0;
   }
   %this.Data[%key] = new ScriptObject(){class = "CityModPDBData";};
   for(%a = 0; %a < %this.FieldCount;%a++)
      %this.Data[%key].Value[%this.fieldname[%a]] = %this.fieldValue[%a];
   if(%this.AutomaticLoading)
   {
      %this.AutoLoad[%this.AutoLoadCount] = %key;
      %this.AutoLoadCount++;
      %file = new fileObject();
      %file.openForWrite(%this.FilePath @"AutoLoad.txt");
      for(%a = 0;%a<%this.AutoLoadCount;%a++)
         %file.writeline(%this.AutoLoad[%a]);
      %file.close();
      %file.delete();
   }
   warn("[CMDB] :: Key "@ %key @" has been added to "@ %this.name @".");
}
function CityModPDB::ResetData(%this,%key)
{
   if(!isObject(%this.Data[%key]))
   {
      warn("[CMDB] :: Key " @ %key @ " does not exist.");
      return 0;
   }
   for(%a = 0; %a < %this.FieldCount; %a++)
      %this.Data[%key].Value[%this.fieldname[%a]] = %this.fieldValue[%a];
   warn("[CMDB] :: Key " @ %key @ " has been reset.");
}
function CityModPDB::SaveData(%this,%key)
{
   if(!isobject(%this.Data[%key]))
   {
      warn("[CMDB] :: Key " @ %key @ " does not exist in the Database.");
      return 0;
   }
   %file = new fileObject();
   %file.openForWrite(%this.FilePath @ %key @".dat");
   for(%a = 0; %a < %this.FieldCount; %a++)
      %file.writeLine(%this.FieldName[%a] @":"@ %this.Data[%key].Value[%this.FieldName[%a]]);
   %file.close();
   %file.delete();
}
Quote from: Saving.cs
function Jassy::onAdd(%this)
{
   %this.Name = %this.getName();
   if(%this.filePath $= "")
   {
      %this.schedule(0, "delete");
      echo(%this.name @" needs a filepath.");
      return 0;
   }
   %this.fieldCount = 0;
   %this.AutoLoadCount = 0;
   if(%this.AutomaticLoading && isfile(%this.filepath @"AutoLoad.txt"))
   {
      %file = new fileObject();
      %file.openForRead(%this.filepath @"AutoLoad.txt");
      while(!%file.isEOF())
      {
         %loadcount++;
         %line = %file.readLine();
         %this.LoadData(%line);
         %this.AutoLoad[%this.AutoLoadCount] = %line;
         %this.AutoLoadCount++;
      }
      %file.close();
      %file.delete();
      echo(%this.name @" has loaded "@ %loadcount @" keys.");
   }
}
function Jassy::addField(%this, %name, %default)
{
   if(%name $= "" || %this.FieldExist[%name])
      echo("Field "@ %name @" already exists.");
   %this.FieldName[%this.FieldCount] = %name;
   %this.FieldValue[%this.FieldCount] = %default;
   %this.FieldExist[%name] = 1;
   %this.FieldCount++;
}
function Jassy::loadData(%this,%key)
{
   if(isObject(%this.Data[%key]))
   {
      echo("Key "@ %key @" has already been loaded.");
      return 0;
   }
   if(!isFile(%this.filepath @ %key @".dat"))
      return %this.addData(%key);
   %this.Data[%key] = new ScriptObject(){class = "JassyData";};
   %file = new fileObject();
   %file.openForRead(%this.filepath @ %key @".dat");
   while(!%file.isEOF())
   {
      %line = %file.readLine();
      %equalpos = striPos(%line,"=");
      %this.Data[%key].Value[getSubStr(%line,0,%equalpos)] = getSubStr(%line,%equalpos+1,500);
   }
   %file.close();
   %file.delete();
}
function Jassy::AddData(%this,%key)
{
   if(isObject(%this.Data[%key]) || isFile(%this.filepath @ %key @".dat"))
   {
      echo("Key "@ %key @" already exists.");
      return 0;
   }
   %this.Data[%key] = new ScriptObject(){class = "JassyData";};
   for(%a = 0; %a < %this.FieldCount;%a++)
      %this.Data[%key].Value[%this.fieldname[%a]] = %this.fieldValue[%a];
   if(%this.AutomaticLoading)
   {
      %this.AutoLoad[%this.AutoLoadCount] = %key;
      %this.AutoLoadCount++;
      %file = new fileObject();
      %file.openForWrite(%this.FilePath @"AutoLoad.txt");
      for(%a = 0;%a<%this.AutoLoadCount;%a++)
         %file.writeline(%this.AutoLoad[%a]);
      %file.close();
      %file.delete();
   }
   echo("Key "@ %key @" has been added to "@ %this.name @".");
}
function Jassy::ResetData(%this,%key)
{
   if(!isObject(%this.Data[%key]))
   {
      echo("Key "@ %key @" does not exist.");
      return 0;
   }
   for(%a = 0; %a < %this.FieldCount; %a++)
      %this.Data[%key].Value[%this.fieldname[%a]] = %this.fieldValue[%a];
   echo("Key "@ %key @" has been reset.");
}
function Jassy::SaveData(%this,%key)
{
   if(!isobject(%this.Data[%key]))
   {
      echo("Key "@ %key @" does not exist.");
      return 0;
   }
   %file = new fileObject();
   %file.openForWrite(%this.FilePath @ %key @".dat");
   for(%a = 0; %a < %this.FieldCount; %a++)
      %file.writeLine(%this.FieldName[%a] @"="@ %this.Data[%key].Value[%this.FieldName[%a]]);
   %file.close();
   %file.delete();
}
If you're going to rip off my code at least give credit.


CityMod's database system is a complete rehash of my Jassy system which I used in CRP. Here's a side by side comparison.
If you're going to rip off my code at least give credit.

Do you just stalk every open source mod on this forum looking for people ripping off your mod or what? It's not like there's an alternate set of instructions that can do what a City RPG needs to do to save its data.

Do you just stalk every open source mod on this forum looking for people ripping off your mod or what? It's not like there's an alternate set of instructions that can do what a City RPG needs to do to save its data.
I'm just wanting credit where credit is due.

I remembered how many times you said it won't be open source.

Do you just stalk every open source mod on this forum looking for people ripping off your mod or what? It's not like there's an alternate set of instructions that can do what a City RPG needs to do to save its data.
What the forget are you talking about? His code was blatantly ripped off, no need to hop on him. I'm sure he's a little upset about his code being stolen, it's typically expected to be accredited for something you made.

I'm just wanting credit where credit is due.
<image removed>

User was banned for this post
« Last Edit: September 14, 2014, 01:54:33 AM by Badspot »

-banned snip-

Apparently he got banned for posting an image. What was it? I'm curious.

Either way, I'm glad it's open source, and hope to see some bright modders take use of the source code, this looks like it could be a real find of a gamemode.