technical questions

Place to get help with not working mods / modding interface.
Post Reply
vtx
Fast Inserter
Fast Inserter
Posts: 150
Joined: Tue Jun 28, 2016 9:48 am
Contact:

technical questions

Post by vtx »

AND

Did it work like all other programming language ?

Code: Select all

if not a AND not b AND not c then hello world! end
Hello world will only be display when all value are not false ?

Function

I need to access player within myfunction did I have to place it in argument ?

Code: Select all

myfunction(player,max)
or

Code: Select all

myfunction(max)
Scope and good programming

The variable that I'll only use within myfunction did I have to prefix it with local or the default behavior is local ?

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: technical questions

Post by bobingabout »

AND, look up LUA definitions.

Long story short though, when looking at it from the True/False logic perspective... It will check the first entity first. if it fails, it ends. if it doesn't fail, it checks the next condition. There is a lot more to it than that though, because you can compare numbers, or strings, etc.


Functions.

There are actually several different ways to do a function. If you are in a single player game, you don't need to pass the player variable. However, that is bad practice, since the mod may be used in multiplayer. You should instead make use of game.players[]. Now, you could pass the game.players[#] variable directly, but I would recommend sending game.players[#].index... or just the # part as: myfunction(player_index,max). Then in the function, you access the player using game.players[player_index].

I hope that clears a few things up.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

Post Reply

Return to “Modding help”