MODULE: Journal-Maker 1.1

Started by Akumayo, Thu 29/06/2006 12:23:32

Previous topic - Next topic

Cpt Ezz

the link has gone dead
could you reupload it
Thanks

Wonkyth

The link is working fine.
It must just be you, Elliot. ;)
"But with a ninja on your face, you live longer!"

Cpt Ezz

now i'm scared WHO ARE YOU ??? ???
and how do you know my name?

Mehrdad

Hi
Link is dead.can you put mirror.I want it serious.
My official site: http://www.pershaland.com/

.M.M.

Ok, and I also present you new version of the module!  :) Now, JournalModule works with list box! Tell me, if any problem will occur.
Journal module 1.2

Mehrdad

OK...Thank you very much Mirek.its done.
My official site: http://www.pershaland.com/


Dualnames

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)


Dualnames

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

TheRoger

Does this module works in AGS 3.2.1?

I seem to get an  error here:
Code: ags
 JournalLabel.Text(JournalModule.GetJournalCurrentText());

BlueAngel

#31
Quote from: riseryn on Sat 17/11/2007 09:58:04
Hi
I have solved this problem by changing:

JournalLabel.SetText(JournalModule.GetJournalCurrentText());

by
JournalLabel.Text=JournalModule.GetJournalCurrentText();

hope this help

Have you change this? It works in 3.2 for me dont have 3.2.1

You have to change this too I think
Quote
Try to replace DEFINE with define. 

TheRoger

Wow, just needed to remove braces  ;D Thank you, it's working now.

BlueAngel

#33
Quote from: Mirek on Sat 09/02/2008 09:58:14
QuoteFrom what I understand if you want to enter text into entry 3, you first have to enter blank text or a space or something into entry 1 and 2, then when you want to change entry 1 and 2 you'll have to edit them.
Yes, great idea!  :)
If somebody will have same problem,just put into game_start
Code: ags

JournalModule.AddEntry("EMPTY PAGE 0[(there is nothing)");
JournalModule.SetEntryDisplayed(0);
JournalModule.AddEntry("EMPTY PAGE 1[(there is nothing)");
JournalModule.SetEntryDisplayed(1);

It could be really long....  ;D

Anyone got a problem with this? It works but if the player has change the line in the journal using the buttons I sometime get the old Error: Null string supplied to CheckForTranslations.

Sorry I have fixed it I think.
I put:
JournalModule.EditEntry(3, "Lianas are good for most things.");
  JournalLabel.Text = JournalModule.ChangePosition_GetJournalText(3);
  JournalModule.SetEntryDisplayed(3);

Instead of
Code: ags

JournalModule.EditEntry(3, "Lianas are good for most things. [I have seen little birds cut them down and build nests");
  JournalLabel.Text = JournalModule.ChangePosition_GetJournalText(0);
  JournalModule.SetEntryDisplayed(3);

BESTIEunlmt

#34
Hi there

I've succesfully implemented the Journal-Maker into my game and it works fine, except...

I'm in desparate need of the function .M.M. described earlier, i.e. that the JournalModule.EditEntry doesn't replace the entire entry but adds on to the text before it.

The AGS resources still lists the older Version, an alternate download source was the exact same file.
So... where can I get Version 1.11, or is there a simple way to rewrite the source-script for this exact purpose?

Thanks

.M.M.

Hi, BESTIEunlmt,
I've modified the module for my game and I don't have the original version on this comuter - I'll look for it on the other one, and if I don't find it, I'll write the "universal version" again and upload it here.

BESTIEunlmt

Hello .M.M.

Yes, that would be highly appreciated, thanks a lot.

.M.M.

#37
Hello, first of all, sorry for the huge delay, I've found out that I just simply don't have enough time for it. So I've decided to post the raw code here: at least, you don't have to worry about the download link. It is a version of code altered for my game, so you will have to alter it a bit (at least the EditEntry part). Right now, you have to add an item into your listbox, add empty journal entry and then use EditEntry. Of course it can be simplified, but I don't have any newer version here right now.
Example:

   lstDenik.AddItem("1st outlaw");
   JournalModule.AddEntry("");
   JournalModule.EditEntry("1st outlaw", "My first task is to find Oliver Green, worker at the railway, and bring him alive to the village.");

And for the next entry:

  JournalModule.EditEntry("1st outlaw", "(Another text...)");


