QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

Would anyone be kind enough to offer a great deal of help?

This is a discussion on Would anyone be kind enough to offer a great deal of help? within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Okay, here's the deal: I'm working on my lua homebrew game, Making a Legend, and I have a function that ...

Reply
 
LinkBack Thread Tools
Old 08-12-2007, 03:35 PM   #1
 
andyauff's Avatar
 
Join Date: Jan 2007
Location: U.S.
Posts: 405
Trader Feedback: 0
Default Would anyone be kind enough to offer a great deal of help?

Okay, here's the deal: I'm working on my lua homebrew game, Making a Legend, and I have a function that is working perfectly in one scenario. That same function, however, doesn't work in the 5 other scenarios that I need it to work in. It is a very complicated problem that I just can't seem to fix, and it is crucial to my AI system that I am building that I get it working. If someone offers to help, I would be very appreciative and then I can send you my (very large) code. I will be very grateful for any amount of help, even if you just glance at my code. Thanks to anyone who assists me.
andyauff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-12-2007, 03:40 PM   #2
 
Join Date: Dec 2006
Posts: 652
Trader Feedback: 0
Default

Nope.

Lol jk. If u want u can pm me the code that u want to run all 5 times and il try n find out wuts wrong. Like pm me the code that works the first time and the code that doesnt work the rest of tha time.
_-Tiger-_ is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-12-2007, 03:42 PM   #3
 
andyauff's Avatar
 
Join Date: Jan 2007
Location: U.S.
Posts: 405
Trader Feedback: 0
Default

Well, the thing is....it's all exactly the same. Just with different variables. That's what's getting me.
andyauff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-12-2007, 04:11 PM   #4

sceKernelExitGame();
 
Bronx's Avatar
 
Join Date: Jan 2006
Location: New York
Posts: 3,125
Trader Feedback: 0
Default

Might as well just post it here for everyone to see.
Bronx is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-12-2007, 04:21 PM   #5
 
andyauff's Avatar
 
Join Date: Jan 2007
Location: U.S.
Posts: 405
Trader Feedback: 0
Default

Whoops- misinterpreted, sorry!

Last edited by andyauff; 08-12-2007 at 07:47 PM..
andyauff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-12-2007, 05:13 PM   #6

lol
 
Anti-QuickJay's Avatar
 
Join Date: Aug 2006
Real First Name: Robert
Location: Whittier, CA
Just Played: Madden 10
Posts: 5,791
Trader Feedback: 0
Default

Post Question in Lua Help Thread.
It was made so these kind of threads wont be made. The Lua Help Thread is moving kinda slow lately so you should get an answer.
Anti-QuickJay is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-12-2007, 05:27 PM   #7
 
andyauff's Avatar
 
Join Date: Jan 2007
Location: U.S.
Posts: 405
Trader Feedback: 0
Default

I know, but it's not just a simple question. It's really not a big deal if I make a thread for my question. It's not like I do it all the time, in fact this is the first. I understand and respect what you're saying, but I don't agree.
andyauff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-12-2007, 05:31 PM   #8
 
Join Date: Mar 2007
Posts: 755
Trader Feedback: 0
Default

just post the code for everyone to see, even if it is really big
__________________
[I][U]QJ took away my sig. :([/U][/I]
michaelp is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-12-2007, 05:32 PM   #9

sceKernelExitGame();
 
Bronx's Avatar
 
Join Date: Jan 2006
Location: New York
Posts: 3,125
Trader Feedback: 0
Default

Just post it! I highly doubt it's *that* big of a problem (nothing that experienced developers haven't encountered).

Post all the related code, and as much detail about the problem you can. That's almost a sure way to get decent help.
Bronx is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-12-2007, 06:05 PM   #10
 
andyauff's Avatar
 
Join Date: Jan 2007
Location: U.S.
Posts: 405
Trader Feedback: 0
Default

Wait... did I misunderstand your first post, Bronx? I'm really sorry if I did. I thought you were being sarcastic and talking about the fact that I made my own topic instead of posting in the Lua Help Thread. If that's not what you meant, you can disregard my second post. Sorry about that! (Do you see where I misunderstood?)

