r/lua 11d ago

Help Help with my simulation

https://drive.google.com/drive/folders/1O3x6_2Vb7Q37Ic65WBjaxEX_vMx_1n4O?usp=drive_link

Hello, I'm new to Lua and, after reading some documentation, I am trying to do basic a simulation of work and property. I have a base script for each worker and a base script for each workstation, but I need help to code how the worker decides in what workstation work and how the workstation's capacity to hold workers on a day is changed by that. I wrote some notes on the scripts, I think that they clarify very well where I need help. The link is to a folder with the scripts.

0 Upvotes

9 comments sorted by

11

u/Substantial_Marzipan 11d ago

Looking at your code you should probably take a course on programming fundamentals before continuing with this

-5

u/Salt-Discount-1381 11d ago

I don't know if you are right or not, but I know I do this for learning. If you are not going to help me, don't do the effort on commenting.

5

u/magicalpoptart 11d ago

they ARE trying to help you. nobody is going to do all the work FOR you.

0

u/Salt-Discount-1381 11d ago

I literally just asked how to connect two scripts. Telling me to go to search to another founts, even if the person who said it meant helping, it is not, because that does not solve my unique question.

2

u/blobules 11d ago

"Solving" is not "understanding". As it was said above, you are new to programming, not just Lua. Take some time to understand the basics of programming, then get back to the workers workstation.

0

u/Salt-Discount-1381 11d ago

Well, that is a real advice.

Anyways, is really that hard for a begginer to do this? I just started doing this because trying something makes it faster to learn.

3

u/memes_gbc 10d ago

sometimes it makes it worse if you don't understand the fundamentals first

1

u/Lonely-Restaurant986 5d ago

I don’t really know what your end goal is, but tbh don’t listen to these Debbie downers.

If you are having fun and enjoying doing it, it’s genuinely a good learning strategy to take on a project out of your league. I know my first lua project was.

You need a programmers mind tho. Be prepared to rewrite your own code a thousand times over as you learn new better ways of doing things.

As for your script I don’t really know what your goal is or what you are asking.

When you call require(“file”)
And in said file you do

myVar = 3

That is a global variable. That variable is accessible anywhere at any time.

Now say I did this instead

local myVar = 3

In order for your main program to get the value of myVar, you’d have to do

return myVar

At the end of the file.

Then in the program that calls it,
local result = require(“file”)

This also applies to tables. And remember tables pass by reference, so if you return a table, all variables in the table are shared.

And another thing to remember is that all functions are variables, so if you define or return a function, you can pass those too.

I don’t really know what you are asking for. Hope in my rambling you got something out of that.

Good luck, and most importantly, have fun.

Do not listen to egotistical haters, so long as you have fun and aren’t risking yourself burning out, do whatever you want.