what type of code
Printable View
what type of code
are you sure you posted on the right thread lol
-= Double Post =-
some pointers:Zitat:
Zitat von omegaridley
1. use a menu
2. System.getDevSize() only returns the size, to show it e.g. System.message(System.get DevSize(),0)
3. that code is bad
4. i made one of these just to test all of the functions here is the code
Code:System.memclean()
System.usbDiskModeActivate()
white = Color.new(255, 255, 255)
red = Color.new(255,0,0)
green = Color.new(0,255,0)
blue = Color.new(0,0,255)
options = { "PSP Information", "Set Cpu Speed To 133", "Set Cpu Speed To 266", "Set Cpu Speed To 333", "Re-Load" }
current = 1
function printg(x, y, text, colour, display)
if colour == nil then
colour = Color.new(255, 255, 255)
end
if display == nil then
display = screen
end
for xbg = -1, 1 do
for ybg = -1, 1 do
display:print(x + xbg, y + ybg, text, Color.new(0, 0, 0))
end
end
display:print(x, y, text, colour)
end
function printgc(y, text, colour, display)
if colour == nil then
colour = Color.new(255, 255, 255)
end
if display == nil then
display = screen
end
x = 240 - ((string.len(text) * 8) / 2)
for xbg = -1, 1 do
for ybg = -1, 1 do
display:print(x + xbg, y + ybg, text, Color.new(0, 0, 0))
end
end
display:print(x, y, text, colour)
end
function Display_Menu()
for i = 1, table.getn(options) do
printgc(30 + ((i - 1) *10), options[i], white)
end
printgc(30 + ((current - 1) * 10), options[current], green)
end
if System.powerGetBatteryChargingStatus() == 1 then
bat_stat = "Charging"
else
bat_stat = "In Use"
end
function Menu_Controls()
if pad:up() and not oldpad:up() then
if current > 1 then
current = current - 1
else
current = table.getn(options)
end
elseif pad:down() and not oldpad:down() then
if current < table.getn(options) then
current = current + 1
else
current = 1
end
end
if pad:cross() and not oldpad:cross() and current == 1 then
System.message("PSP Version: " .. System.cfwVersion() .. "\nNick Name: " .. System.nickName() .. "\nBattery Status: " .. bat_stat .. "\nBattery Percentage: " .. System.powerGetBatteryLifePercent() .. "%" .. "\nTime Left: " .. System.powerGetBatteryLifeTime() .. "\nLua Player HM: V" .. System.playerVer(), 0)
elseif pad:cross() and not oldpad:cross() and current == 2 then
System.setLow()
elseif pad:cross() and not oldpad:cross() and current == 3 then
System.setReg()
elseif pad:cross() and not oldpad:cross() and current == 4 then
System.setHigh()
elseif pad:cross() and not oldpad:cross() and current == 5 then
dofile("./function_dump.lua")
end
end
oldpad = Controls.read()
while true do
pad = Controls.read()
screen:clear(blue)
-- insert your main code here
printgc(10, "Lua Player HM Function Dump By [email protected]", green)
Display_Menu()
Menu_Controls()
printgc(260, "Hi " .. System.nickName(), green)
-- insert your main code here
if pad:start() then
break
end
oldpad = pad
screen.waitVblankStart()
screen.flip()
end
thx [email protected], youve helped me yet again!
ur the best!!!
so now, what you told me should get the rest of my code to work.
this leaves me to 1 more question!
ok, on Ogg playback, the song I have only plays 1 time, How do I make it loop? here is the code I am using:
it works, the music plays, but it doesnt loop, so it only plays onceCode:Ogg.load("SYSTEM/music/system.ogg")
Ogg.play
looking at the commands in luaplayer hm for ogg files i would say it is probably one of these
Code:Ogg.EndOfStream()
Ogg.songTime()
Ogg.mode()
Yes, looking at the source Ogg.EndOfStream() returns a string "true" when an Ogg file has finished playing so just put in your main loop:
Code:if Ogg.EndOfStream() == "true" then
Ogg.play()
end
ok, i understand now, but after I put in that line of code, it game me this error:Zitat:
Zitat von SG57
:16: attempt to call field 'EndOfStream' (a nil value)
here is line 16:
it wont work, and the functions.txt even shows the function!!!Code:if Ogg.EndOfStream() == "true" then
any ideas?
did you acctually put code after
if Ogg.EndOfStream() == "true" then
??
or is that it?
cause if thats all you put, then you need to add
Ogg.play() end
yes, i put code afterZitat:
Zitat von PSProgramer
and it still isnt working...Code:if Ogg.EndOfStream() == "true" then
Do you have an Ogg loaded? Looking at the source code of LP, the eof integer is initialized to 0 when an Ogg is loaded so trying to access it before an Ogg is loaded will return nil..
so ur saying to load the Ogg AFTER this code is executed?:Zitat:
Zitat von SG57
cause, i can easily move the loading code below itCode:if Ogg.EndOfStream() == "true" then
-= Double Post =-
no that didnt work either, i dont understand, is it a bugZitat:
Zitat von omegaridley
i am using LuaPlayerHM v6.6, and the code u have me is in the functions list!
how do you get in to use the code?
omegaridley - You clearly didnt read my post correctly lol. I said nothing about moving things around or even to load after the code executes. i'm saying that in order for Ogg.EndOfStream() to return anything but nil, an Ogg must be loaded. That's all i'm saying for the second time. You should be able to figure out how to make sure an Ogg is loaded before executing code that contains Ogg.EndOfStream(), if not and even still please start with very early basics and fundamentals, learning by trial and error isn't a very good path to go.
scryerth - what...?
It sounds like you have a problem with your PSP, not LUA. LUA is just a scripting language for creating basic applications and games. Go post in the PSP General Help forum.Zitat:
Zitat von scryerth
i DO have an OGG loaded before the Ogg.EndOfStream(), look at my code:Zitat:
Zitat von SG57
but it STILL returns nil...Code:white = Color.new(255, 255, 255)
green = Color.new(0, 255, 0)
background = Image.load("SYSTEM/images/background.png")
Ogg.load("SYSTEM/music/system.ogg")
while true do
done = false
pad = Controls.read()
if pad:cross() and done == false then
System.message("UMD ISO will be dumped in name 9660.ISO, if u have a UMD dumped by this app, rename the ISO in the memory stick. Are you ready to dump the UMD?",1)
button = System.buttonPressed(1) if button == "yes" then UMD.ripISO("ms0:/ISO/9660.ISO") end
button = System.buttonPressed(1) if button == "no" then end
done = true end
if done == false then
if Ogg.EndOfStream() == "true" then
Ogg.play()
end
screen:blit(0, 0, background, false)
screen:print(1, 1, "Press X to Dump UMD Game", white)
end
i have tried Ogg.eos() and the error goes away, but doesnt loop the song...?
Code:white = Color.new(255, 255, 255)
green = Color.new(0, 255, 0)
background = Image.load("SYSTEM/images/background.png")
Ogg.load("SYSTEM/music/system.ogg")
Ogg.play()
while true do
done = false
pad = Controls.read()
if pad:cross() and done == false then
System.message("UMD ISO will be dumped in name 9660.ISO, if u have a UMD dumped by this app, rename the ISO in the memory stick. Are you ready to dump the UMD?",1)
button = System.buttonPressed(1) if button == "yes" then UMD.ripISO("ms0:/ISO/9660.ISO") end
button = System.buttonPressed(1) if button == "no" then end
done = true end
if done == false then
if Ogg.EndOfStream() == "true" then
Ogg.play()
end
screen:blit(0, 0, background, false)
screen:print(1, 1, "Press X to Dump UMD Game", white)
end
I need help. Not with scripting but generally, i dont understand wifi much and 3d and would like to know if there are any gd snippets/examples etc. Also with wifi you connect to an server? ( i think) could you possible connect to an web pg OR would you have 2 have your own server, if So how would you make an server?
I still cant get the Ogg to work...
-= Double Post =-
oops ignore my post, wrong forum...Zitat:
Zitat von jaki54321
So far i've created a basic menu for a game but i can't go into a sub-menu. When i go into the sub-menu it will execute the file once then go back to the main menu so i'm wondering what the best way to fix this is (i'm guessing some kind of loop)
EDIT: The sub-menu is a separate .lua file loaded into the main script through dofile
Could you post the code up? by sub-menu do u mean options, credits etc.
there is your problemZitat:
Zitat von drag_93
No, the problem is that he does not have a main loop in his sub-menu. My guess is that he copied the menu code from somewhere and has no idea how games and applications usually run.
how i can go to next line (with one string?) i used '\n' but it din't work :( (i see the square)
This would be an better example were u would use \n :)Code:
file:write("Player.x = 165 "...\n)
i will try thank you
you can only use the \n statement when saving to a file, you cant for examplr do this
screen:print(10, 10, "hello\n hi")
as it will be on one line, if you load it from a file then you can use
for line in file:lines() do
end
to display then sequentially on the screen
Wow...i haven't coded lua in a while. Do you guys recommend that i go back to it?
not if you know c no
Why not? Lua is like a sexy blonde chick. They are really hot and juicy, but they are very simple and ignorant to be enticed into your malicious intentions.
lol fine but there isnt much left to make, it mainly just for the fun of it that people make stuff in lua anymore
so true :)Zitat:
Zitat von FaT3oYCG
actually, there havent been many fun card games in lua that i know of, i am making one based of uno, when it is at least playable i am gonna release itZitat:
Zitat von FaT3oYCG
Not True ifiwere1337: PSPMillionaire BEST Lua Game Ever
thats not a card game, is it?Zitat:
Zitat von xpack
I wouldn't call PSPMillionaire an Card game:p more like an question game.Zitat:
Zitat von xpack
Just wondering, is there a known limitation in LuaPlayer 0.16 in that it doesn't support semi-transparency when blitting to an image?
I don't know for SURE but I almost always run stuff on 0.16 modded with a couple extra functions and I've never had any issues. Details about what you might be referring to and I'll try to recreate it
Well, I've got a image buffer, on which I blit unanimated objects at the start of a level and whenever something changes. I just noticed when I transfered one of my more complex objects (rather than just the little sprites I've only been using previously) from my blit-every-frame table to my blit-to-the-buffer table, that it was blocky and aliased. This seams to be because all semi-transparent pixels are being made fully-transparent. Here is the basic scenario:
The example image is attached, you will notice is looks a lot better when blitted directly.Code:object = {}
object.pics = {side = Image.load("side.png")}
object[1] = {type = "hexagonthing",x = 0, y = 0, width = 30,height = 30} --This would be created by an object.new function
object.intFunction = {
["hexagonthing"] = function(aObject)
object.buffer:blit(aObject.x,aObject.y,object.pics.side)
end
}
object.intDraw = function()
object.buffer = Image.createEmpty(480,272)
object.buffer:clear(Color.new(0,0,0))
for i,aObject in ipairs(object) do
object.intFunction[aObject.type](aObject)
end
end
object.intDraw()
while true do
screen:blit(0,0,object.buffer)
screen.waitVblankStart()
screen.flip()
end
P.S. Yeah, 0.16 is great apart from the few annoying things that are broken(SIO,Font:getTextSi ze, etc.)
OK, How would you make an object move without an if statement, AI? I want to move sumthing left and right without any IF statement.
Also How would you do it that so when the object is going back and forth and you hit into this object that you would DIE?
Note: Not good with collisions or Ai, thats why i'm asking 4 help :)
If you're going to make an AI it's probably going to have at least one if statement in it. If you want it to walk three spaces left then three spaces right and then loop you'd have to make a loop that checked its position or a counter and caused it to step left until its position was as far left as you wanted and then step right until its position was as far right as you wanted.
step = 0
while 1 do
if step < 3 then
stepleft()
else
stepright()
end
step = (step + 1) % 6
end
As for collision detection you'll just need to compare your x,y with the object's x,y and if they're equal then trigger your 'die' event or whatever. Sorry, this question is really too vague to give more of an answer.
There are tutorials available on AI and collision around the scene. Poke around a bit and see what you can find. These things are not as mysterious or difficult as they may sound.