--

Well, you asked for it! This might not be enough of the code, but we'll see.
Spoiler for snippet:

Code:
------------Function to check position of player relative to that of the enemy-----------


function dirChk()

if sqselected == 9 then enemyimage = "enemy1"
   end
if sqselected == 15 then enemyimage = "enemy2"
   end
if sqselected == 23 then enemyimage = "enemy3"
   end
if sqselected == 29 then enemyimage = "enemy4"
   end
if sqselected == 37 then enemyimage = "enemy5"
   end
if sqselected == 43 then enemyimage = "enemy6"
   end

--enemy1
if enemyimage == "enemy1" and (player.x + 32 < enemy[1].x + 16) then
   left = "true"
      else
   left = "false"
end
if enemyimage == "enemy1" and (player.x > enemy[1].x + 16) then
   right = "true"
      else
   right = "false"
end
if enemyimage == "enemy1" and (player.y + 32 < enemy[1].y + 16) then
   up = "true"
      else
   up = "false"
end
if enemyimage == "enemy1" and (player.y > enemy[1].y + 16) then
   down = "true"
      else
   down = "false"
end


--enemy2
if enemyimage == "enemy2" and (player.x + 32 < enemy[2].x + 16) then
   left = "true"
      else
   left = "false"
end
if enemyimage == "enemy2" and (player.x > enemy[2].x + 16) then
   right = "true"
      else
   right = "false"
end
if enemyimage == "enemy2" and (player.y + 32 < enemy[2].y + 16) then
   up = "true"
      else
   up = "false"
end
if enemyimage == "enemy2" and (player.y > enemy[2].y + 16) then
   down = "true"
      else
   down = "false"
end


--enemy3
if enemyimage == "enemy3" and (player.x + 32 < enemy[3].x + 16) then
   left = "true"
      else
   left = "false"
end
if enemyimage == "enemy3" and (player.x > enemy[3].x + 16) then
   right = "true"
      else
   right = "false"
end
if enemyimage == "enemy3" and (player.y + 32 < enemy[3].y + 16) then
   up = "true"
      else
   up = "false"
end
if enemyimage == "enemy3" and (player.y > enemy[3].y + 16) then
   down = "true"
      else
   down = "false"
end


--enemy4
if enemyimage == "enemy4" and (player.x + 32 < enemy[4].x + 16) then
   left = "true"
      else
   left = "false"
end
if enemyimage == "enemy4" and (player.x > enemy[4].x + 16) then
   right = "true"
      else
   right = "false"
end
if enemyimage == "enemy4" and (player.y + 32 < enemy[4].y + 16) then
   up = "true"
      else
   up = "false"
end
if enemyimage == "enemy4" and (player.y > enemy[4].y + 16) then
   down = "true"
      else
   down = "false"
end


--enemy5
if enemyimage == "enemy5" and (player.x + 32 < enemy[5].x + 16) then
   left = "true"
      else
   left = "false"
end
if enemyimage == "enemy5" and (player.x > enemy[5].x + 16) then
   right = "true"
      else
   right = "false"
end
if enemyimage == "enemy5" and (player.y + 32 < enemy[5].y + 16) then
   up = "true"
      else
   up = "false"
end
if enemyimage == "enemy5" and (player.y > enemy[5].y + 16) then
   down = "true"
      else
   down = "false"
end


--enemy6
if enemyimage == "enemy6" and (player.x + 32 < enemy[6].x + 16) then
   left = "true"
      else
   left = "false"
end
if enemyimage == "enemy6" and (player.x > enemy[6].x + 16) then
   right = "true"
      else
   right = "false"
end
if enemyimage == "enemy6" and (player.y + 32 < enemy[6].y + 16) then
   up = "true"
      else
   up = "false"
end
if enemyimage == "enemy6" and (player.y > enemy[6].y + 16) then
   down = "true"
      else
   down = "false"
end

screen:print(380,50,"Up:" .. up,red)
screen:print(380,70,"Down:" .. down,red)
screen:print(380,90,"Left:" .. left,red)
screen:print(380,110,"Right:" .. right,red)

end


