Jump to content

Correct file structure


mehmet

Recommended Posts

  • Moderators

Yes, could be bad depending on your code style.

Because files are also code blocks. Which limit the accessibility of local variables.

 


Example, where it can go wrong:

 

File 1

local variableName = "can't be changed outside of this file"

function show ()
	iprint(variableName)  
end

 

File 2

variableName = "yes"

show () -- call the function show

 

It should output:

"can't be changed outside of this file"

Because the local variable can't be changed outside of it's scope.

 

 


 

Now put it in 1 file.

local variableName = "can't be changed outside of this file"

function show ()
	iprint(variableName)  
end

variableName = "yes"

show () -- call the function show

 

It should output:

"yes"

 

We have 1 file, 1 file scope. The `variableName` is available at the place where it is overwritten. (so the local variable will be overwritten)

 

 

  • Thanks 1
Link to comment
3 minutes ago, IIYAMA said:

Yes, could be bad depending on your code style.

Because files are also code blocks. Which limit the accessibility of local variables.

 


Example, where it can go wrong:

 

File 1


local variableName = "can't be changed outside of this file"

function show ()
	iprint(variableName)  
end

 

File 2


variableName = "yes"

show () -- call the function show

 

It should output:


"can't be changed outside of this file"

Because the local variable can't be changed outside of it's scope.

 

 


 

Now put it in 1 file.


local variableName = "can't be changed outside of this file"

function show ()
	iprint(variableName)  
end

variableName = "yes"

show () -- call the function show

 

It should output:


"yes"

 

We have 1 file, 1 file scope. The `variableName` is available at the place where it is overwritten. (so the local variable will be overwritten)

 

 

Thank's man. 
Can you show a good file structure?(screenshot)

Link to comment
  • Moderators
34 minutes ago, mehmet said:

Well, which one do you use?

Multiple resources and multiple files.

  • Every resource for every gamemode component. (hud, external interfaces)
  • And each file for sub tasks.

Sometimes it can be difficult to determine if you should split it up or not. Which can sometimes mean that it can actually be both.

When split it up? > If the tasks which the code full fill, are entirely different from each other.

 


 

As @CodyJ(L) did mention: performance

 

There are two types of performance showing up when doing this:

  • Computer performance.
  • Your own performance. (writing/reading code speed)

You will slowly learn how to keep those balanced, based on experience and inspiration. 

 

 

 

 

  • Thanks 1
Link to comment
10 hours ago, IIYAMA said:

Multiple resources and multiple files.

  • Every resource for every gamemode component. (hud, external interfaces)
  • And each file for sub tasks.

Sometimes it can be difficult to determine if you should split it up or not. Which can sometimes mean that it can actually be both.

When split it up? > If the tasks which the code full fill, are entirely different from each other.

 


 

As @CodyJ(L) did mention: performance

 

There are two types of performance showing up when doing this:

  • Computer performance.
  • Your own performance. (writing/reading code speed)

You will slowly learn how to keep those balanced, based on experience and inspiration. 

 

 

 

 

 


like that?
KvwxP

Link to comment
  • Moderators

Scoreboard isn't related to nametags. First-person isn't to both of them.

Hud might be related to scoreboard and yet it isn't.

So if you want to merge this in to a single resource. Then merge it in to the main gamemode. Because they aren't all huds (even though they might contain them).

 

And for the files:

/scripts/...

/fonts/...

 

 

Edited by IIYAMA
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...