Help requested with script

chungsie

Veteran
Veteran
Joined
Sep 9, 2015
Messages
656
Reaction score
857
First Language
English
Primarily Uses
N/A
In my text game version, I had a journal, which took notes from scenes, such as battles and information about what skills did. So I looked at some tutorials and got help from @Rikifive

it requires an extra end I can't figure out why.

 


class Journal
def initialize
@journal = Window_Base.new(0,0,300,300)
@page = 1
@log = []
write_log
end
def write_log
log[1] = "Page 1:
Page 2-362: Scenes
Page 363-375: Skills"
end

def refresh
case @page
when 1
draw_text(0, 0, 100, 24, log[1])
when 2
draw_text(0, 0, 100, 24, "This is page 2")
#etc....
end
end
def update
if Input.trigger?:)LEFT) && @page > 1
@page -= 1
refresh
elsif Input.trigger?:)RIGHT) && @page < 17 #(for example having maximum of 17 pages)
@page += 1
refresh
end
end
end


how do I call it to test it? how would I store more data to @log? what do I need to do to this script?
 

Rikifive

Bringer of Happiness
Veteran
Joined
Jun 21, 2015
Messages
1,441
Reaction score
680
First Language
Polish
Primarily Uses
Other
First, make a scene (it's something like a room).


In the default scripts you'll see Scene_Menu, Scene_Item, Scene_Map etc.. - these are different scenes.


For example in Scene_Map - you have a character and you move on map


in Scene_Menu - you have the game's menu


in Scene_Item - you have the inventory


And the game calls these scenes ~ like going to another rooms with different code.


You'll need to make a new scene for your journal:


#===============================================================================
# ** Scene Journal
#-------------------------------------------------------------------------------
# Class, that handles journal thingie.
#===============================================================================

class Scene_Journal < Scene_Base

def start
super
create_journal_window
end

def create_journal_window
@page = 1
@journal_window = Window_Journal.new
end

def update
super
update_player_input
end

def update_player_input
if Input.trigger?:)LEFT) && @page > 1 # if pressed left
Sound.play_cursor # play sound
@page -= 1 # change page
@journal_window.draw_log(@page) # change contents in the window
elsif Input.trigger?:)RIGHT) && @page < 3 # if pressed right
Sound.play_cursor
@page += 1
@journal_window.draw_log(@page)
end
end

def terminate
super
@journal_window.dispose
end

end




And another class for your window:


#===============================================================================
# ** Journal Window
#-------------------------------------------------------------------------------
# This class handles the journal window
#===============================================================================

class Window_Journal < Window_Base

def initialize
super(100, 60, 400, 300)
draw_log(1) # set the text
end

def draw_log(page)
case page
when 1
@log = "Page 1"
when 2
@log = "Page 2, how awesome!"
when 3
@log = "END OF JOURNAL"
end

refresh # refresh contents
end

def refresh
self.contents.clear #to clean previous stuff

draw_text(0, 0, 300, 24, @log) # draw @log contents
end

end






These are working codes - It's a quick and simple example ~ stuff can be changed.


You need to paste them in your script editor, preferably below MATERIALS; above MAIN and in game, use this script code*:


SceneManager.call(Scene_Journal)




* - you can put in either in other scripts like menus, event or whatever~ or even directly in the title screen ~ take a look how other scenes/windows handle that.


This script code will transfer you to that scene (room) where it will have its own code to do ~ in that scene it will create a window, that I've created in the second script.


Test stuff out and check if that helps. =P
 
Last edited by a moderator:

chungsie

Veteran
Veteran
Joined
Sep 9, 2015
Messages
656
Reaction score
857
First Language
English
Primarily Uses
N/A
how would I make a way to exit the scene? or even store data to @log? for instance, if a battle is won, I want to store that information to the journal.

I added this to the script, at update_player_input:



elsif Input.trigger?:)UP)
      terminate
    end


it gives me an error with Window Base.
 
Last edited by a moderator:

Rikifive

Bringer of Happiness
Veteran
Joined
Jun 21, 2015
Messages
1,441
Reaction score
680
First Language
Polish
Primarily Uses
Other
Oh yes! I forgot!
Add this:



elsif Input.trigger?:)B)


    Sound.play_cancel


    return_scene




 


so it looks like this:


