PDA

View Full Version : Help with Lua



Shadowblind
August 4th, 2006, 03:55
I am just starting out with lua, and due to frustration I am NOT IN A RATIONAL MOOD. I am tryin to run the lua program by creating script.cmd, but when I double-click it it just brings up notepad.

WHAT AM I DOING WRONG?!

I am using the tutorials from evilmana

fg-54
August 4th, 2006, 03:59
ditto, hmmm, nice signature.:)

fg-54
August 4th, 2006, 04:04
I am just starting out with lua, and due to frustration I am NOT IN A RATIONAL MOOD. I am tryin to run the lua program by creating script.cmd, but when I double-click it it just brings up notepad.

WHAT AM I DOING WRONG?!
i have the seame problem.

Gizmo356
August 4th, 2006, 04:06
ok you write this in note pad luaplayer

whateveryourluascriptnameis.lua
pause

and save it in the lua player windows folder

Shadowblind
August 4th, 2006, 04:08
the thing is when I double click it like evilmana says, it doesnt start the engine

fg-54
August 4th, 2006, 04:08
note pad? what note pad?

Shadowblind
August 4th, 2006, 04:09
the text document

yaustar
August 4th, 2006, 04:09
Chances are that you have named the file
XXXX.cmd.txt
but since windows likes to hide extensions by defualt, you can't see .txt.

Go to:
Tools->Folder Options->View
and uncheck "Hide Extensions for known filetypes"

Click Apply, then Apply to All folders then OK.

In the batch file, it should be:

luaplayer NameOfLuaScript.lua
pause

fg-54
August 4th, 2006, 04:10
are you talking about that white square with a blue line on top? if you are, when i double click on it it apears for less then half a second, and then desapears.

fg-54
August 4th, 2006, 04:11
i don't have any files named XXXX.cmd.txt

Shadowblind
August 4th, 2006, 04:11
thats the windows lua

BTW I cant find tools, where would that be?

BL4Z3D247
August 4th, 2006, 04:12
cool the gizman is the teach :D

fg-54
August 4th, 2006, 04:13
can't find tools ether

yaustar
August 4th, 2006, 04:14
the batch file should look like this:
http://img480.imageshack.us/img480/4178/image1zy2.png (http://imageshack.us)

Shadowblind
August 4th, 2006, 04:14
its in your control panel

fg-54
August 4th, 2006, 04:15
it says "test" on the file i downloaded.

yaustar
August 4th, 2006, 04:16
*gah*
You do realise the XXXX means anything?

it says "test" on the file i downloaded.
Well double click on the damn thing to see the example.
http://img210.imageshack.us/img210/1294/image1of2.png (http://imageshack.us)

Shadowblind
August 4th, 2006, 04:16
yes, I know, have you read the first page of the tutorial fg
im pi**ed off about too many things right now

yaustar
August 4th, 2006, 04:18
Chances are that you have named the file
XXXX.cmd.txt
but since windows likes to hide extensions by defualt, you can't see .txt.

Go to:
Tools->Folder Options->View
and uncheck "Hide Extensions for known filetypes"

Click Apply, then Apply to All folders then OK.

In the batch file, it should be:

luaplayer NameOfLuaScript.lua
pause
Once you can view the extensions, then you rename the file AND the extension


yes, I know, have you read the first page of the tutorial fg?

BTW, how do I change the file type

im pi**ed off about too many things right now
Well cool off and try this later.

fg-54
August 4th, 2006, 04:18
yes.

yaustar
August 4th, 2006, 04:19
it says "test" on the file i downloaded.
You do realise the XXXX means any file name?
Well double click on the damn thing to see the example.

Shadowblind
August 4th, 2006, 04:20
Aha! I got it! fg-54 catch up while I cool the heck down.

Im restarting my comp because when I try the .cmd file it says Another program is already using this file

fg-54
August 4th, 2006, 04:22
the example shows a blue thunder looking thing, and a black screen on the back.

Shadowblind
August 4th, 2006, 04:23
what? what example are you talking about?

yaustar
August 4th, 2006, 04:24
the example shows a blue thunder looking thing, and a black screen on the back.
Good, that means it works.

fg-54
August 4th, 2006, 04:24
...the only example there is?

fg-54
August 4th, 2006, 04:25
soo...now what? the thing that says "luaplayer.exe" still desapears in less then one second. and i can't see the note pad luaplayer. where is it sopuse to be at?

