Author Topic: HOW-TO: Use basic if's and ends  (Read 2873 times)

0 Members and 1 Guest are viewing this topic.

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
HOW-TO: Use basic if's and ends
« on: 25 December, 2003, 20:37:06 »
ok while i here a quick little thread to remind you if the tabbing system

for if end

for for end

== is if it eqals

= is it make it equal


ok tabs

ok here is one of a projects main function ive been working on, i have removed lotsa stuff so you see only an example this will not work for you

Code: [Select]

function Main()
SendToAll("test")
RestartMain()
KillFunctions()
ChecksRestarts()
UpdateText(Retarted,Endline)
for i,v in Use do
UseFunction(v)
if return == 1 then
return 3 = 4
end
end
end



now for tabbing look how messy it looks, first tab all the lines that the function looks over

Code: [Select]
function Main()
SendToAll("test")
RestartMain()
KillFunctions()
ChecksRestarts()
UpdateText(Retarted,Endline)
for i,v in Use do
UseFunction(v)
if return == 1 then
return 3 = 4
end

now there is a for, every for must come to an end

Code: [Select]

function Main()
SendToAll("test")
RestartMain()
KillFunctions()
ChecksRestarts()
UpdateText(Retarted,Endline)
for i,v in Use do
UseFunction(v)
if return == 1 then
return 3 = 4
end -- if
end -- for
end -- function

now to tab them up more

Code: [Select]

function Main()
SendToAll("test")
RestartMain()
KillFunctions()
ChecksRestarts()
UpdateText(Retarted,Endline)
for i,v in Use do
UseFunction(v)
if return == 1 then
return 3 = 4
end -- if
end -- for
end -- function


now for some ppl this will be confusing at first so re read it sorry i sometimes dont make sense to myself lol but theres a little reminder, that how i used to remind myself lol

l8rr,,
Resistance is futile!

PtokaX forum

HOW-TO: Use basic if's and ends
« on: 25 December, 2003, 20:37:06 »

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #1 on: 25 December, 2003, 21:57:11 »
One easy way to is:

To each function there is always an end.
And to every if there is always an end.
And to every for there is always an end.

and if you use:


if
elseif
elseif

it will be just one

end

what do you guys call this "table" call for ?? my english sucks
right now...

accociative or ???
//NL

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #2 on: 25 December, 2003, 22:33:18 »
associative (or something like that, terible word 2 spell).

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #3 on: 25 December, 2003, 22:34:47 »
if you associate something with something i guess yes its

associate lol :)

Damn PLOP NOOOOOOOOOO!!!! :P

that screen i used to see it every 2 minutes on win98 lol
Resistance is futile!

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #4 on: 25 December, 2003, 22:44:37 »
the key is associated with a vallue, thats why some wise ass named it an associative array.
maby a linked array would have been easyer, definatly 2 spell.

good that you like my avatar phatty.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Offline kepp

  • Scripter
  • King
  • ******
  • Posts: 790
  • Karma: +2/-0
(No subject)
« Reply #5 on: 26 December, 2003, 23:42:45 »
I never understood why either, but with a little google search i found out that it's purposes is, to keep up the structure of the code.
and yes, i aslo notice that it became very easy to read it that way aswell..

:D
« Last Edit: 26 December, 2003, 23:43:13 by kepp »
Guarding    

PtokaX forum

(No subject)
« Reply #5 on: 26 December, 2003, 23:42:45 »