Ok well you use (16*64) then because the x is read according to lua player as a letter the multiplication operator is *.
And do you know what to put where bounce away is? could help u if u dont.
Printable View
Ok well you use (16*64) then because the x is read according to lua player as a letter the multiplication operator is *.
And do you know what to put where bounce away is? could help u if u dont.
allright.
my last post should help...
Im really gettin angry i'm making my game and there must be such a simple error but i just cant see it. line 12 loop in gettable. Whats wrong ?
white = Color.new(255,255,255)
kitchen = Image.load("kitchen.png")
Player = Image.load("mouse.png")
while true do
pad = Controls.read()
if pad:up() then
Player.y = Player.y + 1
end
if pad:down() then
Player.y = Player.y - 1
end
if pad:right() then
Player.x = Player.x + 1
end
if pad:left() then
Player.x = Player.x - 2
end
screen:clear()
screen:blit(0,0,kitchen)
screen:blit(240,130,Playe r)
screen.waitVblankStart()
screen.flip()
end
you havent defined anything called "Player.x" or "Player.y"Zitat:
Zitat von eldiablov
Erm i just thought that it'd know that it's the players co-ordinates ?
you gotta give player.x and player.y values.
edit - nope. you gotta spell it out for luaplayer.
Luaplayer doesn't know ANYTHING except for what to do when you give it a command. You can't go off using undefined variables.
Ive added this in
Player = {}
Player.x = 230
Player.y = 135
then carry on as normal but it still doesnt work. Someone give me some sort of direction
"but it doesn't work"
What error does it give?
I know what's wrong, but you DO need to be more specific in "it doesn't work"
Anyways, you need to define the player's image with a different variable than the x-y table. Also you need to put player.x and player.y inside the table, like this:
Player = { x = blah, y = blah }
Ok thank you ill try it
after you do player = {}Zitat:
Zitat von eldiablov
do: Player.img = Image.load("mouse.png")
then change all the times you use Player to Player.img
--Vaza
-= Double Post =-
you don't HAVE to do that.Zitat:
Zitat von -TacticalPaper-
you can define like player.x, but its cleaner this way^^
--Vaza
white = Color.new(255,255,255)
kitchen = Image.load("kitchen.png")
Player.img = {x = 240, y = 130}
Player.img = Image.load("mouse.png")
while true do
pad = Controls.read()
if pad:up() then
Player.img.y = Player.y + 1
end
if pad:down() then
Player.img.y = Player.img.y - 1
end
if pad:right() then
Player.img.x = Player.img.x + 1
end
if pad:left() then
Player.img.x = Player.img.x - 2
end
screen:blit(240,130,Playe r.img)
screen:clear()
screen:blit(0,0,kitchen)
screen.waitVblankStart()
screen.flip()
end
ATtempt to index Player a nil value ?
You defined player as a table then you defined it as an image.
Luaplayer thinks player is an image.
You need to use different variables when defining them.
Sorry to go on but could you go further into what you're saying i'm quite new to this
white = Color.new(255,255,255)
kitchen = Image.load("kitchen.png")
Player = {x = 240, y = 130, img = Image.load("mouse.png") }
while true do
pad = Controls.read()
if pad:up() then
Player.y = Player.y - 1
end
if pad:down() then
Player.y = Player.y + 1 -- You had the +/- backwards
end
if pad:right() then
Player.x = Player.x + 1
end
if pad:left() then
Player.x = Player.x - 2
end
screen:clear()
screen:blit(0,0,kitchen)
screen:blit(Player.x,Play er.y,Player.img)
screen.waitVblankStart()
screen.flip()
end
You needed to fix a few different things. There's a script that SHOULD do as intended.
You don't know how much i appreciate that. Thanks very much to all three of you
Okay, I just started LUA yesterday... I made a little sample of an RPG I'm trying to make... I can't seem to get it to work... I attached the file here so you can download it and see it... Also, I need help with adding images underneath the text of the player/enemy. I know how to load/display images, I just can't get them to display properly in the game, it gives me an error when I try... Please try out the sample/demo I made... And please, don't flame me. I'm just looking for help
pspillows, heed my advice, it will help indefinitely. you say you got started with lua yesterday? if thats the extent of your programming history its best not to aim high and try to make an RPG. not gonna happen. sorry, way of the virtual world my friend. see how long i've been a member here? i still dont get alot of the things people do on here, even in lua, my most experienced field. heck, in a second i'm about to post about my problem. i cant say what you should do to further yourself in this, but i can tell you what NOT to do. dont aim high with a crossbow when you need a sniper. look at what other devs do and ask a question here and there after honestly putting effort into it and, before you know it, you'll be doing fine.
EDIT - i need help with reading and writing other files. i'm making a save file, if you will, that tracks progress so the player cant do some of the things that are possible in the beginning. in my game, players will first have to customize their..er..characters (cant really call them characters really, but thats another story) then they set off to play the rest of the game. i'm making a save file so that the result would be something like:
-= Double Post =-Code:while (player hasnt played before, variable from save file) do
customize character
else
while (player has played before, same variable with different value) do
whatever comes next
end
my menu leaves to another script which starts here:
the script automatically goes back to the menu after it flickers.Code:screen:clear(black)
screen.flip()
screen:clear(black)
bg = Image.load("project pics/statsbg.png")
size = 2
speed = 2
recovery = 2
selectstat = 3
save = io.open("save.lua", "r") -- \
first = save:read() ------------- heres whats giving me trouble
save:close() -------------------/
while first== true do
Use a different file name, not save. There's probably a function that starts with 'save:'Zitat:
Zitat von EminentJonFrost
nope..that didnt do anything...i changed every "save" to "profile". oh, if you were wondering, 'save.lua' file only has the word 'true' in it. thats it.
Maybe it should be:
while first == "true" do
Try adding the quotes.
didnt work either...:(
i even added these: "" to the save file text...still nothing.
could it be luaplayer? i have cool's mod.
I don't think so. Cools mod is the same thing, only with a few more functions. Could you post your whole code?
this is all the code that has anything to do with the problem. without these codes, it runs fine, but not how i want it to.
main script -
Save File -Code:profile = io.open("save.lua", "r")
first = profile:read()
profile:close()
-- skipping some code
while first == "true" do
-- skipping alot of code
end
Code:"true" -- player's first time playing
Maybe instead of writing true, write 0 for false and 1 for true. Numbers might be easier to work with.Zitat:
Zitat von EminentJonFrost
nope. :(...
i'm gonna have to find some way around this then...
if anyone thinks they know whats wrong though, please tell me.
did you try addingto the savefile?Code:first = "true"
this, translated, pretty much means that.
Code:first = profile:read()
i know but you may have to define it in the savefile then just us do:file(filename)
hmm...i'll try that :)
so simple, it just might work.
Zitat:
Zitat von slicer4ever
taht wont work.
-= Double Post =-
Zitat:
Zitat von EminentJonFrost
try this:
main script -
Code:profile = io.open("save.lua", "r")
first = profile:read()
profile:close()
-- skipping some code
if first == "true" then
-- skipping alot of code
end
Grimfate - that didnt work...errors started coming up about how many 'ends' there were
slicer4ever - i did that, sorta. and it worked!
i did this:
worked like a charm! :)Code:dofile("./save file.lua")
while first == true do
...
if button pressed
save = io.open("save file.lua", "w")
save:write("first = false")
save:close()
end
...
end
successful bypass gentlemen! lol
thanks Access_Denied, Grimfate, and slicer4ever! :Punk:
tight, i don't know why nobody could get it to work, but this is a great bypass! nice ideas!!!Zitat:
Zitat von EminentJonFrost
I need help with my ping pong game, once more...
What i need is, the variable for "bounce away" because i dont know what to write there.Zitat:
white = Color.new(255, 255, 255)
screen:print(136, 136, "Loading LUA Pong...", white)
screen.flip()
background = Image.load("Background.pn g")
bat11 = Image.load("Bat1.png")
bat21 = Image.load("Bat2.png")
bat1 = { x = 20, y = 100 }
bat2 = { x = 460, y = 100 }
ball = { x = 240, y = 146, image = Image.load("Ball.png") }
screen.waitVblankStart(60 )
while true do
screen:clear()
screen:blit(bat1.x, bat1.y, bat11, true)
screen:blit(bat2.x, bat2.y, bat21, true)
pad = Controls.read()
if ball.x == bat.x and ball.y >= bat.y and ball.x < (16*64) then
bounce away
end
if pad:down() then
bat1.y = bat1.y +2
end
if pad:up() then
bat1.y = bat1.y -2
end
if pad:cross() then
bat2.y = bat2.y +2
end
if pad:triangle() then
bat2.y = bat2.y -2
end
if pad:start() then
break
end
screen:print(136, 136, "Welcome to the world of PPP.", white)
screen.waitVblankStart()
screen.flip()
end
Setup a direction system for the ball and make collisions change its directio. then do if direction == blah then ballx = ballx-1 or whatever
Sry Tactical, to be honest, i didn't understand a (beep) of what you said.
Im a total n00b to lua...
Allright I hava a problem,
1st time in this thread so don't pLh4M3 me :tup:
When I run this code:
Spoiler for Code:
Lowser will just do nothing,
It loads something for about 2 seconds,
and then it doesn't do anything!
I can still use home and such...
Can someone help me?!?
btw: does anyone know where to download that luaplayer for windows that displays the error code, instead of just shutting off?
I know it exists......
:tup:on bounce away this is what i would do. I would assign a variable at the beginning of ur code outside of the main loop.... u know what let me just rewrite your codeZitat:
Zitat von gameo
Spoiler for Your code:
Right off the top if any other coders find problems tell me. or just fix it
Zitat:
Zitat von gameo
well, you cant just magically call a function called "bounceBall". set-up a physics system. ill get you started:
then..Code:ball = {x = 50, y = 50, img = Image.load("ball.png"), xMove = 3, yMove = 3 }
Code:ball.x = ball.x + ball.xMove
ball.y = ball.y + ball.yMove
if (ball hits paddle) then
ball.xMove = (something else)
ball.yMove = (something else)
end