BL4Z3D247
August 4th, 2006, 04:27
shadow don't worry bro it was the same experience for me the first time i look at the tuts, then i got pissed and couldn't figured out why i got errors, thats why i stopped

yaustar
August 4th, 2006, 04:28
*sigh*
If you read the tutorial, you should know that you run your Lua scripts with LuaPlayer (the exe) via batch files. The .cmd file that you are using is a batch file to show the example.

Shadowblind
August 4th, 2006, 04:30
the thing is every time I double click it to run luaplayer it says "Another Program is currently using this file"

fg-54
August 4th, 2006, 04:30
..........but i can't open the luaplayer.exe, it desapears in less then a second.

yaustar
August 4th, 2006, 04:34
@ Shadowblind: I dont have that problem. You might have a program that has the file open at the same time or a process that is still running using the file. Check task manager or reset the computer.

I also find that using .bat instead of .cmd is much easier to deal with.

fg-54
August 4th, 2006, 04:35
well, i can't restart my computer right now, but i haven't used any dofferent files when i double click on it.


here is what it looks like, i just took a picture:

http://i10.photobucket.com/albums/a119/fg-54/uyg001.jpg

yaustar
August 4th, 2006, 04:36
..........but i can't open the luaplayer.exe, it desapears in less then a second.
*oh FFS*
You dont run luaplayer directly.
You use batch files to run scripts with LuaPlayer like the example CMD file that you just ran

Shadowblind
August 4th, 2006, 04:36
Changing it to .bat still gets the same da** results, reseting the computer doesnt work

and fg-54, READ THIS: http://evilmana.com/tutorials/lua_tutorial_01.php

fg-54
August 4th, 2006, 04:37
batch files?CMD? are you speaking english?

yaustar
August 4th, 2006, 04:38
@Shadowblind: Something is screwed with the settings on your PC.

@fg_54: yes. CMD = .cmd files.
http://support.packeteer.com/documentation/packetguide/6.0.0/nav/tasks/administrative/create-command-file.htm
batch
http://en.wikipedia.org/wiki/.bat

fg-54
August 4th, 2006, 04:39
Inside the folder you extracted the files to create a text file with Notepad. Inside the file type where is that at?

fg-54
August 4th, 2006, 04:40
Something is screwed with the settings on your PC.

i told you shadowblind! my computer sucks! so what;s wrong with it?

yaustar
August 4th, 2006, 04:41
*thumps head on desk*
It says, create a blank text document inside the folder where Luaplayer is extracted (aka the same folder in your screenshot).

Open the file and type:

yaustar
August 4th, 2006, 04:42
i told you shadowblind! my computer sucks! so what;s wrong with it?
That comment wasn't aimed at you, it was at Shadowblind.
Your problem here is that you dont have a problem or not describing well enough.

What are you trying to do?

fg-54
August 4th, 2006, 04:45
oOOOooohhh.....so what do i do with the blank text again? by the way, here is a pic of that "test" looks like on my computer "the blue thunder looking thing"

http://i10.photobucket.com/albums/a119/fg-54/yfyu001.jpg

BL4Z3D247
August 4th, 2006, 04:46
shadow i had the same problem thats why i just used my psp

yaustar
August 4th, 2006, 04:46
I know full well what it looks like. I dont understand what the hell is your problem that you are trying to convey. Are you trying to run your own Lua script?

@Shadow: Is the .cmd or .bat file in any other program besides notepad?

fg-54
August 4th, 2006, 04:47
That comment wasn't aimed at you, it was at Shadowblind.
Your problem here is that you dont have a problem or not describing well enough.

What are you trying to do?

.....i'm trying to make a game....but first i want to start up that lua thing i need to make it.

yaustar
August 4th, 2006, 04:48
You do realise that LuaPlayer is NOT like GameMaker, Games Factory or Click and Play. You have to program for it like BASIC, Pascal, C/C++ etc.

Here is an example of a lua script/program that you run WITH LuaPlayer VIA batch files:

-- 2006-07-03
-- Added a pause and reset animation functions

-- 2006-07-02
-- Very quick and hacky animation test by yaustar
-- Note there are some REALLY bad practices here.

-- Preload some colours
GREEN = Color.new(0, 255, 0);
WHITE = Color.new(255, 255, 255);
BLACK = Color.new(0, 0, 0);

-- Constants for the various animations
Int_Standing = 1;
Int_Walking = 2;
Int_Attacking = 3;

-- Load the images
Image_Ken = {};
Image_Ken[Int_Standing] = Image.load("./KenStanding.png");
Image_Ken[Int_Walking] = Image.load("./KenWalking.png");
Image_Ken[Int_Attacking] = Image.load("./KenDragonPunch.png");