That's the main part of the problem. As you can see, the 6 different possibilities (enemy1,2,3,4,5,6) should all be coded exactly the same, just with the relative enemy variable, etc.

What this code does is it checks the position of the player relative to that of the enemy. That meaning, whether the player is above the enemy, below it, to the left of it, or to the right of it. The "up", "down", "left", and "right" variables take care of that, and are therefore printed to the screen for debugging purposes.

The thing is, this function works perfectly when it comes to enemy6. But other than that, it does not work at all. Here's what I mean by that: There are 6 enemies on the grid (enemies 1-6). When I choose to attack enemies 1-5 and go into battle with them, the variables left, right, up, and down don't change at all no matter what. However, they change according to the player's position when at battle with enemy 6.

The reason I have 6 different parts of a function that are all the same is so I can use the different enemies' positions, and not have all of the enemies have the same position at the same time. This allows all 6 enemies to be their own individual (does this make sense?). Would there be a better way to do this? Such as with a "currentenemy" variable or array that changes to suit the current enemy's stats?

I can give you more code, but there isn't much more that directly relates to the problem. That is why I figured it would be tough to solve... I might end up having to post the whole thing. But thanks for any help. Tell me if you want more code or have any questions or suggestions. Thanks a lot!
andyauff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-12-2007, 06:39 PM   #11

sceKernelExitGame();
 
Bronx's Avatar
 
Join Date: Jan 2006
Location: New York
Posts: 3,125
Trader Feedback: 0
Default

The first thing you want to check is print out what enemyimage is equal to every frame. If it never changes from "enemy6" then you know your problem lies in this part:
Code:
if sqselected == 9 then enemyimage = "enemy1"
   end
if sqselected == 15 then enemyimage = "enemy2"
   end
if sqselected == 23 then enemyimage = "enemy3"
   end
if sqselected == 29 then enemyimage = "enemy4"
   end
if sqselected == 37 then enemyimage = "enemy5"
   end
if sqselected == 43 then enemyimage = "enemy6"
   end
Which might mean there is a problem in how/when/if you're changing/setting the value of sqselected.

Start there and report back. It'll help narrow down the possibilities of where the error is occurring.

Btw, yes, you did misinterpret my first post
Bronx is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-12-2007, 07:57 PM   #12
 
andyauff's Avatar
 
Join Date: Jan 2007
Location: U.S.
Posts: 405
Trader Feedback: 0
Default

Okay, sorry about the misunderstanding of your post.

As for the enemyimage variable, it changes how it is supposed to. I printed it to the screen during battle and for enemies 1-6 it changes accordingly.
andyauff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-13-2007, 06:02 AM   #13

Developer
 
yaustar's Avatar
 
Join Date: Jun 2006
Location: UK
Posts: 2,317
Trader Feedback: 0
Default

Use the Lua string functions library

Code:
for i=1,table.getn( enemy ) do
	if enemyimage == "enemy" .. i then 
		if player.x + 32 < enemy[i].x + 16 then
		   left = "true"
		else
		   left = "false"
		end
		if player.x > enemy[i].x + 16 then
		   right = "true"
			  else
		   right = "false"
		end
		if player.y + 32 < enemy[i].y + 16 then
		   up = "true"
		else
		   up = "false"
		end
		if player.y > enemy[i].y + 16 then
		   down = "true"
		else
		   down = "false"
		end
	end
end
-= Double Post =-
As for the actual problem, get rid of enemies 2-6 and see if the problem still happens with only one enemy in the game. Check that variable are not being overridden. Add scaffolding inside the if statements to check the logic flow. Output as much information to the screen as humanly possible of everything that relates. Check the value of variables from where you set it to where you use it.

Last edited by yaustar; 08-13-2007 at 06:12 AM.. Reason: Automerged Doublepost
yaustar is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-13-2007, 12:34 PM   #14
 
andyauff's Avatar
 
Join Date: Jan 2007
Location: U.S.
Posts: 405
Trader Feedback: 0
Default

Thanks a lot, yaustar. I will try that out when I get a chance (this weekend...band camp this week )
andyauff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
deal , great , kind , offer

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 08:29 PM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us