Code:
[COLOR=rgb(0,0,136)]def[/COLOR][COLOR=rgb(0,0,0)] update_player_input
  [/COLOR][COLOR=rgb(0,0,136)]if[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(102,0,102)]Input[/COLOR][COLOR=rgb(102,102,0)].[/COLOR][COLOR=rgb(0,0,0)]trigger[/COLOR][COLOR=rgb(102,102,0)]?(:[/COLOR][COLOR=rgb(0,0,0)]LEFT[/COLOR][COLOR=rgb(102,102,0)])[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(102,102,0)]&&[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(0,102,102)]@page[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(102,102,0)]>[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(0,102,102)]1[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(136,0,0)]# if pressed left[/COLOR][COLOR=rgb(0,0,0)]
    [/COLOR][COLOR=rgb(102,0,102)]Sound[/COLOR][COLOR=rgb(102,102,0)].[/COLOR][COLOR=rgb(0,0,0)]play_cursor [/COLOR][COLOR=rgb(136,0,0)]# play sound[/COLOR][COLOR=rgb(0,0,0)]
    [/COLOR][COLOR=rgb(0,102,102)]@page[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(102,102,0)]-=[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(0,102,102)]1[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(136,0,0)]# change page[/COLOR][COLOR=rgb(0,0,0)]
    [/COLOR][COLOR=rgb(0,102,102)]@journal_window[/COLOR][COLOR=rgb(102,102,0)].[/COLOR][COLOR=rgb(0,0,0)]draw_log[/COLOR][COLOR=rgb(102,102,0)]([/COLOR][COLOR=rgb(0,102,102)]@page[/COLOR][COLOR=rgb(102,102,0)])[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(136,0,0)]# change contents in the window[/COLOR][COLOR=rgb(0,0,0)]
  [/COLOR][COLOR=rgb(0,0,136)]elsif[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(102,0,102)]Input[/COLOR][COLOR=rgb(102,102,0)].[/COLOR][COLOR=rgb(0,0,0)]trigger[/COLOR][COLOR=rgb(102,102,0)]?(:[/COLOR][COLOR=rgb(0,0,0)]RIGHT[/COLOR][COLOR=rgb(102,102,0)])[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(102,102,0)]&&[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(0,102,102)]@page[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(102,102,0)]<[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(0,102,102)]3[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(136,0,0)]# if pressed right[/COLOR][COLOR=rgb(0,0,0)]
    [/COLOR][COLOR=rgb(102,0,102)]Sound[/COLOR][COLOR=rgb(102,102,0)].[/COLOR][COLOR=rgb(0,0,0)]play_cursor
    [/COLOR][COLOR=rgb(0,102,102)]@page[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(102,102,0)]+=[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(0,102,102)]1[/COLOR][COLOR=rgb(0,0,0)]
    [/COLOR][COLOR=rgb(0,102,102)]@journal_window[/COLOR][COLOR=rgb(102,102,0)].[/COLOR][COLOR=rgb(0,0,0)]draw_log[/COLOR][COLOR=rgb(102,102,0)]([/COLOR][COLOR=rgb(0,102,102)]@page[/COLOR][COLOR=rgb(102,102,0)])[/COLOR][COLOR=rgb(0,0,0)]
  [/COLOR][COLOR=rgb(0,0,136)]elsif[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(102,0,102)]Input[/COLOR][COLOR=rgb(102,102,0)].[/COLOR][COLOR=rgb(0,0,0)]trigger[/COLOR][COLOR=rgb(102,102,0)]?(:[/COLOR][COLOR=rgb(0,0,0)]B[/COLOR][COLOR=rgb(102,102,0)])[/COLOR][COLOR=rgb(0,0,0)]
    [/COLOR][COLOR=rgb(102,0,102)]Sound[/COLOR][COLOR=rgb(102,102,0)].[/COLOR][COLOR=rgb(0,0,0)]play_cancel
    return_scene
  [/COLOR][COLOR=rgb(0,0,136)]end[/COLOR][COLOR=rgb(0,0,0)]
[/COLOR][COLOR=rgb(0,0,136)]end[/COLOR]

As for adding more information - you can do that in many ways ~ put more strings/variables/methods ~though I'm not sure how to do that in an very efficient way. =P


You can also use in-game switches/variables for conditionals and stuff~
 

chungsie

Veteran
Veteran
Joined
Sep 9, 2015
Messages
656
Reaction score
857
First Language
English
Primarily Uses
N/A
let's say I create an array? how would I append that to the @log? would I just use #{array[1]} for instance?

I got it to work for adding addtional text. but I don't know how to parse in a line break. in ruby it's just \n. but when I set the journal array

 $journal[1] = "\n Lakmi says hi!"

for instance and change the @log for case 1

@log = "Page 1: #{$journal[1]}" 

it prints a square block before Lakmi. how would I go about making a line break in VX ACE?

so draw_text_ex works for that.

how do I make it so this window is accessible from the menu?
 
Last edited by a moderator:

chungsie

Veteran
Veteran
Joined
Sep 9, 2015
Messages
656
Reaction score
857
First Language
English
Primarily Uses
N/A
sorry for bouble post/./..
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,975
Members
137,563
Latest member
cexojow
Top