-- Properties for the Ken Sprite
KenSprite = {
Int_XPosition = 30,
Int_YPosition = 30,
Int_FrameWidth = 40,
Int_FrameHeight = 117,
Int_NumberOfFrames = 6,
Int_CurrentFrame = 0,
Int_FrameDelayInMs = 120,
Int_CurrentFrameTimerLapseInMs = 0,
Bool_Pause = false,
Int_State = Int_Standing,
Int_NumberOfTimesLooped = 0;
};

-- The update function for a sprite. Regulates the time between each frame and loops the animation
function UpdateGraphic(Sprite, Int_DeltatimeMs)
-- Check if the animation is paused
if not Sprite.Bool_Pause then
-- Update the timer lapse
Sprite.Int_CurrentFrameTimerLapseInMs = Sprite.Int_CurrentFrameTimerLapseInMs + Int_DeltatimeMs;

-- Check if the lapse is more then the Frame Delay
if Sprite.Int_CurrentFrameTimerLapseInMs > Sprite.Int_FrameDelayInMs then
-- If so, move to the next frame
Sprite.Int_CurrentFrame = Sprite.Int_CurrentFrame + 1;
-- Reset the Lapse
Sprite.Int_CurrentFrameTimerLapseInMs = Sprite.Int_CurrentFrameTimerLapseInMs - Sprite.Int_FrameDelayInMs;
end

-- Check if the current frame is the last one
if Sprite.Int_CurrentFrame == Sprite.Int_NumberOfFrames then
-- If so, loop back to 0
Sprite.Int_CurrentFrame = 0;
-- Increment the loop counter
Sprite.Int_NumberOfTimesLooped = Sprite.Int_NumberOfTimesLooped + 1;
end
end
end

-- Function to stop and resume the animation of a sprite
function PauseResume(Sprite)
Sprite.Bool_Pause = not Sprite.Bool_Pause;
end

-- Function to reset the animation of a sprite
function ResetAnimation(Sprite)
Sprite.Int_CurrentFrame = 0;
Sprite.Int_NumberOfTimesLooped = 0;
end

-- Function to check if the animation has finished
function CheckIfAnimationHasFinshed (Sprite)
if Sprite.Int_NumberOfTimesLooped > 0 then
return true;
else
return false;
end
end

-- Modify the state of the sprite
function ModifyState(Sprite, Int_IntendedAction)
-- If the Sprite is standing, then it can go to walking or standing
if Sprite.Int_State == Int_Standing and Int_IntendedAction ~= Int_Standing then
ResetAnimation(Sprite);
Sprite.Int_State = Int_IntendedAction;
return true;
end
-- If the Sprite is walking, then it can go to attack or standing
if Sprite.Int_State == Int_Walking and Int_IntendedAction ~= Int_Walking then
ResetAnimation(Sprite);
Sprite.Int_State = Int_IntendedAction;
return true;
end
-- If the Sprite is attacking, then do nothing
if Sprite.Int_State == Int_Attacking then
-- Do nothing
return false;
end

return false;
end

-- Update the sprite state
function UpdateState(Sprite)
-- If the Sprite is Attacking
if Sprite.Int_State == Int_Attacking then
-- If the Sprite has finsihed the attacking animation then go back to standing
if CheckIfAnimationHasFinshed(Sprite) then
ResetAnimation(Sprite);
Sprite.Int_State = Int_Standing;
end
end
end

-- Move the sprite by X and Y amount
function MoveSprite(Sprite, Int_X, Int_Y)
Sprite.Int_XPosition = Sprite.Int_XPosition + Int_X;
Sprite.Int_YPosition = Sprite.Int_YPosition + Int_Y;
end

-- Create a Timer Object
Clock = Timer.new();

-- Get the number of milliseconds since last call
function GetDeltatime()
local Int_Dtime = Clock:time();
Clock:reset();
Clock:start();
return Int_Dtime;
end

-- A Deley function to regulate FPS
function Delay(Int_NumberOfMsDelay)
-- Variable to keep count of the accumlated deltatime
local Int_CurrentTimePassed = 0;
-- Reset deltatime
GetDeltaTime();
-- While the accumlated deltatime is lower then Int_NumberOfMsDelay
while ( Int_CurrentTimePassed < Int_NumberOfMsDelay ) do
-- Loop
Int_CurrentTimePassed = Int_CurrentTimePassed + GetDeltaTime();
end
end