Header:
Code: ags

[font=courier]struct JournalModule {
  import static function AddEntry(String Text);
  import static function SetEntryDisplayed(int WhatPosition);
  import static function IsChangeValid(int Position_Change);
  import static function EditEntry(String WhichOne, String AppendText);
  import static function GetCurrentEntry();
  import static function GetCurrentPosition();
  import static function GetEntryByText(String SearchText);
  import static function GetPositionByText(String SearchText);
  import static String GetJournalCurrentText();
  import static String ChangePosition_GetJournalText(int Position_Change);
};
  import String MyText;
  import String Datum;
[/font]


Main script:
Code: ags

[font=courier]
String MyText;
String Datum;
export MyText, Datum;

struct Entries {
  bool Visible;
  int Position;
  String Text;
};

struct Positions {
  int Owning_Entry;
};

//==========================================================
//These two integers control a great deal as well.
//==========================================================

int Journal_Entries = -1;
int Current_Entry_Displayed = -1;

//==========================================================
//If you came looking here becuase of an error regarding not
//having enough Entries, then this line is your friend.
//Just change that '50' to the number of entries you think
//you'll need.
//==========================================================

#define Max_Entries 50

//==========================================================
//Now we declare the structures.
//==========================================================

Entries Entry[Max_Entries];

Positions Position[Max_Entries];

//==========================================================
//This runs on game_start, as you can see.  It sets some of
//the vars in the structs, since you can't do it in
//declaration.
//==========================================================

function game_start() {
  int counter = 0;
  while (counter < Max_Entries) {
    Entry[counter].Position = -1;
    Position[counter].Owning_Entry = -1;
    counter ++;
  }
}

//==========================================================
//And now, the functions:
//==========================================================

//----------------------------------------------------------
//GetJournalText cannot be called by the user, because it is
//needed only within this module to return text
//----------------------------------------------------------

String GetJournalText(int WhatPosition) {
  if (Position[WhatPosition].Owning_Entry != -1)
    return Entry[Position[WhatPosition].Owning_Entry].Text;
}

//----------------------------------------------------------
//AddEntry allows you to add new entries to the journal.
//----------------------------------------------------------

static function JournalModule::AddEntry(String Text) {
  if (Journal_Entries == Max_Entries) AbortGame("You seem to have called AddEntry when doing so would exceed your Max_Entries.  If the problem persists, increase your Max_Entries value, which is currently %d", Max_Entries);
  else Journal_Entries ++;
  int available_entry;
  int current_entry = 0;
  while (current_entry < Max_Entries) {
    if (Entry[current_entry].Visible == false) {
      available_entry = current_entry;
      current_entry = Max_Entries;
    }
    current_entry ++;
  }
  Entry[available_entry].Visible = true;
  Entry[available_entry].Text = Text;
	Entry[available_entry].Position = Journal_Entries;
	Position[Journal_Entries].Owning_Entry = available_entry;
}

//----------------------------------------------------------
//EditEntry allows you to edit the text of an already
//existing entry.  This way, you can update an entry once
//an event has taken place.
//----------------------------------------------------------

static function JournalModule::EditEntry(String WhichOne, String AppendText) {
  int WhatPosition = 0;
  int newindex = 0;
  while (newindex < lstDenik.ItemCount) {
   if (lstDenik.Items[newindex] == WhichOne) {
    WhatPosition = newindex;
    newindex = lstDenik.ItemCount+1;
   }
   else newindex ++;
  }
 MyText = GetJournalText(WhatPosition);
 if (MyText !="") { 
  DateTime *dt = DateTime.Now;
  Datum=String.Format("[[%02d.%02d, %02d:%02d[", dt.DayOfMonth, dt.Month, dt.Hour, dt.Minute);
  AppendText = Datum.Append(AppendText);
  Entry[Position[WhatPosition].Owning_Entry].Text = MyText.Append(AppendText);
  Display("You have a new journal entry on the page %d about topic %s." ,WhatPosition+1, WhichOne);   
 }
 else {
  DateTime *dt = DateTime.Now;
  Datum=String.Format("%02d.%02d, %02d:%02d[", dt.DayOfMonth, dt.Month, dt.Hour, dt.Minute);
  AppendText = Datum.Append(AppendText);
  Entry[Position[WhatPosition].Owning_Entry].Text = MyText.Append(AppendText);
  Display("You have a new journal entry on the page %d about topic %s." ,WhatPosition+1, WhichOne);   
 }
}
//----------------------------------------------------------
//GetJournalCurrentText grabs the text the journal should be
//displaying, and returns it as a String.  This is the
//function you should use to update labels after calling
//EditEntry, in case the player is viewing the label you 
//edited.
//----------------------------------------------------------

