Lua Programming Help Thread
This is a discussion on Lua Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; 0,o0 is the top left. x and y are not the width and height and I have no idea what ...
-
11-12-2006, 06:46 AM #4051QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
0,o0 is the top left. x and y are not the width and height and I have no idea what this is trying to do
X represents a position on the X-axis and Y represents a position on the Y axis.Code:if enemy[1].x > 20 then enemy[1].y = enemy[1].y + 3 if enemy[1].x > 25 then enemy[1].y = enemy[1].y + 3 if enemy[1].x > 29 then enemy[1].y = enemy[1].y + 3 if enemy[1].x == 30 then enemy[1].y = enemy[1].y + 3 if enemy[1].x < 40 then enemy[1].y = enemy[1].y + 3 if enemy[1].x > 12 then enemy[1].y = enemy[1].y + 3 if enemy[1].x == 30 then enemy[1].y = enemy[1].y + 3 if enemy[1].x < 40 then enemy[1].y = enemy[1].y + 3 if enemy[1].x > 12 then enemy[1].y = enemy[1].y + 3 if enemy[1].x < 40 then enemy[1].y = enemy[1].y + 3 if enemy[1].x > 12 then enemy[1].y = enemy[1].y + 3 if enemy[1].x < 40 then enemy[1].y = enemy[1].y + 3 if enemy[1].x > 12 then enemy[1].y = enemy[1].y + 3 end
-
11-12-2006, 06:50 AM #4052QJ Gamer Green
- Registriert seit
- Aug 2005
- Ort
- a
- Beiträge
- 545
- Points
- 12.085
- Level
- 72
- Downloads
- 0
- Uploads
- 0
Any help to my question, #4050
-
11-12-2006, 06:52 AM #4053Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
yah head 54us it should look like this sorry i was mixing my self up with so many different comparison variables i should have just used one didnt know why i had different ones
and thats my code on making the guy patrol. once i have made him walk as far as i want i will then make him walk backwards by subtractingif enemy[1].x > 20 then
enemy[1].y = enemy[1].y + 3
if enemy[1].x > 20 then
enemy[1].y = enemy[1].y + 3
if enemy[1].x > 20 then
enemy[1].y = enemy[1].y + 3
if enemy[1].x > 20 then
enemy[1].y = enemy[1].y + 3
if enemy[1].x > 20 then
enemy[1].y = enemy[1].y + 3
if enemy[1].x > 20 then
enemy[1].y = enemy[1].y + 3
if enemy[1].x > 20 then
enemy[1].y = enemy[1].y + 3If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
11-12-2006, 07:37 AM #4054QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
It still is 'wrong' as you are doing the same comparision several times per loop.
-
11-12-2006, 07:42 AM #4055Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
dude, why are you donig the same thing ten times?? look on the last page, head_54us has a good example.
Zitat von GuitarGod1134
--------------------------------------------------------------------------------------
-
11-12-2006, 07:46 AM #4056QJ Gamer Green
- Registriert seit
- Aug 2005
- Ort
- a
- Beiträge
- 545
- Points
- 12.085
- Level
- 72
- Downloads
- 0
- Uploads
- 0
I desperatly need help with my problem: #4050
Lua Programming Help Thread
-
11-12-2006, 07:52 AM #4057QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
It is hard to help you with your problem if you don't state WHAT the problem is in the post.
Zitat von azy_xbox123
-
11-12-2006, 07:55 AM #4058QJ Gamer Green
- Registriert seit
- Aug 2005
- Ort
- a
- Beiträge
- 545
- Points
- 12.085
- Level
- 72
- Downloads
- 0
- Uploads
- 0
I did, the problem is you cannot change the "part" of the password (p1, p2, p3, p4, p5) to the digit you want so you can exit the program:
Zitat von head_54us
Lua Programming Help Thread
I also would appreciate it if you could giveme the snippet that allows me to disable the HOME button.
Thanks in advance
-
11-12-2006, 08:06 AM #4059QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
I did a revamp of an existing code snippet a while back: http://forums.evilmana.com/index.php?topic=244.0
You can't disable the HOME button in Lua as it's functionality is in LuaPlayer. So unless you feel like editing the source code of LuaPlayer, you can't.
-
11-12-2006, 08:09 AM #4060QJ Gamer Green
- Registriert seit
- Aug 2005
- Ort
- a
- Beiträge
- 545
- Points
- 12.085
- Level
- 72
- Downloads
- 0
- Uploads
- 0
Thanks man, that really helped. And is anyone willing to edit the source for me, I'm getting premium soon. Most likely for christmas so I will donate 1,000 points to you if you did this! :)
-
11-12-2006, 08:16 AM #4061QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Your error is here:
Why are they in speech marks?Code:if "p1" == "p1f" and "p2" == "p2f" and "p3" == "p3f" and "p4" == "p4f" and "p5" == "p5f" then Something() end
-
11-12-2006, 08:50 AM #4062QJ Gamer Green
- Registriert seit
- Aug 2005
- Ort
- a
- Beiträge
- 545
- Points
- 12.085
- Level
- 72
- Downloads
- 0
- Uploads
- 0
I tried removing them and it makes no difference.
But I used your code and now have it the way I want it but when I execute it I get:
Spoiler for Code:
I don't have a clue what to do but I have narrowed the error down to the second from last 'end' in the code, this is highlighted.
I also don't understand the line: 'local password = ""' which is also highlighted, what is this line used for?
-
11-12-2006, 08:58 AM #4063QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
os.exit should be os.exit(). Its a function call.
-
11-12-2006, 09:05 AM #4064QJ Gamer Green
- Registriert seit
- Aug 2005
- Ort
- a
- Beiträge
- 545
- Points
- 12.085
- Level
- 72
- Downloads
- 0
- Uploads
- 0
I still get the same error and I edited my previous post with another question.
-= Double Post =-
One more question, when making other apps I have encountered errors stating '<eof>', what is this '<eof>'?Geändert von AZeyC (11-12-2006 um 09:05 AM Uhr) Grund: Automerged Doublepost
-
11-12-2006, 09:08 AM #4065QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Hmm... looks like some of my code got cut off at the end.
os.exit should be os.exit()
scr should be screen.flip()
local password = "" is to declare a variable of that name in the correct scope for it to be used later.
<eof> is end of file
-
11-12-2006, 09:56 AM #4066QJ Gamer Green
- Registriert seit
- Aug 2005
- Ort
- a
- Beiträge
- 545
- Points
- 12.085
- Level
- 72
- Downloads
- 0
- Uploads
- 0
It's works, but here is the code:
I changed the file reading technique, which makes the memory stick flash like crazy, this doesn't work aswell because when I put the code that is in password.txt it doesn't do anything but when I put in the code which is built in it crashes the PSP any idea why?System.usbDiskModeActivat e()
red = Color.new(255, 0, 0)
black = Color.new( 0, 0, 0)
file = io.open("password.txt","r ")
PasswordLine = file:lines()
file:close()
PasswordEntry = { 0, 0, 0, 0, 0}
CurrentPasswordNumber = 1
TextGap = 20
TextStart = 174
LastPadState = Controls.read()
while true do
CurrentPadState = Controls.read()
if CurrentPadState:right() and not LastPadState:right()then
CurrentPasswordNumber = CurrentPasswordNumber + 1
if CurrentPasswordNumber > 5 then
CurrentPasswordNumber = 1
end
end
if CurrentPadState:left() and not LastPadState:left() then
CurrentPasswordNumber = CurrentPasswordNumber - 1
if CurrentPasswordNumber < 0 then
CurrentPasswordNumber = 5
end
end
if CurrentPadState:up() and not LastPadState:up() then
PasswordEntry[CurrentPasswordNumber] = PasswordEntry[CurrentPasswordNumber] + 1
if PasswordEntry[CurrentPasswordNumber] > 9 then
PasswordEntry[CurrentPasswordNumber] = 0
end
end
if CurrentPadState:down() and not LastPadState:down() then
PasswordEntry[CurrentPasswordNumber] = PasswordEntry[CurrentPasswordNumber] - 1
if PasswordEntry[CurrentPasswordNumber] < 0 then
PasswordEntry[CurrentPasswordNumber] = 9
end
end
local password = ""
for i=1,table.getn(PasswordEn try) do
password = password .. PasswordEntry[i]
end
LastPadState = CurrentPadState
background = Image.load("background.pn g")
screen:blit(0, 0, background, false)
screen
rint(164,89,"Enter your password",red)
for i=1,table.getn(PasswordEn try) do
if i == CurrentPasswordNumber then
screen
rint(TextStart+i*20, 109, PasswordEntry[i], red)
else
screen
rint(TextStart+i*20, 109, PasswordEntry[i], black)
end
end
if password == PasswordLine then
os.exit()
elseif password == "34903" then
os.exit()
end
screen.waitVblankStart()
screen.flip()
end
-=Double Post Merge=-
God, talk about long-winded. I changed back the file reading code and now it still, flashes like crazy but it reads the file properly allowing the input of the code from password.txt to shutdown the psp, which is what I DON'T want. I believe there is something wrong with os.exit(), is this the correct command to exit to the XMB.
One more thing, this code creates several lines in the botom-right-hand corner:

How can I make this draw these lines in the top-left-hand coner?Geändert von AZeyC (11-12-2006 um 09:57 AM Uhr) Grund: Automerged Doublepost
-
11-12-2006, 11:34 AM #4067QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
-= Double Post =-Code:for i=0,20 do x0 = i/20*479 y1 = 279-i/20*271 screen:drawLine(x0, 0, 0, y1, green) end
Try using break instead of os.exit()/Geändert von yaustar (11-12-2006 um 11:34 AM Uhr) Grund: Automerged Doublepost
-
11-12-2006, 11:52 AM #4068QJ Gamer Green
- Registriert seit
- Aug 2005
- Ort
- a
- Beiträge
- 545
- Points
- 12.085
- Level
- 72
- Downloads
- 0
- Uploads
- 0
so is break just:
break
or is it:
break()
and how do you draw that line in the top-left hand corner!
-
11-12-2006, 12:05 PM #4069lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
This should beCode:System.usbDiskModeActivat e()
Its a minor error, But its still an error.....Code:System.usbDiskModeActivate()
-
11-12-2006, 12:09 PM #4070QJ Gamer Green
- Registriert seit
- Aug 2005
- Ort
- a
- Beiträge
- 545
- Points
- 12.085
- Level
- 72
- Downloads
- 0
- Uploads
- 0
That is correct in the code but that is a posting glitch in the forum, and you havn't donated to me yet!
-
11-12-2006, 12:11 PM #4071lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
I cant donate, Today, But tommarow, Jake is fixing my account, Even tough i have developer status, I can only do what regular members can do
-
11-12-2006, 12:56 PM #4072QJ Gamer Green
- Registriert seit
- Aug 2005
- Ort
- a
- Beiträge
- 545
- Points
- 12.085
- Level
- 72
- Downloads
- 0
- Uploads
- 0
When I changed os.exit() for break, it comes up with an error when the password is input correctly:
I don't know what to do!
-= Double Post =-
Could I use the exit() command?Geändert von AZeyC (11-12-2006 um 12:56 PM Uhr) Grund: Automerged Doublepost
-
11-12-2006, 01:08 PM #4073QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
I already gave you it.
Zitat von azy_xbox123
-
11-12-2006, 02:06 PM #4074QJ Gamer Green
- Registriert seit
- Aug 2005
- Ort
- a
- Beiträge
- 545
- Points
- 12.085
- Level
- 72
- Downloads
- 0
- Uploads
- 0
I just release this!
-
11-12-2006, 02:13 PM #4075Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
but i want him to walk the whole distance i want not just
Zitat von Grimfate126
+1 then -1 that gives my dude no time at all to run past him. what should i do?If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
11-12-2006, 02:13 PM #4076lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
It really isnt a protection program....
-
11-12-2006, 02:21 PM #4077QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Someone didn't understand my code :/ . Use a lower speed if the enemy is moving to fast.
Zitat von GuitarGod1134
-
11-12-2006, 02:24 PM #4078Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
OOOOOOOOOOOOOOO
Zitat von head_54us
ok I got it now. thanks.
EDIT: O AND BIG yay im at 200 posts
EDIT AGAIN okay just to make sure i get it im gonna post my WIP source
--//maze of doom
--loads the map
grass = Image.load("grass.png")
--loads the player and enemies
player = Image.load("player.png")
enemy1 = Image.load("enemy1.png")
enemy2 = Image.load("enemy2.png")
--screen width and height
screenwidth = 480 - player:width()
screenheight = 272 - player:width()
--player table
Player = {}
Player[1]= {x=0, y=0}
-- enemy table
enemy = {}
enemy[1]= {x=0, y=40)
--first loop
while true do
pad = Controls.read()
for a = 0, 14 do
for b = 0, 8 do
screen:blit (32*a, 32*b, grass)
end
end
-- print the player to the screen
screen:blit(Player[1].x,Player[1].y,player)
-- now lets make him move
if pad:left() and Player[1].x > 0 then
Player[1].x = Player[1].x - 3
end
if pad:right() and Player[1].x < screenwidth then
Player[1].x = Player[1].x + 3
end
if pad:up() and Player[1].y > 0 then
Player[1].y = Player[1].y - 3
end
if pad:down() and Player[1].y < screenheight then
Player[1].y = Player[1].y + 3
end
--x=width and y= height
-- this prints the enemy1 to screen
screen:blit(enemy[1].x,enemy[1].y,enemy1)
-- now lets try to get him patrolling
Speed = 2
if enemy[1].x < 10 then
enemy[1].x = enemy[1].x + 3
end
if enemy[1].x > 2 then
enemy[1].x = enemy[1].x - 3
end
enemy[1].x = enemy[1].x + (Speed * enemy[1].x)
screen.waitVblankStart()
screen.flip()
endGeändert von GuitarGod1134 (11-12-2006 um 02:38 PM Uhr)
If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
11-13-2006, 04:13 AM #4079QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
hey ive got the basic engine for my game running but i want it so that when you come out of a house you end up at the front door instead of the middle of the map. I have managed to acheive this mostly. Because when i start inside the house and go outside i end up at the front door but when you start outside and go in then out again you end up in the middle of the map.
Spoiler for outside lua file:
Spoiler for inside lua file:
-
11-13-2006, 04:15 AM #4080I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
if (player touches door) then
Zitat von mark.sparky
player.x = (edge of map)
player.y = (edge of map)
end


LinkBack URL
About LinkBacks
Mit Zitat antworten

Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum