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
991
Reaction score
838
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
42,196
Reaction score
14,665
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
42,196
Reaction score
14,665
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
42,196
Reaction score
14,665
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

here's another RPG Maker remake idea: "Plumbers Don't Wear Ties". I'll salute to whomever does this
I won't finish it today, I only will have time to work on that next Saturday, what a shame... :(
I made something for @LittenDev [as he requested]
It's been a weird while. I've been so torn down that even playing video games has been something I avoided. But I shouldn't forget two things. One, I love RPG Maker for a reason. Two, only way to eat an elephant is a bite at a time.

Forum statistics

Threads
111,388
Messages
1,060,735
Members
144,731
Latest member
ariOwl
Top