Help the PSP 3D community grow! Vote for us below:


| | Development Center - Learn the basics of coding or talk about advanced coding techniques with other developers. |
Welcome to PSP3D.com - Sony PlayStation Portable News, Homebrew, Hacks, Reviews, Videos, Mods, Forums!
You are currently viewing our website as a guest, which gives you limited access to reply and interact to discussions and other members. By joining our free community, you will be able to post topics in the forums, communicate privately with other members, vote in polls, and access many other special features.
Registration is fast, simple, and absolutely free so join our community today!
| 
07-09-2006, 10:41 AM
| | Member | | Join Date: Jun 2006 Location: in ur ass | | some definitions ok im still a begginer in lua i need an explanation fo these codes
math.randomseed()
ok bitween the 2 bracets some script have numbers in them like this
math.randomseed(32)
so wuts this whole function do?
and the second code is about functions for instans
function input(some code in here) <-- question 1 = wut dose this code bitween the bracets do?
function input()
local (some code) <-- and for the local wuts the diffrence between the local and
the code between the bracets both deicribes the function as i know
please replay ASAP
thnx in advance
Last edited by omar_omar2 : 07-27-2006 at 01:51 PM.
| 
07-09-2006, 11:12 AM
| | Senior Member
My Mood: | | Join Date: Jan 2006
Posts: 351
Points: 41.54 Donate | | Ill have to get back to you about randomseed (hint, do a search), but I cn certainyl tell you about the brackets.
Its known as parameter passing. Say you declare a variable in your main procedure, and then you want to do stuff to it, well, thats what parameter passing is, sorta.
Ill give you the easiest example. Don't say that its just convoluted code, it's an example!!!
function multiply(a,b)
x = a*b
end
while true do
multiply(8,2)
screen  rint(0,0,x,black)
end
the output on the screen would be 16, get it?
it assigns the variables of the function by passing the parameters over.
Hope this helps. | 
07-09-2006, 09:50 PM
| | Member | | Join Date: Jun 2006 Location: in ur ass | | | yea kinda'f but still i really need to know wut mth.randomseed() is
and wut dose the # between the bracets do for it
btw, wuts the diffrence between a local and and the function for example:
function input()
local player = 2
pad = Controls.read()
end
so wuts the diffrence between the local and the pad = Controls.read()
we could've jus put
function input()
local pad = Controls.read()
end
dosent that work? | 
07-10-2006, 12:01 PM
| | Member | | | | | | 
07-12-2006, 06:40 PM
| | Senior Member
My Mood: | | Join Date: Jan 2006
Posts: 351
Points: 41.54 Donate | | | a local variable is one thats only in scope in one part of a program.
And randomseed thingy seeds the ran# generator. | 
07-27-2006, 01:56 PM
| | Member | | Join Date: Jun 2006 Location: in ur ass | | hi,
randomseed is required for AI and im coding an enemy.
So i would like an explanation of this chunk of codes:
math.randomseed(os.time() )
time = os.time()
dateString = os.date("%c", time)
I was reading a script and I found this code ( the script has AI).
And from before i heard that AI requirs randoomseed etc.
I understand the first line but these lines seem to be very complex to me 
so please i need an explanation of these codes
time = os.time()
dateString = os.date("%c", time)
thank u all in advance  | 
07-27-2006, 02:00 PM
| | Senior Member | | Join Date: Jun 2006 Location: C:\windows\fonts\gigabyte.tff
Posts: 612
Points: 0.93 Donate | | | wow. this is like a new language for me... .... ill bet its hard | 
07-27-2006, 03:00 PM
| | Member | | Join Date: Jun 2006 Location: in ur ass | | | never mind about my prev question
i have another question but now it not definitions
the only probelm with my game is that it getting very messy cuz all of my codes are in one script
and if i want to put them in seperate scripts i have to use the dofile command its gonna immediatly excute the code and the code is not ment to be excuted it just some arrays so i heard about the io.open() but that only reads one line so is it possible to use the io.open() to read the whole file with out excuting the code ?
thnx in advance | 
07-27-2006, 06:20 PM
| | Senior Member
My Mood: | | Join Date: Jan 2006
Posts: 351
Points: 41.54 Donate | | ye, you create a lua file of all the little functions you want to do, for example drawing the different mode screen's outputs, then dofile on it in index.lua. Nothing will appear to change, but you will then be able to call the functions you declared in your other lua script. Not difficult, but its a bad explanation!!!
EG: in one lua file, perhaps called functions.lua:
function menu(
screen  rint(x,y,option,color@new(255,255,255)
end
then in index.lua
dofile ("./functions.lua")
while not pad:start()
menu()
end
Obviously not a working lua script, but its pseudocode that outlines how it works. | 
07-27-2006, 07:01 PM
| | Moderator / Pastafarian
My Mood: | | Join Date: Jan 2006 Location: sda1:/sys/kernel
Posts: 2,422
Points: 356.24 Donate | | Quote: |
Originally Posted by GIGABYTE wow. this is like a new language for me... .... ill bet its hard | Actually, though I have no programming experience in any language, Lua and Python are probably the two easiest languages you could find. | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is On Points Per Thread View: 0.00 Points Per Thread: 1.00 Points Per Reply: 0.10 | | | | |