-- List of bools to store the last state of the Key
Bool_PadDLeftLastState = true;
Bool_PadDRightLastState = true;
Bool_PadDUpLastState = true;
Bool_PadDDownLastState = true;
Bool_PadDLbutLastState = true;
Bool_PadDRbutLastState = true;
Bool_PadDSqaureLastState = true;
Bool_PadDTriangleLastState = true;
Bool_PadDCrossLastState = true;
Bool_PadDCircleastState = true;
Bool_PadDSelectLastState = true;
Bool_PadDStartLastState = true;

-- true for Key Up, false for Key Down for readability
Bool_KeyUp = true;
Bool_KeyDown = false;

-- Main 'game' loop
while true do
-- Local move variables
Int_MoveX = 0;
Int_MoveY = 0;

-- Check if the dpad was pressed
Bool_DPadPressed = false;

-- Get the pad state
PspPadState = Controls.read();

-- Move the player
if PspPadState:up() then
ModifyState(KenSprite, Int_Walking);
if KenSprite.Int_State == Int_Walking then
Int_MoveY = -3;
Bool_DPadPressed = true;
end
end

if PspPadState:down() then
ModifyState(KenSprite, Int_Walking);
if KenSprite.Int_State == Int_Walking then
Int_MoveY = 3;
Bool_DPadPressed = true;
end
end

if PspPadState:left() then
ModifyState(KenSprite, Int_Walking);
if KenSprite.Int_State == Int_Walking then
Int_MoveX = -3;
Bool_DPadPressed = true;
end
end

if PspPadState:right() then
ModifyState(KenSprite, Int_Walking);
if KenSprite.Int_State == Int_Walking then
Int_MoveX = 3;
Bool_DPadPressed = true;
end
end

-- If the dpad was not pressed, go to standing state
if Bool_DPadPressed == false then
ModifyState(KenSprite, Int_Standing);
end

-- If the player has pressed start, exit the loop and end the 'game'
if PspPadState:start() then
break;
end

-- Pause / Resume the animation
if PspPadState:square() then
if Bool_PadDSqaureLastState == Bool_KeyUp then
PauseResume(KenSprite);
end
Bool_PadDSqaureLastState = Bool_KeyDown;
else
Bool_PadDSqaureLastState = Bool_KeyUp;
end

-- Restart the Animation
if PspPadState:triangle() then
if Bool_PadDTriangleLastState == Bool_KeyUp then
ResetAnimation(KenSprite);
end
Bool_PadDTriangleLastState = Bool_KeyDown;
else
Bool_PadDTriangleLastState = Bool_KeyUp;
end

-- Attacking button
if PspPadState:cross() then
if Bool_PadDCrossLastState == Bool_KeyUp then
-- Update the state of the sprite
ModifyState(KenSprite, Int_Attacking);
end
Bool_PadDCrossLastState = Bool_KeyDown;
else
Bool_PadDCrossLastState = Bool_KeyUp;
end

-- Update the Ken Sprite
UpdateState(KenSprite);

-- Get the deltatime
local Int_DeltatimeInMs = GetDeltatime();

-- Update the Ken sprite
MoveSprite(KenSprite, Int_MoveX, Int_MoveY);
UpdateGraphic(KenSprite, Int_DeltatimeInMs);

-- Blank the screen
screen:clear(WHITE);

-- Draw Ken to the screen
screen:blit(
KenSprite.Int_XPosition, -- X position of sprite
KenSprite.Int_YPosition, -- Y position of sprite
Image_Ken[KenSprite.Int_State], -- Image to blit
KenSprite.Int_CurrentFrame * KenSprite.Int_FrameWidth, -- X position in the Image to start blitting from
0, -- Y position in the Image to start blitting from
KenSprite.Int_FrameWidth, -- Width of the frame (clipping frame)
KenSprite.Int_FrameHeight -- Height of the frame (clipping frame)
);

-- Debug text
String_Display = "Current Frame: " .. KenSprite.Int_CurrentFrame;
screen:print(1, 1, String_Display, BLACK);
String_Display = "Deltatime: " .. Int_DeltatimeInMs;
screen:print(1, 9, String_Display, BLACK);

-- Wait for Vblank
screen.waitVblankStart(1);
-- Flip the buffers
screen.flip();
end

fg-54
August 4th, 2006, 04:50
i'm trying to run luaplayer.exe.

