forums.evilmana.com
Welcome, Guest. Please login or register.

Login with username, password and session length
September 08, 2010, 09:50:44 AM
.
News: 08/07/2009 - Welcome to the revived and revamped evilmana forums. Take a look around  for new features such as:New Theme, New Reputation System, and Arcade!
Coming Soon: An all new evilmana.com main site!
Pages: [1] 2 3 ... 5   Go Down
0 Members and 1 Guest are viewing this topic. Topic Tools  
Read September 12, 2008, 11:28:46 AM #0
dan369

Lua Turn based fighting

I've been looking into turn-based fighting and have made this (dl HereI need peoples help.The best way to improve is to realise mistakes & How-to improve on these mistakes. I need advice on How i can improve this! And for that i need your advice, tips and critiscm Smile  So if you could point out to me how i can improve it'll be grateful & useful Silly Tongue


Offline  
Read September 12, 2008, 11:58:20 AM #1
Buddy4point0

Re: Lua Turn based fighting

You didn't upload anything or post your code.


veiw my coding projects here
Offline  
Read September 12, 2008, 12:24:56 PM #2
dan369

Re: Lua Turn based fighting

Yeah, i did its at the top in brackets, (dl HERE


Offline  
Read September 12, 2008, 01:03:17 PM #3
yaustar

Re: Lua Turn based fighting

Indent the code properly and reupload.
Offline  
Read September 12, 2008, 01:13:14 PM #4
dan369

Re: Lua Turn based fighting

What do you mean by indent??


Offline  
Read September 12, 2008, 03:46:32 PM #5
osgeld

Re: Lua Turn based fighting

this is impossible to read
Code:
if stuff
blah
blah
blah
end
while
gruff
gruff
gruff
end
blah
blah
blah
end

this is not
Code:
if stuff
    blah
    blah
    blah
end

while
    gruff
    gruff
    gruff
end

blah
    blah
    blah
end

and theres an old saying ...
Quote from: Linus Torvalds
if you need more than three levels of indentation, your screwed anyway, and should go back and fix your program

which is fairly true
« Last Edit: September 12, 2008, 03:50:24 PM by osgeld »
Offline  
Read September 12, 2008, 03:59:32 PM #6
tacticalpenguin

Re: Lua Turn based fighting

Just because Linus said it doesn't mean it's absolutely true - I see LOTS of cases where more than 3 levels of indentation is fine and I really don't see why any number wouldn't have its use. example: if statement within for loop within while loop within function


tactical makes everything better
Offline  
Read September 12, 2008, 04:44:47 PM #7
TyPR124

Re: Lua Turn based fighting

Yea hell if you use states then your just about screwed automatically, cause you have the main loop and the state checking, which is two indentations before you even get to the actual code...


Code:
-- The Univers's script

createParticles()
createStarts()
createPlanets()
createGalaxys()
createOthers()

while LIVING_PEOPLE do --we are here ^.^
 Earth.health = Earth.health - 1
 
 if Earth.health <= 0 then
  Earth.Destroy()
  LIVING_PEOPLE = false
 end
end
Offline  
Read September 12, 2008, 05:11:22 PM #8
dan369

Re: Lua Turn based fighting

Oh...... I see what you mean, ok i'll do that.


Offline  
Read September 12, 2008, 05:40:06 PM #9
osgeld

Re: Lua Turn based fighting

Just because Linus said it doesn't mean it's absolutely true

um
Quote from: osgeld
which is fairly true

fairly != absolutely

and i have not ever seen a reason to go more than 3 PER BLOCK, 3 per entire program is a challenge ill agree with you all there
« Last Edit: September 12, 2008, 05:43:56 PM by osgeld »
Offline  
Read September 12, 2008, 06:02:47 PM #10
PL3X

Re: Lua Turn based fighting


and theres an old saying ...
Quote from: Linus Torvalds
if you need more than three levels of indentation, your screwed anyway, and should go back and fix your program

which is fairly true


that isn't entirely true although recurssion would be a better option if you are indenting that far, does lua support recursion?
Offline  
Read September 12, 2008, 06:04:46 PM #11
Buddy4point0

Re: Lua Turn based fighting

Ok, I just skimmed though your code quickly and there is a lot of things wrong with it.

You shouldn't have while true do inside of functions.


veiw my coding projects here
Offline  
Read September 12, 2008, 06:07:16 PM #12
PL3X

Re: Lua Turn based fighting

very true buddy, a function should only complete a small task and then return control to the main loop (for which there should only be one)
Offline  
Read September 12, 2008, 06:13:09 PM #13
osgeld

Re: Lua Turn based fighting

that isn't entirely true although recurssion would be a better option if you are indenting that far, does lua support recursion?

lua can, does luaplayer implement it, i have no idea

Offline  
Read September 12, 2008, 06:37:58 PM #14
dan369

Re: Lua Turn based fighting

Ok, I just skimmed though your code quickly and there is a lot of things wrong with it.

You shouldn't have while true do inside of functions.
Why? What else is wrong? They point of this is to relize my mistakes & how-to improve upon these mistakes &  to learn Smile

Edit: What if i Changed the While true do Loop To While player.health < 0 do Would that be better?? Or Use An alternative Method No while loop?
« Last Edit: September 12, 2008, 06:47:25 PM by dan369 »

Offline  
Pages: [1] 2 3 ... 5   Go Up
Jump to:  

Theme Update by Runic Warrior Originally created by m3talc0re