166
Technical forum / Re:LoadFromFile problems
« on: February 20, 2004, 02:55:16 PM »
Well, the whole thing still didn't work. I have to do some testing...
Forum rules - please read before posting, it can save you a lot of time.
include "scripts\base.inc"
#include "scripts\keys.inc"
var first_slot_deletes_data;
var second_slot_deletes_data;
var third_slot_deletes_data;
var fourth_slot_deletes_data;
var id1;
var id2;
var id3;
var id4;
var IDs=new Array();
var CurrentPage = 0;
var Pages = new Array();
var Deletes=new Array();
Redraw();
var nphil=Game.LoadEntity("entities\notepad_phil\notepad_phil.entity");
////////////////////////////////////////////////////////////////////////////////
on "block1"
{
if(discussion==true)
{
if(first_slot_deletes_data==false)
{
question=id1;
LargeDialogueHandler();
}
}
}
////////////////////////////////////////////////////////////////////////////////
on "block2"
{
if(discussion==true)
{
if(second_slot_deletes_data==false)
{
question=id2;
LargeDialogueHandler();
}
}
}
////////////////////////////////////////////////////////////////////////////////
on "block3"
{
if(discussion==true)
{
if(third_slot_deletes_data==false)
{
question=id3;
LargeDialogueHandler();
}
}
}
////////////////////////////////////////////////////////////////////////////////
on "block4"
{
if(discussion==true)
{
if(fourth_slot_deletes_data==false)
{
question=id4;
LargeDialogueHandler();
}
}
}
////////////////////////////////////////////////////////////////////////////////
on "close"
{
if(discussion==true) question=false;
go_on="go_on";
this.Close();
}
////////////////////////////////////////////////////////////////////////////////
on "prev"
{
if(CurrentPage >=1) CurrentPage = CurrentPage - 1;
Redraw();
}
////////////////////////////////////////////////////////////////////////////////
on "next"
{
if(CurrentPage < Pages.Length-1) CurrentPage = CurrentPage + 1;
Redraw();
}
////////////////////////////////////////////////////////////////////////////////
on "locations_button"
{
/*if(discussion==false)
{
this.Close();
WinLocations.GoExclusive();
}else{
go_on="locations";
this.Close();
}*/
WinCharacters.LoadFromFile("notepad\locations.window");
}
////////////////////////////////////////////////////////////////////////////////
on "events_button"
{
/*if(discussion==false)
{
this.Close();
WinEvents.GoExclusive();
}else{
go_on="events";
this.Close();
}*/
WinCharacters.LoadFromFile("notepad\events.window");
}
////////////////////////////////////////////////////////////////////////////////
function Redraw()
{
// get controls
var BtnPrev = this.GetControl("prev");
var BtnNext = this.GetControl("next");
var Block1 = this.GetControl("Block1");
var Block2 = this.GetControl("Block2");
var Block3 = this.GetControl("Block3");
var Block4 = this.GetControl("Block4");
var Page;
Page = Pages[CurrentPage];
id1=IDs[CurrentPage];
//FIRST BLOCK
first_slot_deletes_data=Deletes[CurrentPage];
if(first_slot_deletes_data==true)
{
Game.Msg("Ekaa ei nayteta.");
Block1.SetFont("fonts\phyllis-strikeout.font");
}else{
Game.Msg("Eka nautetaan");
Block1.SetFont("fonts\phyllis.font");
}
SetupBlock(Block1, Page.Text1);
//SECOND BLOCK
if(CurrentPage<Pages.Length-1)
{
Page = Pages[CurrentPage+1];
second_slot_deletes_data=Deletes[CurrentPage+1];
if(second_slot_deletes_data==true)
{
Game.Msg("Tokaa ei nayteta.");
Block2.SetFont("fonts\phyllis-strikeout.font");
}else{
Game.Msg("Toka nautetaan");
Block2.SetFont("fonts\phyllis.font");
}
SetupBlock(Block2, Page.Text1);
id2=IDs[CurrentPage+1];
}else{
SetupBlock(Block2, "");
}
//THIRD BLOCK
if(CurrentPage<Pages.Length-2)
{
Page=Pages[CurrentPage+2];
third_slot_deletes_data=Deletes[CurrentPage+2];
if(third_slot_deletes_data==true)
{
Game.Msg("Kolmatta ei nayteta.");
Block3.SetFont("fonts\phyllis-strikeout.font");
}else{
Game.Msg("Kolmas nautetaan");
Block3.SetFont("fonts\phyllis.font");
}
SetupBlock(Block3, Page.Text1);
id3=IDs[CurrentPage+2];
}else{
SetupBlock(Block3, "");
}
//FOURTH BLOCK
if(CurrentPage<Pages.Length-3)
{
Page=Pages[CurrentPage+3];
fourth_slot_deletes_data=Deletes[CurrentPage+3];
if(fourth_slot_deletes_data==true)
{
Game.Msg("Neljatta ei nayteta.");
Block4.SetFont("fonts\phyllis-strikeout.font");
}else{
Game.Msg("Neljatta nautetaan");
Block4.SetFont("fonts\phyllis.font");
}
SetupBlock(Block4, Page.Text1);
id4=IDs[CurrentPage+3];
}else{
SetupBlock(Block4, "");
}
Game.Msg(first_slot_deletes_data);
Game.Msg(second_slot_deletes_data);
Game.Msg(third_slot_deletes_data);
Game.Msg(fourth_slot_deletes_data);
//button states
BtnPrev.Visible = CurrentPage > 0;
BtnNext.Visible = CurrentPage < Pages.Length - 4;
}
////////////////////////////////////////////////////////////////////////////////
function SetupBlock(Control, Text)
{
if(Text==null) Text = "";
Control.Text = Text;
}
////////////////////////////////////////////////////////////////////////////////
method AddNote(Text1)
{
var NewPage;
NewPage.Text1 = Text1.contents;
NewPage.id=Text1.id;
NewPage.status=Text1.removed;
IDs.Push(NewPage.id);
Pages.Push(NewPage);
Deletes.Push(NewPage.status);
Redraw();
}
////// there's no reason to use this function, but I let it be here just in case
method SkipToPage(PageNumber)
{
if(PageNumber%2 != 0) PageNumber = PageNumber - 1;
if(PageNumber>=Pages.Length) PageNumber = Pages.Length - 1;
if(PageNumber<0) PageNumber = 0;
CurrentPage = PageNumber;
Redraw();
}
////// there's no reason to use this function, but I let it be here just in case
method SkipToEnd()
{
SkipToPage(Pages.Length-1);
}
////////////////////////////////////////////////////////////////////////////////
/*on "Keypress"
{
var button;
if(Keyboard.KeyCode==VK_ESCAPE)
{
button = this.GetControl("close");
button.Press();
}
else if(Keyboard.KeyCode==VK_LEFT || Keyboard.KeyCode==VK_PRIOR)
{
button = this.GetControl("prev");
if(!button.Disabled) button.Press();
}
else if(Keyboard.KeyCode==VK_RIGHT || Keyboard.KeyCode==VK_NEXT)
{
button = this.GetControl("next");
if(!button.Disabled) button.Press();
}
}*/
///////////////////////////////////////////////////////////////
function LargeDialogueHandler()
{
go_on="go_on";
if(question==1
|| question==2
|| question==3
|| question==4
&& character=="OldGuy")
{
this.Close();
}else{
var line;
var run=Random(1,3);
switch(run)
{
case 1:
line="Naw, I don't want to ask about that.";
break;
case 2:
line="Excellent, but no.";
break;
default:
line="I'd rather eat garlic than ask that question!!";
}
Game.Interactive=false;
nphil.Talk(line);
Game.Interactive=true;
}
}
///////////////////////////////////////////////////////////////
method CrossOutNote(note_number)
{
var i=0;
while(IDs[i]!=note_number)
{
i=i+1;
}
if(IDs[i]==note_number)
{
Deletes[i]=true;
}else{
Game.Msg("CrossOutNote-error has occurred.");
}
Redraw();
}
on "locations_button"
{
/*if(discussion==false)
{
this.Close();
WinLocations.GoExclusive();
}else{
go_on="locations";
this.Close();
}*/
WinCharacters.LoadFromFile("notepad\locations.window");
}
#include "scripts\base.inc"
//var scrollbutton=Game.LoadEntity("\slider\slider.entity");
//scrollbutton.Visible=true;
var scrollBtn=Window.GetEntity();
on "LeftClick"
{
scrollBtn.X=200;
Game.Msg("left_CLICK");
}
on "LeftRelease"
{
Game.Msg("left_release");
}
if(Selected==4)
{
Loop=false;
Game.Interactive = true;
WinCharacters.GoExclusive();
for(var f=0; go_on!="go_on"; f=f+1)
{
if(go_on=="characters") WinCharacters.GoExclusive();
if(go_on=="events") WinEvents.GoExclusive();
if(go_on=="locations") WinLocations.GoExclusive();
}
if(go_on=="go_on")
{
//we have selected a note, and an appropriate response will be heard
if(Selected==4)
{
Loop=false;
Game.Interactive = true;
WinCharacters.GoExclusive();
Game.Interactive=false;
if(question=="1")
{
WinCharacters.CrossOutNote(1);//removes the first note
actor.Talk("Ask about the first note");
}
if(question=="2")
{
WinCharacters.CrossOutNote(2);
actor.Talk("ask about the second note");
}
if(question=="3")
{
WinCharacters.CrossOutNote(3);
actor.Talk("ask bout the third note");
}
if(question=="4")
{
WinCharacters.CrossOutNote(4);
actor.Talk("fourth note");
}
OldGuyDialogue();//after asking, go back to dialogue