MODULE: Journal-Maker 1.1

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

Previous topic - Next topic

Akumayo

The Journal-Maker allows the user to create logs/journals/questbooks/and the like using a GUI label and two buttons for scrolling.

The download includes both the module file and a walkthrough showing how to set up a journal, and some various functions one can use to edit the journal.Ã,  Once you've read over the walkthrough, the comments in the module itself elaborate on the use of each function.

This is just version 1.0, so if you find any bugs, don't hesitate to offer them up for fixing.
This may be an updated version, but bugs and suggestions are still welcome.

User Experience Recommended:
-Basic knowledge or understanding of Strings

For Advanced Use
-Advanced knowledge of String functions (some functions return a String, that can be edited, and then replaced)

Journal-Maker 1.1

-Regards, Akumayo
"Power is not a means - it is an end."

Ghost

yes, it's indeed a nice feat. i had not too much trouble rigging up a small "quest log"- and i really think this is a useful feature for games with a more elaborate scoring system, or a hint of rpg. good work!


Akumayo

Thank you very much, I intend to use it in the RPG I've been thinking about making lately.  I'm glad you found it nice.
"Power is not a means - it is an end."

Akumayo

Version 1.1 now finished.  It incorporates several more functions that are useful only for fine tuning and customizing the module.

-Enjoy, Akumayo
"Power is not a means - it is an end."

pslim

Just a note that when I unzipped the updated version, the period in the version number part of the name of the .scm file caused AGS to think 1 was the extension, so it wouldn't recognize the file type until I renamed it. Testing it out now. :)
 

Akumayo

 :-[ Sorry, I will fix that as soon as I update the module, or get some extra time.
"Power is not a means - it is an end."

JRock

Hello.  I am having trouble with the module.  I created a journal gui and created a label and two buttons.  I know how to add entries, but how do I update the journal to display the NEWEST entry next time the player goes to the journal?

Code: ags

JournalLabel.SetText(JournalModule.GetJournalCurrentText());

doesn't work.  It says that SetText is invalid????  I read the entire help file but I still can't figure out how to have The newest entry displayed.

Any help would be GREATLY appreciated!  THAN YOU so much!

riseryn

Hi
I have solved this problem by changing:

JournalLabel.SetText(JournalModule.GetJournalCurrentText());

by
JournalLabel.Text=JournalModule.GetJournalCurrentText();

hope this help

JRock


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
Ok, but where do you put this code?  Do you put it right after the code for the new journal entry or in REPEATEDLY_EXECUTE?  Cuz I tried both and it still doesn't change to the new entry????

.M.M.

#9
How can I import it to AGS??? There is nothing about it in manual and it´s not .scm or .dll

[EDIT] It´s okay now. Because name of file ends on 1.1 my computer thinks it is file .1- so I just change it on 11.scm 
:)
Your module is great! It´s exactly what I needed!

riseryn

Quote from: JRock on Sat 17/11/2007 17:52:08
Ok, but where do you put this code?  Do you put it right after the code for the new journal entry or in REPEATEDLY_EXECUTE?  Cuz I tried both and it still doesn't change to the new entry????

Yes you put it after the code for the journal entry.
:)

AntmanJB

#11
This is a cool module, I'm currently using it in my game.

However, I have encountered a few issues and I think other people would have them too.

How can I add an "Open Journal" button to the GUI, and a "Close" button in the journal? I can't seem to find any script commands for this.

Also, when new entries are added, I don't want the journal to pop up automatically, I just want it to update itself and let the player open it when they want to.

I might add a sound effect to indicate new entries, for a good example play the game "Submachine 5: The Root". Edit: I've been able to add sounds for the turn pages buttons and also in the global script for AddEntry. Now for the opening and closing of it!

Edit again: Ah! I've done it! Despite scripting not being my strong suit, after searching through the help file I found some commands. gui[number].visible brings up the journal and closes it. I put one on the icon bar and another in the journal itself. Works perfectly.
"Marge, it takes two to lie. One to lie, and one to listen."

.M.M.

#12
I am doing RPG, so It isn´t sure which entry will be, first, second or last. How can I write the script to entry can be 3rd even if there is no entry in 2nd place.
[EDIT] It is error
---------------------------
Adventure Game Studio
---------------------------
An error has occurred. Please contact the game author for support, as this
is likely to be a scripting error and not a bug in AGS.
(ACI version 3.00.1000)

in "GlobalScript.asc", line 128

Error: Null string supplied to CheckForTranslations

---------------------------
OK   
---------------------------

Dualnames

I think the module isn't made for AGS 3.0.. that's a known module bug when the module is made with a previous version. That's just compatibility issues.
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)

OneDollar

Quote from: Mirek on Fri 08/02/2008 16:10:21
Error: Null string supplied to CheckForTranslations
Actually I don't think this error is anything to do with modules being made on previous versions.

What's happening here is that you're trying to display a string somewhere without assigning any text to it. From the nature of the problem I guess you're writing to entry 3 without writing anything to entry 2, so when the compiler checks to see if there are any available translations for entry 2, it can't find a value to check and crashes. This was all helpfully explained to me a while back in this thread.

Instead of just ignoring entry 2, you'll need to assign it a value of "". (Something like JournalModule.AddEntry(""); ? I've not used this module, so I can't tell you exactly what to type). If that doesn't work, try adding just a space (JournalModule.AddEntry(" "); ?)

Alternatively post the code and ask someone who's used the module :) From 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.

.M.M.

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

.M.M.

OK, Akumayo told me to update this so... Here is Journal-Maker 1.11 ! Now, function JournalMaker.EditEntry won´t replace your text, but it will add it to the end of an old one. Also, when you sometimes need to replace all the text at some entry, Just use that:
Code: ags
 JournalMaker.EditEntry(0, "This will replace text of 0th entry!",false) 


Download here.

Kiah

Its give me an error  on   

#DEFINE Max_Entries 100

it says...

journalmodule_v1.1.asc(49): Unknown preprocessor directive 'DEFINE'

Please help im sure its something obvious and im just an idiot thanks  :)



.M.M.

Try to replace DEFINE with define.

Kiah


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!

Slasher

Hi Caracal,

same problem here. I have emailed Akumayo to find out if there is a version that would work with 3.2.1.

Meanwhile I have made my own journal that gets updated after each new entry.

SMF spam blocked by CleanTalk