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 

Lua Help

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



Joined: 03 Apr 2006
Posts: 1

PostPosted: Mon Apr 03, 2006 9:06 am    Post subject: Lua Help Reply with quote

Hello, I'm new to this forum, so sorry if this is the wrong section, or something along the line.
I have a Lua script(http://home.comcast.net/~nickpaoletti/lj2.lua) thats nearing completion, but has a couple bugs that need a little fix-up.
The first bug is that when the player chooses "scissors" the enemy may not choose something, but still get hit and lose health. His graphic does not show either when he is hit. (Video HERE
My second bug is that when the player is not standing, it seems he can still make a choice. (I'll upload a video soon if anyone would like to see.)

Anyway, thanks for any help :)... oh and take the IMG folder from this archive if you want to test the game. The script is outdated, so that dosen't matter.
Back to top
View user's profile Send private message
Kameku



Joined: 23 Mar 2006
Posts: 32
Location: Oregon, USA

PostPosted: Mon Apr 03, 2006 10:20 am    Post subject: Reply with quote

This could be further simplified, but...

Code:
math.randomseed(os.time())
math.random();math.random();math.random()
black = Color.new(0, 0, 0)
title = Image.load("img/title.png")
vs = Image.load("img/vs.png")
jimmystand = Image.load("img/stand.png")
jimmyrock = Image.load("img/rock.png")
jimmypaper = Image.load("img/paper.png")
jimmyscissors = Image.load("img/scissors.png")
jimmyhit = Image.load("img/hit.png")
enemystand = Image.load("img/estand.png")
enemyrock = Image.load("img/erock.png")
enemypaper = Image.load("img/epaper.png")
enemyscissors = Image.load("img/escissors.png")
enemyhit = Image.load("img/ehit.png")

enemyrps = 0
jimmyhealth = 24
enemyhealth = 24
jimmypos = 0
enemypos = 0

showTitle = true
varJimmy = 0
varEnemy = 0

timer = Timer.new()

while true do
   screen:clear()
   pad = Controls.read()

   if showTitle then
      screen:blit(0, 0, title)
      if pad:start() and pad ~= oldpad then showTitle = false end
   else
      screen:blit(0, 0, vs)

      screen:print(2, 256, "Jimmy 's HP: " .. jimmyhealth, black)
      screen:print(365, 256, "Enemy's HP: " .. enemyhealth, black)
      screen:print(180, 104, "Jimmy " .. jimmypos, black)
      screen:print(160, 154, "The enemy " .. enemypos, black)

      if pad:up() and pad ~= oldpad then
         if varJimmy == 0 then
         varJimmy = 1
         varEnemy = math.random(1,3)
         timer:start()
         end
      end
      
      if pad:right() and pad ~= oldpad then
         if varJimmy == 0 then
         varJimmy = 2
         varEnemy = math.random(1,3)
         timer:start()
         end
      end
      
      if pad:down() and pad ~= oldpad then
         if varJimmy == 0 then
         varJimmy = 3
         varEnemy = math.random(1,3)
         timer:start()
         end
      end

      if timer:time() > 2005 then
         varJimmy = 0
         varEnemy = 0
         timer:stop()
         timer:reset()
      end

         if varJimmy == 1 and varEnemy == 2 then
            varEnemy = 4
            enemyhealth = enemyhealth - 4
         elseif varJimmy == 1 and varEnemy == 3 then
            varJimmy = 4
            jimmyhealth = jimmyhealth - 4
         elseif varJimmy == 2 and varEnemy == 1 then
            varJimmy = 4
            jimmyhealth = jimmyhealth - 4
         elseif varJimmy == 2 and varEnemy == 3 then
            varEnemy = 4
            enemyhealth = enemyhealth - 4
         elseif varJimmy == 3 and varEnemy == 1 then
            varEnemy = 4
            enemyhealth = enemyhealth - 4
         elseif varJimmy == 3 and varEnemy == 2 then
            varJimmy = 4
            jimmyhealth = jimmyhealth - 4
         end


         if varJimmy == 1 then jimmypos = "chose PAPER"
            screen:blit(0, 0, jimmypaper)
         elseif varJimmy == 2 then jimmypos = "chose ROCK"
            screen:blit(0, 0, jimmyrock)
         elseif varJimmy == 3 then jimmypos = "chose SCISSORS"
            screen:blit(0, 0, jimmyscissors)
         elseif varJimmy == 4 then jimmypos = "got HIT"
            screen:blit(0, 0, jimmyhit)
         else
            jimmypos = "is STANDING"
            screen:blit(0, 0, jimmystand)
         end

         if varEnemy == 1 then enemypos = "chose PAPER"
            screen:blit(346, 0, enemypaper)
         elseif varEnemy == 2 then enemypos = "chose ROCK"
            screen:blit(346, 0, enemyrock)
         elseif varEnemy == 3 then enemypos = "chose SCISSORS"
            screen:blit(346, 0, enemyscissors)
         elseif varEnemy == 4 then enemypos = "got HIT"
            screen:blit(346, 0, enemyhit)
         else
            enemypos = "is STANDING"
            screen:blit(346, 0, enemystand)
         end
      end

   oldpad = pad
   screen.flip()
   screen.waitVblankStart()
end


Sorry for the long post. ^^;
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
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