![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
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 ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
![]() |
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.
|
|
|
|
|
|
#4 |
![]() ![]() sceKernelExitGame();
|
Might as well just post it here for everyone to see.
__________________
|
|
|
|
|
|
#6 |
![]() ![]() lol
Join Date: Aug 2006
Real First Name: Robert
Location: Whittier, CA
Just Played: Madden 10
Posts: 5,791
Trader Feedback: 0
|
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. |
|
|
|
|
|
#7 |
![]() |
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.
|
|
|
|
|
|
#9 |
![]() ![]() sceKernelExitGame();
|
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.
__________________
|
|
|
|
|
|
#10 |
![]() |
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:
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! |
|
|
|
|
|
#11 |
![]() ![]() sceKernelExitGame();
|
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 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
__________________
|
|
|
|
|
|
#13 |
![]() ![]() Developer
|
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 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.
__________________
[Blog] [Portfolio] [Homebrew Illuminati - Serious Homebrew Development Forums] [I want to make Homebrew FAQ] [How I broke into the Games Industry] [Programming Book List] [Programming Article List] Last edited by yaustar; 08-13-2007 at 06:12 AM.. Reason: Automerged Doublepost |
|
|
|
![]() |
| Tags |
| deal , great , kind , offer |
| Thread Tools | |
|
|