fg-54
August 4th, 2006, 04:52
You do realise that LuaPlayer is NOT like GameMaker, Games Factory or Click and Play. You have to program for it like BASIC, Pascal, C/C++ etc.

Here is an example of a lua script/program that you run WITH LuaPlayer VIA batch files:

.....huh?

yaustar
August 4th, 2006, 04:52
*breathes*
I try this another way. What are you expecting LuaPlayer to be?
I repeat: You do realise that LuaPlayer is NOT like GameMaker, Games Factory or Click and Play. You have to program for it like BASIC, Pascal, C/C++ etc.

BL4Z3D247
August 4th, 2006, 04:53
screen:print just so u know its not smilies lol

@fg: u code in the notepad silly

yaustar
August 4th, 2006, 04:54
screen:print just so u know its not smilies lol
I have edited it now. Cheers.

fg-54
August 4th, 2006, 04:56
screen:print just so u know its not smilies lol lol, i know!



I try this another way. What are you expecting LuaPlayer to be?
I repeat: You do realise that LuaPlayer is NOT like GameMaker, Games Factory or Click and Play. You have to program for it like BASIC, Pascal, C/C++ etc.

...i don't know....i've never seen it before so i can't expect anything, i have no idea what its gonna looks like.

yaustar
August 4th, 2006, 04:57
You have just ran the example. You know what it looks like. If you open test.lua in notepad you find the code used to create that example.

fg-54
August 4th, 2006, 04:58
...............huh?

yaustar
August 4th, 2006, 04:59
If you have this much trouble understanding what LuaPlayer is then I suggest going back to GameMaker. You don't seem to be ready for this yet.

fg-54
August 4th, 2006, 05:00
hmmm...for some reason i can't save the notepad.

yaustar
August 4th, 2006, 05:00
What do you mean you can't save the notepad?

fg-54
August 4th, 2006, 05:01
i'm 15...i know i'm retarded.

Shadowblind
August 4th, 2006, 05:01
Plz, someone show me a link to lua player.16 .20 WILL NOT CANNOT AND SHALLNOT WORK ON MY PSP

and fg: WHAT THE **** IS WRONG WITH YOU?!

fg-54
August 4th, 2006, 05:02
What do you mean you can't save the notepad?

never mind, i got it (not exactly sure how) but i got it.

BL4Z3D247
August 4th, 2006, 05:03
in the notepad go to FILE at the top and click save as and save it some where like in a folder called LUA on ur desktop and its saved

yaustar
August 4th, 2006, 05:03
Why did you ditch GameMaker again?

BL4Z3D247
August 4th, 2006, 05:05
shadow go here www.luaplayer.org, it should have all the versions

fg-54
August 4th, 2006, 05:05
Why did you ditch GameMaker again?


becouse its too limited.

Shadowblind
August 4th, 2006, 05:07
thank you blaze. Lua .20 left something on my mem stick that cannot be deleted: a folder called SA .02

yaustar
August 4th, 2006, 05:09
Are you sure you are not using the full features properly.

Regardless, I will say this. LuaPlayer (for Windows) is NOT designed for someone to create windows applications with. It WAS designed for easier debugging LuaPlayer scripts rather then having to keep uploading to the PSP.

What do you actually want to do in general? Create games for the PC? Learn how to program? Program on a console?

BL4Z3D247
August 4th, 2006, 05:10
first try and delete it from ur game icon on the XMB if that doesn't work make a backup of the root of ur MS with everything but the file u can't delete then format ur MS, then put it back on

Shadowblind
August 4th, 2006, 05:11
I want to run a script.lua by itself. I made it from the tutorial, and since I cant run it on my computer I want to run it on PSP. How can I do that?

fg-54
August 4th, 2006, 05:11
Are you sure you are not using the full features properly.

Regardless, I will say this. LuaPlayer (for Windows) is NOT designed for someone to create windows applications with. It WAS designed for easier debugging LuaPlayer scripts rather then having to keep uploading to the PSP.

What do you actually want to do in general? Create games for the PC? Learn how to program? Program on a console?

create games for the pc, and psp...and ds...

fg-54
August 4th, 2006, 05:13
hmmmm... its 12:12 pm in gainesville (florida) right now...i should probably go to bed in a few minutes.

yaustar
August 4th, 2006, 05:15
create games for the pc, and psp...and ds...
Then quite frankly I would NOT use Lua if you are trying to create a cross platform application. Especially with the DS in the mix. The DS does not have LuaPlayer, it uses a different Lua framework so the applications you develop for PSP (LuaPlayer) will NOT work with the DS unless major changes are made to the code.

