LOGIN
SEARCH
PROFILE
keys: ↑ ↓
LOGOUT
INDEX
MEMBERS
keys: ↑ ↓
HOME
PORTAL
PLAY ALONG
PLAY with WORDS
PLAY with GRAPHICS
PLAY with SOUNDS
PLAY with CODES
PLAY with PROJECTS
keys: ← →
Guest Access
Register:
Members:



Go to page : Previous  1, 2, 3, 4  Next

View previous topic View next topic Go down Message [Page 3 of 4]

Active Member
Active Member
#21 Learn to script - Page 3 Empty Re: Learn to script
Loading

handy333

handy333
Active Member
Active Member
Active Member
profile
Question

I'm working to make like an opening help window in the item menu via holding the A button.

Spoiler:


As you can see, I'm working with this part. I'm trying to turn this 3 into a Global Var. so I can change it and constantly update it.

I want the height of the box to grow from 3 pixels to 64 while the person holds the button and shrinks back to 3 when released.
Active Member
Show Signature
Active Member
http://projectrisingsun.weebly.com/ http://soundcloud.com/handyfox https://www.youtube.com/channel/UCkBX7ZxqoXslAtqsdrmsn_w
EVENTALIST
EVENTALIST
#22 Learn to script - Page 3 Empty Re: Learn to script
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
well you cant use the way you ware because classes are constants.

You should give your window a update definition and do the window re-size in there.

Try something like this:
Code:

class ItemWindow_Help < Window_Help
def initialize
super
self.width = 0
end

def update
super
if Input.press?(Input::A)
self.width += 3 if self.width < 64
else
self.width -= 3 if self.width > 0
end
end
end

Something like that.

Then change the help window in the item script to ItemWindow_Help.
EVENTALIST
Show Signature
EVENTALIST
Active Member
Active Member
#23 Learn to script - Page 3 Empty Re: Learn to script
Loading

handy333

handy333
Active Member
Active Member
Active Member
profile
Lost...
Active Member
Show Signature
Active Member
http://projectrisingsun.weebly.com/ http://soundcloud.com/handyfox https://www.youtube.com/channel/UCkBX7ZxqoXslAtqsdrmsn_w
Active Member
Active Member
#24 Learn to script - Page 3 Empty Re: Learn to script
Loading

handy333

handy333
Active Member
Active Member
Active Member
profile
Forget aboot it, I need help on knowing what CONSTANTS are and what they do.

Edit

I need help on inheritances and what they do.
Active Member
Show Signature
Active Member
http://projectrisingsun.weebly.com/ http://soundcloud.com/handyfox https://www.youtube.com/channel/UCkBX7ZxqoXslAtqsdrmsn_w
EVENTALIST
EVENTALIST
#25 Learn to script - Page 3 Empty Re: Learn to script
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
Constants
Inheritance
EVENTALIST
Show Signature
EVENTALIST
||||||||||
||||||||||
#26 Learn to script - Page 3 Empty Re: Learn to script
Loading

supercow

supercow
||||||||||
||||||||||
profile
thx for the knowledge was wondering about that too although not fully understand yet Laughing
||||||||||
Show Signature
||||||||||
Active Member
Active Member
#27 Learn to script - Page 3 Empty Re: Learn to script
Loading

handy333

handy333
Active Member
Active Member
Active Member
profile
Got it.

class Handy
def
print "Master Hand"
end
end

class Mona < Handy
def
print "Handy and Mona's future!
end
end

Mona.new

(there may be an error)
Active Member
Show Signature
Active Member
http://projectrisingsun.weebly.com/ http://soundcloud.com/handyfox https://www.youtube.com/channel/UCkBX7ZxqoXslAtqsdrmsn_w
EVENTALIST
EVENTALIST
#28 Learn to script - Page 3 Empty Re: Learn to script
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
yea its just inherited values.
Code:

class Adult
  def initialize
    @variable = 0
  end
  def update
    @variable += 1
  end
  def show_txt
    print("This is Adult.")
  end
end

class Child < Adult
  def show_var
    print("#{@variable}") # puts 0
    update
    print("#{@variable}") # puts 1
    5.times do |i|
      update # updates 5 times
    end
    print("#{@variable}") # puts 6
    @variable -= 2
    print("#{@variable}") # puts 4
  end
  def show_txt
    super # runs adult class definition
    print("This is child.")
  end
end


A good example in RMXP is the Game_Character class as an adult, Game_Event and Game_Player as child.
EVENTALIST
Show Signature
EVENTALIST
The only one
The only one
#29 Learn to script - Page 3 Empty Re: Learn to script
Loading

NuKa_BuBble

NuKa_BuBble
The only one
The only one
profile
I know what I want to learn. You can choose one/two things or all. The most important. The spoiler hide explications.

1. How fonctions work
Spoiler:

2. Errors and bugs resolution.
Spoiler:

3. Control the time.
Spoiler:

4. Sprites and interractions with player. (Self-switch include Cool )
Spoiler:

5. How a shop work.
Spoiler:
The only one
Show Signature
The only one
http://nukabubble.deviantart.com/ http://soundcloud.com/nuka_bubble https://www.youtube.com/user/NuKaBuBble?feature=mhee
EVENTALIST
EVENTALIST
#30 Learn to script - Page 3 Empty Re: Learn to script
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
All of those things you can find by studding the default scripts in RMXP. They have labeled what takes place in the code so you get a nice description on what is happening and a good example.

functions are well they work by how you made them. for example,

Code:

def times_five(num)
  return num * 5
end

when called Class.times_five(3) it will take 3 and multiply it by five and give you 15. Understand?

For errors those will be understood over time, its difficult to describe how to read them and tell whats wrong. That and i really cant think of any examples to give you. sorry.

Controlling time:

What do you mean? like to get seconds and mins? you can use this:

Code:

seconds = Graphics.frame_count / Graphics.frame_rate

then the basic time conversions from there.

you can also time how long a process took by doing this.

Code:

old_time = Time.now
#------------------------------
# example process
x = 1
1000.times{ x *= 2 }
#------------------------------
time = Time.now - old_time
print("That took #{time} seconds.")

More about the Time Class.
EVENTALIST
Show Signature
EVENTALIST

Sponsored content

profile

View previous topic View next topic Back to top Message [Page 3 of 4]

Go to page : Previous  1, 2, 3, 4  Next

 

Chatbox system disabled
Personal messaging disabled