static String JournalModule::GetJournalCurrentText() {
  if (Position[Current_Entry_Displayed].Owning_Entry != -1) {
    return Entry[Position[Current_Entry_Displayed].Owning_Entry].Text;
  }
}

//----------------------------------------------------------
//SetEntryDisplayed allows you to 'activate' the
//journal by jumping it to an entry (probably 0, if 
//you are just setting it up.).  It could also be used to
//make shortcuts in the journal, allowing the player to
//jump to a specific entry.
//----------------------------------------------------------

static function JournalModule::SetEntryDisplayed(int WhatPosition) {
  Current_Entry_Displayed = WhatPosition;
}

//----------------------------------------------------------
//ChangePosition_GetJournalText allows you to jump to
//another entry by supplying the value to move by.  For
//example, a move of -1 would go to the entry above the
//current, while a move of 10 would jump 10 ahead.  Always
//use IsChangeValid to check the number you want to jump
//by before calling this to set your label.
//----------------------------------------------------------

static String JournalModule::ChangePosition_GetJournalText(int Position_Change) {
  Current_Entry_Displayed += Position_Change;
  return GetJournalText(Current_Entry_Displayed);
}

//----------------------------------------------------------
//GetEntryByText allows you to get the integer of an
//entry by checking its text, useful for fine-tuning
//----------------------------------------------------------

static function JournalModule::GetEntryByText(String SearchText) {
  int ent_check = 0;
  while (ent_check < Max_Entries) {
    if (Entry[ent_check].Text == SearchText) {
      return ent_check;
      ent_check = Max_Entries;
    }
    ent_check ++;
  }
}

//----------------------------------------------------------
//GetPositionByText allows you to get the integer of
//a position by checking its text, useful for fine-tuning
//----------------------------------------------------------

static function JournalModule::GetPositionByText(String SearchText) {
  int pos_check = 0;
  while (pos_check < Max_Entries) {
    if (Entry[Position[pos_check].Owning_Entry].Text == SearchText) {
      return pos_check;
      pos_check = Max_Entries;
    }
    pos_check ++;
  }
}

//----------------------------------------------------------
//GetCurrentEntry allows you to get the integer of the 
//current entry, useful for fine-tuning
//----------------------------------------------------------

static function JournalModule::GetCurrentEntry() {
  return Position[Current_Entry_Displayed].Owning_Entry;
}

//----------------------------------------------------------
//GetCurrentPosition allows you to get the current
//position, useful for fine-tuning
//----------------------------------------------------------

static function JournalModule::GetCurrentPosition() {
  return Current_Entry_Displayed;
}

//----------------------------------------------------------
//IsChangeValid allows you to check whether or not it is
//safe to call ChangePosition_GetJournalText by the amount
//you want to move.  You should ALWAYS call this, and check
//if it returns 1, before setting your label using
//ChangePosition_GetJournalText
//----------------------------------------------------------

static function JournalModule::IsChangeValid(int Position_Change) {
  if (Current_Entry_Displayed + Position_Change >= 0 && Current_Entry_Displayed + Position_Change < Max_Entries) {
    if (Entry[Current_Entry_Displayed + Position_Change].Visible == true) return 1;
    else return 0;
  }
  else return 0;
}[/font]

BESTIEunlmt

Hello .M.M.

Please excuse my delay as well, I don't utilize Google Alert or such.
I guess I'll really have to kneel into this to implement the sort of Journal I imagined...

It's about whether my game will be linear or non-linear, with the latter posing much more difficulties then just the Journal.
Anyway, thank you very much for the effort, I'm sure it's going to work with a little experimentation.

BESTIEunlmt

Caracal

I still have a problem with the „recognize“ issue.
Even if I rename the downloaded file journalmodule_1.1 AGS still won't let me import the script. It acts as if the file wasn't there!
Its sad because the idea is good and the explanation on how to use it is great too!

SMF spam blocked by CleanTalk