LuaPlayer for windows doesn't cut it, you be better off using GameMaker and the internal scripting language in the engine (which is not too dissimilar in usage as Lua).

fg-54
August 4th, 2006, 05:18
i ment any of them, not all of them, it would be extremly hard to make a game for all of those systems.

BL4Z3D247
August 4th, 2006, 05:20
I want to run a script.lua by itself. I made it from the tutorial, and since I cant run it on my computer I want to run it on PSP. How can I do that?
just make a folder with the script.lua and anything else need to run the script, such as sprites or backgrounds and put it in the Applications folder in the Luaplayer .16 folder on ur psp

Shadowblind
August 4th, 2006, 05:22
-- Lua program 1
-- Author: Shadowblind

-- Green Color Object
green = Color.new(0, 255, 0)
-- Store birth year in variable myBirthYear
myBirthYear = 1992
-- Store current year in currentYear
currentYear = 2006
-- create an empty variable
myAge = nil
-- Store some text in a variable
someText = "My age is roughly 14 "
-- Subtract myBirthYear from currentYear and store in myAge
myAge = currentYear - myBirthYear
-- Print our text variable and age to the screen
screen:print(10,100,someText .. myAge,green)
-- Buffer offscreen to onscreen
screen.flip()
-- Loop forever
while true do
screen.waitVblankStart()
end

will this work?

yaustar
August 4th, 2006, 05:22
i ment any of them, not all of them, it would be extremly hard to make a game for all of those systems.

