forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

function stoping

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
wekilledbambi03



Joined: 15 Oct 2005
Posts: 31

PostPosted: Sat Oct 15, 2005 11:44 am    Post subject: function stoping Reply with quote

is there a way to stop a function with an if then statement?
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Sat Oct 15, 2005 7:36 pm    Post subject: Reply with quote

Code:
if something==true then
    return
end

_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
wekilledbambi03



Joined: 15 Oct 2005
Posts: 31

PostPosted: Sun Oct 16, 2005 10:42 am    Post subject: Reply with quote

could you explain that a little more? im still pretty new to coding. im sure it makes sense you know the stuff, but im dont. hahaha
Back to top
View user's profile Send private message
chaos



Joined: 10 Apr 2005
Posts: 135

PostPosted: Sun Oct 16, 2005 1:07 pm    Post subject: Reply with quote

"return" basically kicks the program out of the function.. when the program hits that line, it exits the function immediately, and returns to the point just after where you called the function.
_________________
Chaosmachine Studios: High Quality Homebrew.
Back to top
View user's profile Send private message
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Sun Oct 16, 2005 6:27 pm    Post subject: Reply with quote

LuMo wrote:
Code:
if something==true then


This is a nice pleonasm :-)
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Sun Oct 16, 2005 7:50 pm    Post subject: Reply with quote

hehe
well maybe easier to understand than
Quote:
if something then

for a beginner...
cause something may be 1+1==2 :P
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
wekilledbambi03



Joined: 15 Oct 2005
Posts: 31

PostPosted: Mon Oct 17, 2005 11:11 am    Post subject: Reply with quote

so would i put that in the function itself? like

Code:
funtion something()
stuff = otherstuff
if pad:cross() then
return
Back to top
View user's profile Send private message
chaos



Joined: 10 Apr 2005
Posts: 135

PostPosted: Mon Oct 17, 2005 11:35 am    Post subject: Reply with quote

yes.
_________________
Chaosmachine Studios: High Quality Homebrew.
Back to top
View user's profile Send private message
wekilledbambi03



Joined: 15 Oct 2005
Posts: 31

PostPosted: Tue Oct 18, 2005 10:07 am    Post subject: Reply with quote

alright thanks ill try it
Back to top
View user's profile Send private message
wekilledbambi03



Joined: 15 Oct 2005
Posts: 31

PostPosted: Sun Oct 23, 2005 9:29 am    Post subject: Reply with quote

Code:
function fly()
   bx = bx-2
   wx = wx-2
   if crashup() then
   return end
end


is that right? cause it doesnt work. it just runs the function.

Code:
function fly()
   bx = bx-2
   wx = wx-2
   if y < uplimit then
   return end
end


tried tat too. did nothing. by the way the bx and wx are just parts of the scrolling bg. i want it to stop scrolling when something happens.
Back to top
View user's profile Send private message
KawaGeo



Joined: 27 Aug 2005
Posts: 191
Location: Calif Mountains

PostPosted: Sun Oct 23, 2005 1:37 pm    Post subject: Reply with quote

wekilledbambi03 (what a long username.:)

The if-then statement in your last code is not affected at all. The function will return to the same caller, no matter what the result of the logical expression is. I'd suggest to return either true or false, something like this:
Code:

function fly()
   bx = bx-2
   wx = wx-2
   return (y < uplimit)
end


Note: the parenthesis pair is not required but for clarity's sake.

PS My late dog was named Bambi.
_________________
Geo Massar
Retired Engineer
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group