PSP Hacks - Forums
Go Back   PSP Hacks - Forums > Tech Talk > LUA Scripting

Notices

Reply
 
Thread Tools Display Modes
  #11  
Old 09-27-2005, 08:39 PM
RaiderX's Avatar
RaiderX RaiderX is offline
Administrator
PSP Titan
 
Join Date: Jun 2005
Posts: 900,010,784
RaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond repute
Default

ok, I'm gonna have to discect the original LUAfireworks to get the gravity code. The reaosn I wnat gravity is to add "tabletip" to my Wooly Willey game so u can drop all the dots to one side. i'll figure it out!
__________________
Reply With Quote
  #12  
Old 09-27-2005, 08:48 PM
qwerty qwerty is offline
Senior Member
PSP Guru
 
Join Date: Jun 2005
Location: Texas
Posts: 2,371
qwerty User Has a Beginner Reputation
Default

im stuck on the 8th level of laserix...
__________________

PSP 5.00 m33
Reply With Quote
  #13  
Old 09-27-2005, 11:23 PM
RaiderX's Avatar
RaiderX RaiderX is offline
Administrator
PSP Titan
 
Join Date: Jun 2005
Posts: 900,010,784
RaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond repute
Default

ooo. I forgot about that game, I ahd it but havent playede it yet. been too busy with other stuff. o well, i play it later.
__________________
Reply With Quote
  #14  
Old 09-28-2005, 01:01 AM
modsyn modsyn is offline
PSP Monk
 
Join Date: Aug 2005
Location: Shinigami Kurosaki Ichigo!
Posts: 2,966
modsyn User Has a Beginner Reputation
Default

This is an all-inclusive learning script. I didn't document the code at all,
but I have a bit at the top explaining what all I'm accomplishing with it
and how to test its funcionality.