In which case:
PC: Either stick with GameMaker and the internal scripting language in the engine (which is not too dissimilar in usage as Lua) or learn Pygame (http://www.pygame.org/news.html) which will be FAR better for you in the long run.

PSP: Short route: LuaPlayer and Lua in which case, start reading evilmana.com tutorials.
Long Route: C/C++ with SDL and/or OpenGL

DS: Short route: Lua with their homebrew Lua Framework which as far as I can see is completely different to LuaPlayer barring the base Lua language.
Long route: C/C++ with SDL or without SDL.

fg-54
August 4th, 2006, 05:25
cool thanks! i should probably get to bed now... its 12:25 right now, i apreciate all of you'r help yaustar.

Shadowblind
August 4th, 2006, 05:26
ah perfect it worked

yaustar
August 4th, 2006, 05:26
Great, now I would appreciate in knowing which path you have chosen.

fg-54
August 4th, 2006, 05:26
wait....where is the engine? i can't find the engine on http://www.pygame.org/news.html

yaustar
August 4th, 2006, 05:27
wait....where is the engine? i can't find the engine on http://www.pygame.org/news.html
Downloads
http://www.pygame.org/download.shtml

BL4Z3D247
August 4th, 2006, 05:28
see ya on the flipside fg-54 :D

fg-54
August 4th, 2006, 05:28
Great, now I would appreciate in knowing which path you have chosen.

are you talking to shadowblind or me? well if you are talking to me i'm gonna see what pygame can do, and if its less limited then game maker i'll stick with that.

fg-54
August 4th, 2006, 05:30
i know, but there are about 20 different downloads there, wich one is the engine?

yaustar
August 4th, 2006, 05:30
are you talking to shadowblind or me? well if you are talking to me i'm gonna see what pygame can do, and if its less limited then game maker i'll stick with that.
Define limited, it has its own scripting engine that you can use so I cant see where the limits would be for a beginner like you.

yaustar
August 4th, 2006, 05:31
i know, but there are about 20 different downloads there, wich one is the engine?
The one under Windows which is the operating system that you are using.

And RTFM: http://rene.f0o.com/mywiki/PythonGameProgramming

Why am I going to get the feeling you are going to get the same problems again?

fg-54
August 4th, 2006, 05:34
..i dun know...anyways, i'll go to bed now, thanks again for you'r help, i'll just download everything until something comes up, bye!

yaustar
August 4th, 2006, 05:36
WTF? I give up. I really do.
http://img60.imageshack.us/img60/7708/image1ps5.th.png (http://img60.imageshack.us/my.php?image=image1ps5.png)

BL4Z3D247
August 4th, 2006, 05:38
yaustar deep breaths, in and out...there u go :D

yaustar
August 4th, 2006, 05:39
Does fg-54 even know what a programming language is?

Shadowblind
August 4th, 2006, 05:40
This did not work. Why?

-- Lua Project 2
-- Author: Shadowblind

-- Blue Color Object
blue = Color.new(0, 255, 0)
upPressed = 'You are pressing the "UP" button'
downPressed = 'You are pressing the "DOWN" button'
leftPressed = 'You are pressing the "LEFT" button'
rightPressed = 'You are pressing the "RIGHT" button'
-- *****Main Loop******
while true do
screen:clear()
pad = Controls.read()
if pad:up() then
screen:print(100,100,upPressed,green)
end
if pad:down() then
screen:print(100,100,downPressed,red)
end
if pad:left() then
screen:print(100,100,leftPressed,blue)
end
if pad:right() then
screen:print(100,100,rightPressed,yellow)
end
if pad:l() then
screen:print(100,100,LPressed,orange)
end
if pad:r() then
screen:print(100,100,'You are pressing the "R" button',yellow)
end
if pad:triangle() then
screen:print(100,100,'You are pressing the "TRIANGLE" button',green)
end
if pad:circle() then
screen:print(100,100,'You are pressing the "CIRCLE" button',green)
end
if pad:cross() then
screen:print(100,100,'You are pressing the "X" button',green)
end
if pad:square() then
screen:print(100,100,'You are pressing the "SQUARE" button',green)
end
screen.waitVblankStart()
screen.flip()
end

Shadowblind
August 4th, 2006, 05:40
and to answer your question yaustar: no, he doesnt.

yaustar
August 4th, 2006, 05:42
@shadowblind. Some of your colours haven't been created (eg green)

Shadowblind
August 4th, 2006, 05:44
green, huh? Thats the clor the tut told me to put... So how is that fixable?

BL4Z3D247
August 4th, 2006, 05:46
no he means u didn't create a variable for the color green, is that right oh wise one(yaustar)?

yaustar
August 4th, 2006, 05:47
Put it this way, you have created the colour blue like:
blue = Color.new(0, 255, 0)

But green, red, yellow etc haven't. Have a guess how it is fixable.

@Blaze: actually the variable has been created (where it is used) but not given a value hence it is crashing.

BL4Z3D247
August 4th, 2006, 05:50
:D thats why i called u the wise one

Shadowblind
August 4th, 2006, 05:51
ohhhhhhhhh thx man

Shadowblind
August 4th, 2006, 05:59
ok: Tables. I dont understand they're exact definition and what they do, and where to implement them.

myTable[1]
myTable[2]
myTable[3]
myTable[4]
myTable[5]

BL4Z3D247
August 4th, 2006, 06:01
hey yaustar is there a specific way to code the script, and are there techniques were can take to avoid annoying things in the end, like short cuts to make things a bit more easy on us?

dtothabreezy
August 4th, 2006, 06:07
tables is a place to hold infor mation i suugesst yousing as mouch of these as you can like if youd want to hold your charcters informatioon in a table it would be like
player{}
player.x=60
player.y=200
player.health=100


then you could call from that in your script such as to print your health you would do something like

screen:print(100,100,player.health)

or when you have to blit your charcter your charcters x and y wont be just variables like

screen:blit(player.x,player.y,playerimage)

you can youse that for anything and it saves you time hope that helps:cool:

tables and functions make things a lil easyer^^

BL4Z3D247
August 4th, 2006, 06:07
shadow my understanding of tables is they give information about the chacacter(s), like health, weapons, ect...correct me if i'm wrong yaustar

Shadowblind
August 4th, 2006, 06:11
hmmm... would a standard table be

green = Color.new(19, 20, 21)
red = Color.new(22, 23, 24)
orange = Color.new(25, 26, 27)
yellow = Color.new(28, 29, 30)

BL4Z3D247
August 4th, 2006, 06:15
yo dtothabreezy screen:blit(player.x,player.y,playerimage) what exactly does that do?

dtothabreezy
August 4th, 2006, 06:24
player .x is where your charcter is relative to x of the psp like a graph its the one that goes out y is the one that goes up if you were to minus or plus x it would give the illosion of movment ahhh :rolleyes: you get it

playerimage is what i use so it will blit all of the images i want in what way i want like if i would want playerimage to be him walking when you press right it would say playerimage=walk or something like that in my new animation system it runs off functions but i still keep that as a defualt to make it easier:cool:

BL4Z3D247
August 4th, 2006, 06:25
hmmm... would a standard table be

green = Color.new(19, 20, 21)
red = Color.new(22, 23, 24)
orange = Color.new(25, 26, 27)
yellow = Color.new(28, 29, 30)
i don't think so, i mean i'm just lookin at the tuts at evilmana i used a different site before(shoulda use evilmana :D) but i think thats just creating colour for the script to use, tables are used to store information about the character, like health, weapons, ammo, ect.

dtothabreezy
August 4th, 2006, 06:33
you could do something like that but you would be going out of your way to make that becuz most pepole just put those in at the top yall r the fastest posters ive seen in my life :cool:

o and so u know the colors when you put them in are like

the c in the color.new most be capatalized
color=Color.new(red,green,blue)
just remeber that so like to make green youd
green=Color.new(0,255,0) 255 is the most you can put in:cool:
dont worry itll come quickly after a while youll get yoused to it

BL4Z3D247
August 4th, 2006, 06:39
lol i know i do post fast :D

BL4Z3D247
August 4th, 2006, 06:51
shadow heres a table:

green = Color.new(0, 255, 0)
Enemy = { }
Enemy[1] = { type = "gargoyle", health = 100 }
Enemy[2] = { type = "vampire", health = 100 }
Enemy[3] = { type = "goomba", health = 100 }
Enemy[4] = { type = "ghost", health = 100 }
Enemy[5] = { type = "zombie", health = 100 }

Player = { }
Player[1] = { weapon = "sword", health = 100 }
Player[2] = { weapon = "knife", health = 100 }

while true do
pad = Controls.read()

screen:clear()

screen:print(5,10,"Player 1 Health: " .. Player[1].health,green)
screen:print(5,20,"Player 1 Weapon: " .. Player[1].weapon,green)

screen:print(250,10,"Enemy Health: " .. Enemy[1].health,green)
screen:print(250,20,"Enemy Type: " .. Enemy[1].type,green)

if pad:cross() then
Enemy[1].health = Enemy[1].health - 5
end

screen.waitVblankStart()
screen.flip()
end

oldpad = Controls.read()

if pad:cross() and oldpad:cross() ~= pad:cross() then

oldpad = pad

if pad:cross() and oldpad:cross() ~= pad:cross() and Enemy[1].health > 0 then

...thats right off of evilmana, i think this is concidered the tabels(arrays)

yaustar
August 4th, 2006, 08:02
I have a shot at explaining the concept of a table.
Think of a variable as a storage box. The box can be empty (nil) or it can have something in it. Eg, value, image, text etc.

Now a table is a stack of these boxes and you can refer to them as Box 1, Box 2 etc. You can remove or insert boxes into/out of this stack and you can refer the stack of boxes as a group under one name.

That's the concept, the syntax in Lua can be cofusing so I let the Wiki deal with that.
http://lua-users.org/wiki/TablesTutorial

Note that tables are also refered to as arrays in places.


Enemy = { }
Enemy[1] = { type = "gargoyle", health = 100 }
Enemy[2] = { type = "vampire", health = 100 }
Enemy[3] = { type = "goomba", health = 100 }
Enemy[4] = { type = "ghost", health = 100 }
Enemy[5] = { type = "zombie", health = 100 }
What you have done here is created a table called 'Enemy' and for each entry/storage box in 'Enemy' created another table that has two entries; 'type' and 'health'.

Shadowblind
August 4th, 2006, 21:22
fg-54 is having this problem: He has script.lua and script.cmd in the same file, when he runs script.cmd it says no lua file in the directory. Whats wrong?

BTW, can you make a simple game using a table? Thats what evilmana wants me to do...

Therefore, I can open your code and see how its placed.

BL4Z3D247
August 4th, 2006, 21:31
fg-54 is ur script.lua still a text file? when u save it make sure to change the type of of the file, use "all files" and then save ur script.lua again, u'll have a lua file now(well u should) then just delete the txt file of ur script

fg-54
August 4th, 2006, 21:38
they are, but i can only make one lua file (they can't all have the seame name)

Shadowblind
August 4th, 2006, 21:40
he sent me a screenshot, here:
http://www.box.net/public/lpzmnq8sn9

this is what it looks like, but the .cmd file still doesnt appear to be runing it.

BL4Z3D247
August 4th, 2006, 21:42
it can't be in a txt file, ok, go to file on the notepad, then save as, then at the bottom of the save box look for file type, its gunna say "*.txt" right? change that to "all files" then save it as "script.lua"

edit: ok after lookin at ur screenshot i'm kinda baffled, cuz u have a script.lua in the folder :confused:, i wonder y it won't work

fg-54
August 4th, 2006, 21:47
i did that, but it doesn't work. look at the screen shot.

yaustar
August 4th, 2006, 23:00
What is in script.cmd?