You mean to unencrypt?
Printable View
You mean to unencrypt?
thats what i meant srry really tired
Just keep a spare, unencrypted script.
yeah i forgot to cause i was tired and just clicked it. now remembered i didnt have an extra
why do you encrypt lua codes? o_O
So nobody can copy his hard work. Although i don't encrypt my scripts.
The actual characters within the document also becomes fewer, and LuaPlayer reads the code faster as well.Zitat:
Zitat von eldiablov
you're saying that if i encrypt my code that my game will run faster?Zitat:
Zitat von HaxxBlaster
Yes. It'll save space too.Zitat:
Zitat von emericaska8r
what do you use to encrypt it?
i'm searching for it, i'll let you know when i find it
The Luac binary.
Make a new text file. Inside of it write:
Luac yourscriptname.lua outputname.lua
pause
Then rename it to Luac.bat and run it.
seems like there is a thing called luac which precompiles your code into binary files which will load faster, and protect your code.
-= Double Post =-
and XtreamLua Compiler
LuaC is different than XtreamLua Compiler. XtreamLua Compiler is harder to decrypt.
ok i need some more help here i got my animation to work I acutally didn't use animation lib but soulkiller's aniamtion instead :Punk: but i have a scrolling bg and when i move the whole animation comes with me here's my script if anyone wants to give a crack at it
[code]
--///////////////// Aquateen Created By : pspaquaforce, Thanks To Evilmana Tutorials\\\\\\\\\\\\\\\\ \\
--///////////////// Special Thanks : Jason215, soulkiller, Evilmana Forums
green = Color.new(0,255,0)
white = Color.new(255,255,255)
red = Color.new(255,0,0)
black = Color.new(0,0,0)
--// Player, Enemy, Ground , bullet
splash = Image.load("splashScreen. png")
--OPENING SPLASH SCREEN
screen:clear()
screen:blit(0,0,splash)
screen.flip()
screen.waitVblankStart(10 0)
backgroundCache = Image.load("image.png")
backgroundCache2 = Image.load("image2.png")
backgroundCache3 = Image.load("image3.png")
bullet = Image.createEmpty(4,4)
bullet:clear(red)
player1 = Image.load("figure.png")
Player = {}
Player[1] ={ x = 50, y = 200, gravity = 200, jumpspeed = 10, jumpstate= "ground"}
enemy1 = Image.load("shake.png") --// enemy image
Enemy= {}
Enemy[1] ={x = 400, y = 150, gravity = 200, jumpspeed = 10, jumpstate= "ground"}
BulletInfo = {}
for a = 1,5 do
BulletInfo[a] = { pic = bullet , firing = false, direction = "right", x = Player[1].x + 32,
y = Player[1].y + 16 }
end
Back1 = {} --------first scrolling background ( standard image 480 x 272)
Back1.x = 0 ----positioned at the start
Back1.y = 0
Back1.img = backgroundCache --- first background
Back2 = {} --------Second scrolling background ( standard image 480 x 272)
Back2.x = 480 ---- positioned precisely after the first background
Back2.y = 0
Back2.img = backgroundCache2 --- second background to scroll after first
Back3 = {} --------Third scrolling background ( standard image 480 x 272)
Back3.x = 960 ---- positioned precisely after the second background
Back3.y = 0
Back3.img = backgroundCache3 --- second background to scroll after second
ground = Image.load("ground.png")
frame1 = Image.load("frame1.png")
frame2 = Image.load("frame2.png")
frame3 = Image.load("frame3.png")
currentFrame = 1 --this represents which frame is displaying
counter = 0 --this is the frame counter which is used to determine when to change frames
--// Variable
oldpad = Controls.read()
currentBullet = 0
direction = "right"
--// Functions
function bulletFire()
for i = 1,5 do
if BulletInfo[i].firing == true then
if BulletInfo[i].direction == "right" then BulletInfo[i].x = BulletInfo[i].x + 10 end
if BulletInfo[i].direction == "left" then BulletInfo[i].x = BulletInfo[i].x - 10 end
screen:blit(BulletInfo[i].x,BulletInfo[i].y,BulletInfo[i].pic)
end
if BulletInfo[i].x < 0 or BulletInfo[i].x > 480 or BulletInfo[i].y < 0 or BulletInfo[i].y > 272 then BulletInfo[i].firing = false end
end
end
function bulletSetup()
--Increase the current bullet by one, or reset it to 1
if currentBullet < 5 then
currentBullet = currentBullet + 1
else
currentBullet = 1
end
if direction == "left" then
BulletInfo[currentBullet].x = Player[1].x
BulletInfo[currentBullet].y = Player[1].y + 16
end
if direction == "right" then
BulletInfo[currentBullet].x = Player[1].x + 32
BulletInfo[currentBullet].y = Player[1].y + 16
end
BulletInfo[currentBullet].direction = direction
BulletInfo[currentBullet].firing = true
end
function movePlayer()
pad = Controls.read()
if pad:left() then
Player[1].x = Player[1].x - 1.5
Back1.x = Back1.x + 3 ------ moves the background to scroll in the direction you are going
Back2.x = Back2.x + 3 ------ moves the background to scroll in the direction you are going
Back3.x = Back3.x + 3 ------ moves the background to scroll in the direction you are going
direction = "left"
end
if pad:right() then
Player[1].x = Player[1].x + 1.5
Back1.x = Back1.x - 3 ------ moves the background to scroll in the direction you are going
Back2.x = Back2.x - 3 ------ moves the background to scroll in the direction you are going
Back3.x = Back3.x - 3 ------ moves the background to scroll in the direction you are going
direction = "right"
end
if pad:up() then
Player[1].y = Player[1].y - 1
direction = "up"
end
if pad:down() then
Player[1].y = Player[1].y + 1
direction = "down"
end
end
function chasePlayer()
stallchase = math.random(2)
if stallchase == 1 then
if Enemy[1].x > Player[1].x then
Enemy[1].x = Enemy[1].x - 1.5
elseif Enemy[1].x < Player[1].x then
Enemy[1].x = Enemy[1].x + 2
end
end
end
function Jump() --// Function to jump
if pad:cross() and Player[1].jumpstate == "ground" then Player[1].jumpstate = "jumping"
end
if Player[1].jumpstate == "jumping" then
Player[1].jumpspeed = Player[1].jumpspeed - 0.5
Player[1].gravity = Player[1].gravity - Player[1].jumpspeed
end
if Player[1].gravity < 0 then
Player[1].jumpstate = "falling"
end
if Player[1].gravity < 200 and Player[1].jumpstate == "falling" then
Player[1].gravity = Player[1].gravity + (Player[1].jumpspeed + 3)
end
if Player[1].gravity == 200 then
Player[1].jumpspeed = 10
Player[1].jumpstate = "ground"
end
if Player[1].gravity > 200 then Player[1].gravity = 200
end
Player[1].y = Player[1].gravity
end
while true do
pad = Controls.read()
screen:clear()
counter = counter + 1
screen:clear()
if counter > 60 then --if 60 frames have passed
if currentFrame == 3 then --if we are on the last frame
currentFrame = 1 --go back to first frame (loops animation)
else
currentFrame = currentFrame + 1 --else goto the next frame
end
counter = 0 --reset the counter
end
if pad:circle() and oldpad:circle() ~= pad:circle() then
bulletSetup()
end
--// Loads Functions
movePlayer()
chasePlayer()
Jump()
--
--// blitting Image to screen and text
screen:blit(Back1.x, Back1.y, Back1.img) --- blits first background to the screen
screen:blit(Back2.x, Back2.y, Back2.img) --- blits second background to the screen
screen:blit(Back3.x, Back3.y, Back3.img) --- blits third background to the screen
screen:blit(Player[1].x, Player[1].y, player1)
screen:blit(Enemy[1].x, Enemy[1].y, enemy1)
screen:blit(0,262,ground)
bulletFire()
screen:print(10,10,"X: "..Player[1].x.." Y: "..Player[1].y,green)
screen:print(10,20,"Jumps tate: "..Player[1].jumpstate,green)
screen:print(400,10,"You Suck",green)
--
if currentFrame == 1 then --draw first frame
screen:blit(370,50,frame1 )
elseif currentFrame == 2 then --draw second frame
screen:blit(370,50,frame2 )
elseif currentFrame == 3 then --draw third frame
screen:blit(370,50,frame3 )
end
screen.waitVblankStart()
screen.flip()
end[code]
I'm trying to make a function that will load all the images in the sub directory "tiles" into a table. The code I've put together so far doesn't work, lua player quits with this error message:
error: tileloader.lua:15 attempt to index global 'files' (a nil value)
or
error: tileloader.lua:15 Image.load: error loading image
it depends on whether or not I use ".tiles/" or "tiles/"
can anyone tell me what I'm doing wrong?Code:loop1 = true
loop2 = true
tilenum = 1
files = {}
tiles = {}
white=Color.new(255,255,255)
-- load all images from tiles folder
function loadtiles(tiles)
loop1 = true
files = System.listDirectory("tiles/")
while loop1 do
tiles[tilenum] = Image.load(files[tilenum].name)
tilenum = tilenum +1
if files[tilenum].name == nil then loop1 = false end
end
end
loadtiles(tiles)
-- display images one at a time
loop1 = true
tilenum = 1
while loop1 do
loop2 = true
screen:blit (10,10, tiles[tilenum])
screen:flip()
while loop2 do
pad = Controls.read()
if pad:start() then loop2=false oldpad = pad end
end
tilenum = tilenum +1
if pad:start() and pad ~= oldpad then loop1 = false end
end
I just had a inquiry
which is more efficient, doing 3 if statements or using one if and 2 else if?
I would think they would be exactly the same. If not, it can't make that much of a difference.Zitat:
Zitat von dracule
I like the "if" statment its fun and understandable
example "if Homo.x == 69.x then
Gay = true
Dont use Gay on these forums.
Some people find it offensive.
the second one. and it does make a big difference. suppose you did this:Zitat:
Zitat von dracule
when you ran the script, the program would first check if x was 5. suppose it was. then the code that is inside executes. BUT, after the code is done, the computer AGAIN checks if x is 6 or 7, when it has already matched 5. thus, it wastes some time. this can make a huge difference in programs.Code:if x == 5 then
-- do whatever --
end
if x == 6 then
-- do whatever --
end
if x == 7 then
-- do whatever --
end
NOW, suppose you did this:
NOW, the compuet again checks if x is 5. suppose it is again. NOW, the code inside executes. after the code has been completed, the program sees the else if and IGNORES the other two if statements, because it knows that a match was made. thus, it saves some time.Code:if x == 5 then
-- do whatever --
elseif x == 6 then
-- do whatever --
elseif x == 7 then
-- do whatever --
end
how about saying Homosexuals or lezibions that is the proper way to call them. Gay is just a slang term for the meaning homosexualZitat:
Dont use Gay on these forums.
Some people find it offensive.
I don't think they would find it that offensive, unless your affended by it
Lezibions..hmm interesting. Sounds like a relative of the lion. JK.
Zitat:
Zitat von Merick
Try something like that. If you need to know why its for i = 3 and imagetable[i-2] its because listdirectory tables also contain two extra items, . and ..Code:imagetable = {}
tiledir = System.listDirectory("./
tiles")
for i = 3, table.getn(tiledir) do
imagetable[i-2] = Image.load("./tiles/"..tiledir[i].name)
end
That'll load every image in the directory into the table.
Thanks a lot, that fixed it right up! Now I get get to work on the rest of the program.
any idea about mine
I'll post the code I made for you a couple of days ago. It has notes (mine have !!! before and after), and it improves blitting, too (but it could still be better).
Spoiler for script:
EDIT:
I have a question:
Can someone send me a copy of Wedge Racer? I can't seem to download it, and I need the source as an example.
EDIT Again:
Nevermind. After six attempts on dial-up, I got it.
hmm, I'm having some trouble with tables in tables. In my tile loader, how would I make my "tiles" into a two-part table, one part with the image and the second part with the filename of the image?
*edit*
I think I've got it worked out now
thanks aphonia but you still didn't solve my problem. I wanted the animation to stay in one place instead of it moving with me. But thanls for fixing of some my errors
Use animlib to make it easier.
I don't like animlib i have a differnt code thats easier in my opion but i need the animation to stay in one place is there differnt side sroller that can have an object stay in one place?
try something like this:
animx and animy are the coordinates where you want the animation to appear at.if you want your animation to always appear at the same place on the screen then you could call it like this:Code:-- this creates a table with 3 images for the animation
-- if you want to use more than three, just continue with 4 =, 5 =, etc...
animation = { 1 = Image.load(frame1.png), 2 = Image.load(frame2.png), 3 = Image.load(frame3.png)}
-- this function draws the current frame
function animate(animx, animy, frame)
screen:blit(animx, animy, animation[frame])
end
replace the 50, 50 with whatever coordinates it is where you want the animation to appear at, and the animation will always be at that location. Just remember that for it to be visible you'll have to place the function call after the background images.Code:frame = frame + 1
if frame > 3 then frame = 1
animate(50, 50, frame)
thanks but i already have something like that. It's my side scroller that's causeing the problem i need something a little better:down: because this one kind of sucks
hmm...
Oh wait, I think I understand. Are you saying you want the animation to move with the background as it scrolls? Like say if you have a flag by a house in the bg and you want the flag to be waving in the wind
for x use (backx + animx)
for y use (backy + animy)
this will make the animation move with the bg as it scrolls
Use animlib, You say that you have an easier way yet your having so many problems, Just download animlib and learn how to use it.Zitat:
Zitat von pspaquaforce
i keep getting an error :Cry:
what error?
i can't really read it. It flashes to fast. here's the demo you can take a look because i'm really tired http://www.sendspace.com/file/dvgxx3
I got no error while playing.
Thats because i didn't post the one with the error