Status
Not open for further replies.
Joined
Sep 9, 2015
Messages
297
Reaction score
29
First Language
English
Primarily Uses
Hi! XD

What are formal arguments and can I pass a number variable to take in for the argument?
 

Chiakscare

Resident Tifaholic
Veteran
Joined
Jul 24, 2014
Messages
489
Reaction score
148
First Language
English
Primarily Uses
I only hope you're not talking about an argument done in suits and ties... but that's the only one I'm familiar with in this case. x.x

More description, please?
 
Joined
Sep 9, 2015
Messages
297
Reaction score
29
First Language
English
Primarily Uses
Like this below:

def moveto_target(px = 0 , py = 0,jump = false )where px = 0 and py = 0. For some reason its not taking any number variables that I pass in?

EDIT:

I tried changing it with an instance variable such as this

def moveto_target(@movetox , @movetoy,jump = false )and it throws me the Formal arguments cannot be instance variable
 
Last edited by a moderator:

mjshi

Jack of Most Trades
Veteran
Joined
Feb 16, 2013
Messages
988
Reaction score
832
First Language
English
Primarily Uses
N/A
Methods can't take instances... they can only take arguments that are constants or variables.
 
So something like this:

def method(x=2, y=10)endor alternatively define the variables inside the method

def method(x,y) x = 2 y = 10endedit: something to take a look at: http://www.tutorialspoint.com/ruby/ruby_methods.htm
 
Last edited by a moderator:

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,879
Reaction score
14,525
First Language
English
Primarily Uses
RMMV
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.


You need to explain what you are trying to do, not how you are trying to do it, because obviously the way you are trying to do it is not working.


There is no moveto_target method, which means you are writing your own. How do you know it's not taking the values you pass in? How do you know it's not what's happening inside that's flawed? Show us the whole thing, not just a tiny little bit that may or may not be the problem.
 
Last edited by a moderator:
Joined
Sep 9, 2015
Messages
297
Reaction score
29
First Language
English
Primarily Uses
But how can I reference x and y from another method?

def method(x,y)Like, for example, from another method thats calling def method(x,y) has the x and y values and want to use those x and y values for the def method argument?
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,879
Reaction score
14,525
First Language
English
Primarily Uses
RMMV
see my post above. You are not giving us enough information to help you. The method definition you had above is correct. It's either the way you're calling it, or what the method is doing, that has the bug. We can't help you if you don't give us more.
 
Joined
Sep 9, 2015
Messages
297
Reaction score
29
First Language
English
Primarily Uses
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.

You need to explain what you are trying to do, not how you are trying to do it, because obviously the way you are trying to do it is not working.

There is no moveto_target method, which means you are writing your own. How do you know it's not taking the values you pass in? How do you know it's not what's happening inside that's flawed? Show us the whole thing, not just a tiny little bit that may or may not be the problem.
Its from here

http://forums.rpgmakerweb.com/index.php?/topic/44784-schala-move-towards-target-help-plz/

#-------------------------------------------------------------------------- # ● Move Position #-------------------------------------------------------------------------- def moveto_target(px = 0 , py = 0,jump = false ) jump_count = 0 jump_peak = 0 nx = user_target.x + px ny = user_target.y + py nx = real_cx_max if nx > real_cx_max nx = real_cx if nx < real_cx ny = real_cy_max if ny > real_cy_max ny = real_cy if ny < real_cy self.jump_high(0,0,10) if jump self.x = nx self.y = ny end I dont think I'm getting any help so Im trying to do my very best in learning stuff so I could do it myself
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,879
Reaction score
14,525
First Language
English
Primarily Uses
RMMV
Alright - let's keep it to one thread, then, shall we? Not getting an answer as quickly as you would like is not a reason to start a new thread, especially when people are still helping you in the other one.


Closing.
 
Status
Not open for further replies.

Latest Threads

Latest Profile Posts

unknown.png

A sketch of a character for an upcoming chapter. I am pre-preparing the heck out of this one and future chapters, don't want to spend time figuring the story out again. :blush:
Today *Fix the game UI
RMMZ maxRows make me tired.
The game supports real-time language switching (really interesting).
8laFKAa.png


jBYDFzZ.png


lYbvPth.png

mY99lgU.png

Swag collecting in the new randomly generated area. Now the mini map also shows the randomly generated features... And even illustrates the whole "bubble" system" that I made to manage memory... Though that part's inadvertent. We'll just call that "the fog of war"... Yes, that's what we'll do. Nobody will be the wiser! :kaopride:
not me being not lazy for 5 seconds and drawing another char portrait (her name is hazel)
its_hazel.png
Been a while since the last time I made a song remix. Had a blast making this

Forum statistics

Threads
110,458
Messages
1,053,473
Members
143,551
Latest member
AmberliaDraw
Top