Code:
--[[ Example Script for demonstrating swapping backgrounds and how to handle 
	files not being found in LUA. Also demonstrates the values of the analog
	stick, the os.time(), and the os.difftime() functions for getting time values.

	provided by modsyn.

	Test this script this way: put files 0.PNG, 1.PNG, 2.PNG, 3.PNG, 4.PNG and 5.PNG
	in the same directory as the script. Run the script, hitting X to reset the timer
	and swap the images. Then, delete one of the .PNG files and run it again. Instead
	of crashing (like I'm sure has happened with your scripts before) when the image is
	not found, it creates a blank canvas and writes a filenotfound error message to the
	screen.

	I hope everyone enjoys this. 
]]

System.usbDiskModeActivate()
red = Color.new(255, 0, 0);
white = Color.new(255, 255, 255);
black = Color.new(0,0,0)
canvas = Image.load("0.png")

mode = 0
oldTime = os.time()
time = 0

oldPad = Controls.read()
while true do

	pad = Controls.read()
	dx = pad:analogX()
	dy = pad:analogY()

	if pad:cross() then
		if pad ~= oldPad then
			time = os.difftime(os.time(),oldTime)
                  oldTime = os.time()
			mode = mode + 1
			if math.mod(mode, 6) == 0 then
				mode = 0
			end
                  file = io.open(tostring(mode)..".PNG","r")
                  if file then
				canvas = Image.load(tostring(mode)..".PNG")
			else
				canvas = Image.createEmpty(480, 272)
				canvas:clear(black)
                        canvas:print(120,120,"Image " .. tostring(mode+1) .. ".PNG not found!!!",white)
			end
		end
	end

	screen:blit(0, 0, canvas, 0, 0, canvas:width(), canvas:height(), false)
	screen:print(11, 11, "dx: " .. tostring(dx), white)
	screen:print(11, 21, "dy: " .. tostring(dy), white)
	screen:print(11, 31, "mode = " .. tostring(mode), white)
	screen:print(11, 41, "time difference = " .. tostring(time), white)
	screen.waitVblankStart()
	screen.flip()
	if pad:start() then break end
	if pad:select() then screen:save("screenshot.tga") end
	oldPad = pad
end
__________________
jMEnc Guide, jMEnc2 page - by the way, you smell nice
Reply With Quote
  #15  
Old 09-28-2005, 07:29 AM
RaiderX's Avatar
RaiderX RaiderX is offline
Administrator
PSP Titan
 
Join Date: Jun 2005
Posts: 900,010,784
RaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond repute
Default

hmmm. I like that. But does it prevent playign th game, or does it just show an error andthen continue?
__________________
Reply With Quote
  #16  
Old 09-28-2005, 11:20 AM
modsyn modsyn is offline
PSP Monk
 
Join Date: Aug 2005
Location: Shinigami Kurosaki Ichigo!
Posts: 2,966
modsyn User Has a Beginner Reputation
Default

it normally displays an image. if the image isn't found it shows a black
screen and a message but doesn't quit. normally, it will crash if you try
to load a picture that isn't found.
__________________
jMEnc Guide, jMEnc2 page - by the way, you smell nice
Reply With Quote
  #17  
Old 09-28-2005, 02:36 PM
LordCthulu LordCthulu is offline
Senior Member
PSP Veteran
 
Join Date: Mar 2005
Posts: 1,029
LordCthulu User Has a Beginner Reputation
Default

Hey modsyn I made a drawing script that includes your script to show the position of the analog stick.
I gave you credit in the readme. Lemme know if your cool with it.
Heres the script (also uploaded the .rar in my first post in this topic)

Code:
System.usbDiskModeActivate()
red = Color.new(255, 0, 0);
white = Color.new(255, 255, 255);
blue = Color.new(0, 0, 255);
black = Color.new(0, 0, 0);
green = Color.new(0, 255, 0);

canvas = Image.createEmpty(480, 272)
canvas:clear(white)

brush = {}
eraser = {}

x0 = 0
y0 = 0
x1 = 0
y1 = 0

drawColor = 0;

while true do

   pad = Controls.read()
   dx = pad:analogX()
   dy = pad:analogY()
	if math.abs(dx) > 32 then
		x0 = x0 + dx / 64
	end
	dy = pad:analogY()
	if math.abs(dy) > 32 then
		y0 = y0 + dy / 64
	end

	if pad:cross() then
      if drawColor == 0 then
         canvas:drawLine(x0, y0, x1, y1, black)
      elseif drawColor == 1 then
         canvas:drawLine(x0, y0, x1, y1, red)
      elseif drawColor == 2 then
         canvas:drawLine(x0, y0, x1, y1, blue)
      elseif drawColor == 3 then
         canvas:drawLine(x0, y0, x1, y1, green)
      end
   end

   if pad:up() then
      drawColor = 0
   elseif pad:down() then
      drawColor = 1
   elseif pad:left() then
      drawColor = 2
   elseif pad:right() then
      drawColor = 3
   end

   if pad:triangle() then
      canvas:clear(white)
   end
	x1 = x0
	y1 = y0
	screen:blit(0, 0, canvas, 0, 0, canvas:width(), canvas:height(), false)
	screen:drawLine(x1 - 5, y1, x1 + 5, y1, red)
	screen:drawLine(x1, y1 - 5, x1, y1 + 5, red)
   screen:print(11, 11, "X: " .. tostring(dx), red)
   screen:print(11, 21, "Y: " .. tostring(dy), red)

   screen.waitVblankStart()
   screen.flip()
   if pad:start() then break end
   if pad:select() then screen:save("screenshot.tga") end
end
__________________
Member number: 3
Meat lover? Watch: http://www.chooseveg.com/animal-cruelty.asp
Reply With Quote
  #18  
Old 09-28-2005, 05:21 PM
modsyn modsyn is offline
PSP Monk
 
Join Date: Aug 2005
Location: Shinigami Kurosaki Ichigo!
Posts: 2,966
modsyn User Has a Beginner Reputation
Default

i'm most definitely cool with it. anything i post here can be used by
anyone. most of that stuff i got from the tutorials, anyway.
__________________
jMEnc Guide, jMEnc2 page - by the way, you smell nice
Reply With Quote
  #19  
Old 09-28-2005, 08:18 PM
qwerty qwerty is offline
Senior Member
PSP Guru
 
Join Date: Jun 2005
Location: Texas
Posts: 2,371
qwerty User Has a Beginner Reputation
Default

NOOB question, sorry :oops: but, how do i make these into lua scripts?
__________________

PSP 5.00 m33
Reply With Quote
  #20  
Old 09-28-2005, 08:26 PM
RaiderX's Avatar
RaiderX RaiderX is offline
Administrator
PSP Titan
 
Join Date: Jun 2005
Posts: 900,010,784
RaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond reputeRaiderX has a reputation beyond repute
Default

open up notepad ans type in the script. Then save as "all files" and save it as "script.lua" or if u are gonna use it in the Lwoser application, "index.lua"
__________________
Reply With Quote
Reply

 



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:42 PM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©