Advertising (This ad goes away for registered users. You can Login or Register)

[LUA] Need help with code plz

Forum rules
Forum rule Nº 15 is strictly enforced in this subforum.
Locked
qwikrazor87
Guru
Posts: 2874
Joined: Sat Apr 21, 2012 1:23 pm
Location: The North Pole

Re: [LUA] Need help with code plz

Post by qwikrazor87 »

Remove "empty" and it will work.

Code: Select all

shopimage = image.create(20, 20)
shopimage:clear(white)
You can also define a color when creating an image

Code: Select all

shopimage = image.create(20, 20, white)
That will create the image and make it white.

Have I ever sent you the translated docs for LuaDEV? I haven't done a full translation yet though, I just used Google Translate to translate the functions I mainly used. I could send it to you when I complete the translation, some parts have broken english.
Advertising
Last edited by qwikrazor87 on Thu Feb 14, 2013 10:23 pm, edited 1 time in total.
PSP 2001 - TA-085 - 6.61 PRO-C2
PS Vita 3G - PCH-1101 - 3.65 HENkaku Ensō
Alcatel phone - Android 8.1.0
Laptop - Toshiba Satellite L305D-S5974 - Ubuntu 16.04 LTS
dragonxtamer596
Posts: 188
Joined: Wed Oct 24, 2012 11:49 pm
Contact:

Re: [LUA] Need help with code plz

Post by dragonxtamer596 »

I don't think you have.
Advertising
qwikrazor87
Guru
Posts: 2874
Joined: Sat Apr 21, 2012 1:23 pm
Location: The North Pole

Re: [LUA] Need help with code plz

Post by qwikrazor87 »

Okay, I just edited my post, lol, I'll send it to you when I complete the translation.
PSP 2001 - TA-085 - 6.61 PRO-C2
PS Vita 3G - PCH-1101 - 3.65 HENkaku Ensō
Alcatel phone - Android 8.1.0
Laptop - Toshiba Satellite L305D-S5974 - Ubuntu 16.04 LTS
dragonxtamer596
Posts: 188
Joined: Wed Oct 24, 2012 11:49 pm
Contact:

Re: [LUA] Need help with code plz

Post by dragonxtamer596 »

Cool, you are one of the best/most awesome lua devs out there.
dragonxtamer596
Posts: 188
Joined: Wed Oct 24, 2012 11:49 pm
Contact:

Re: [LUA] Need help with code plz

Post by dragonxtamer596 »

Script error 60 unexpected symbol

Code: Select all

end

Code: Select all

blue = color.new(0,0,255)
white = color.new(255,255,255)
black = color.new(0,0,0)
green = color.new(0,128,0)

background = image.create(480,272,green)

ms = 1
mms = 3

while true do
screen.clear()
controls.read()

background:blit(0,0)

if controls.press("square") then
  music = sound.loop("music/Confusion on [REPEAT].mp3")
  end
  if controls.press("triangle") and music and sound.playing(music) then
  music:loop()
  end

  if controls.press("up") then
  ms = ms - 1
  end
  if controls.press("down") then
  ms = ms + 1
  end
  if ms > mms then
  ms = 1
  elseif ms <= 0 then
  ms = mms
  end

mc = {white, white, white}
mc[ms] = blue
screen.print(98, 110, "GAME", mc[1])
screen.print(98, 125, "Controls", mc[2])
screen.print(98, 140, "EXIT", mc[3])

  if controls.press("cross") and ms == 1 then
  draw.fillrect(0, 0, 480, 272, black)
  dofile("name.lua")
  end
  if controls.press("cross") and ms == 2 then
  dofile("controls.lua")
  end
  if controls.press("cross") and ms == 3 then
  os.exit()
  end
  if ms <= 0 then
  ms = 3
  end
  if ms >= 4 then
  ms = 1
  end

screen.waitvblankstart()
screen.flip()
end
qwikrazor87
Guru
Posts: 2874
Joined: Sat Apr 21, 2012 1:23 pm
Location: The North Pole

Re: [LUA] Need help with code plz

Post by qwikrazor87 »

dragonxtamer596 wrote:Cool, you are one of the best/most awesome lua devs out there.
Thanks. :D

Is that your actual code? I don't see what could be causing that error.
What was the actual error message?
PSP 2001 - TA-085 - 6.61 PRO-C2
PS Vita 3G - PCH-1101 - 3.65 HENkaku Ensō
Alcatel phone - Android 8.1.0
Laptop - Toshiba Satellite L305D-S5974 - Ubuntu 16.04 LTS
dragonxtamer596
Posts: 188
Joined: Wed Oct 24, 2012 11:49 pm
Contact:

Re: [LUA] Need help with code plz

Post by dragonxtamer596 »

qwikrazor87 wrote:
dragonxtamer596 wrote:Cool, you are one of the best/most awesome lua devs out there.
Thanks. :D

Is that your actual code? I don't see what could be causing that error.
What was the actual error message?
Yup thats my actual menu code :/ when I saw the error message I was like !??,!;)/(&,)'cvcvjctcch.....
The error showed as script.lua : 60: unexpected symbol.
dragonxtamer596
Posts: 188
Joined: Wed Oct 24, 2012 11:49 pm
Contact:

Re: [LUA] Need help with code plz

Post by dragonxtamer596 »

dragonxtamer596 wrote:
qwikrazor87 wrote:
dragonxtamer596 wrote:Cool, you are one of the best/most awesome lua devs out there.
Thanks. :D

Is that your actual code? I don't see what could be causing that error.
What was the actual error message?
Yup thats my actual menu code :/ when I saw the error message I was like !??,!;)/(&,)'cvcvjctcch.....
The error showed as script.lua : 60: unexpected symbol.
Ok I found out the error I needed a space before the end.
dragonxtamer596
Posts: 188
Joined: Wed Oct 24, 2012 11:49 pm
Contact:

Re: [LUA] Need help with code plz

Post by dragonxtamer596 »

Lua dev is rejecting....

Code: Select all

screen.fillrect(370,10,mana,manabar,blue)
Why is that?

And how do I make it so the player is a certain distance in order to attack the enemy.....

Code: Select all

if controls.press("cross") and Enemy[currentEnemy].health > 0 then
qwikrazor87
Guru
Posts: 2874
Joined: Sat Apr 21, 2012 1:23 pm
Location: The North Pole

Re: [LUA] Need help with code plz

Post by qwikrazor87 »

Lua dev is rejecting....

Code: Select all

screen.fillrect(370,10,mana,manabar,blue)
Why is that?
You just have to call draw.fillrect().
And how do I make it so the player is a certain distance in order to attack the enemy.....

Code: Select all

if controls.press("cross") and Enemy[currentEnemy].health > 0 then
Just make a statement with the distance.

Code: Select all

if controls.press("cross") then --or whatever you want to use to attack
  if (playerx + playerwidth > enemyx + attackdistance) and playerx < enemyx + enemywidth + attackdistance) and (playery + playerheight > enemyy + attackdistance) and (playery < enemyy + enemyheight + attackdistance) then
  --attack
  end
end
attackdistance is the variable you will use to determine how far you want the boundary to be before attacking is possible.
PSP 2001 - TA-085 - 6.61 PRO-C2
PS Vita 3G - PCH-1101 - 3.65 HENkaku Ensō
Alcatel phone - Android 8.1.0
Laptop - Toshiba Satellite L305D-S5974 - Ubuntu 16.04 LTS
Locked

Return to “Programming and Security”