#StackBounty: #c++ #lua #entity-component How to store Lua script's inner state?

Bounty: 50

Situation:

  • I am working on an Entity-Component system, and I am using LuaBridge as a Lua binder.

  • There is only one Lua State.

  • Currently when I update the game objects, I just check whether it has a script defined or not. If there is, I call luaL_dostring() on it, and I call its update() function.

  • I have a script, where I declare a global variable in its start() (it is called when the script runs for the first time), and increment it at every update() then print it out

Question:

  • I would like to achieve separated inner state saving for my scripts.
    • For example If I add the same script to two different game objects, currently the printed out numbers will be 1,2,3,4,5,6 instead of 1,1,2,2,3,3, etc.
    • This is because they use the same Lua State (correct me if I am wrong)

    • But as I heard it’s not a good practice to have a lua state for every script because If I just have 5 scripts, and I add these to 3 different game objects, there would be already 15 lua states.

How should I achieve my goal?


Get this bounty!!!

#StackBounty: #c++ #lua #entity-component How to store Lua script's inner state?

Bounty: 50

Situation:

  • I am working on an Entity-Component system, and I am using LuaBridge as a Lua binder.

  • There is only one Lua State.

  • Currently when I update the game objects, I just check whether it has a script defined or not. If there is, I call luaL_dostring() on it, and I call its update() function.

  • I have a script, where I declare a global variable in its start() (it is called when the script runs for the first time), and increment it at every update() then print it out

Question:

  • I would like to achieve separated inner state saving for my scripts.
    • For example If I add the same script to two different game objects, currently the printed out numbers will be 1,2,3,4,5,6 instead of 1,1,2,2,3,3, etc.
    • This is because they use the same Lua State (correct me if I am wrong)

    • But as I heard it’s not a good practice to have a lua state for every script because If I just have 5 scripts, and I add these to 3 different game objects, there would be already 15 lua states.

How should I achieve my goal?


Get this bounty!!!

#StackBounty: #c++ #lua #entity-component How to store Lua script's inner state?

Bounty: 50

Situation:

  • I am working on an Entity-Component system, and I am using LuaBridge as a Lua binder.

  • There is only one Lua State.

  • Currently when I update the game objects, I just check whether it has a script defined or not. If there is, I call luaL_dostring() on it, and I call its update() function.

  • I have a script, where I declare a global variable in its start() (it is called when the script runs for the first time), and increment it at every update() then print it out

Question:

  • I would like to achieve separated inner state saving for my scripts.
    • For example If I add the same script to two different game objects, currently the printed out numbers will be 1,2,3,4,5,6 instead of 1,1,2,2,3,3, etc.
    • This is because they use the same Lua State (correct me if I am wrong)

    • But as I heard it’s not a good practice to have a lua state for every script because If I just have 5 scripts, and I add these to 3 different game objects, there would be already 15 lua states.

How should I achieve my goal?


Get this bounty!!!

#StackBounty: #c++ #lua #entity-component How to store Lua script's inner state?

Bounty: 50

Situation:

  • I am working on an Entity-Component system, and I am using LuaBridge as a Lua binder.

  • There is only one Lua State.

  • Currently when I update the game objects, I just check whether it has a script defined or not. If there is, I call luaL_dostring() on it, and I call its update() function.

  • I have a script, where I declare a global variable in its start() (it is called when the script runs for the first time), and increment it at every update() then print it out

Question:

  • I would like to achieve separated inner state saving for my scripts.
    • For example If I add the same script to two different game objects, currently the printed out numbers will be 1,2,3,4,5,6 instead of 1,1,2,2,3,3, etc.
    • This is because they use the same Lua State (correct me if I am wrong)

    • But as I heard it’s not a good practice to have a lua state for every script because If I just have 5 scripts, and I add these to 3 different game objects, there would be already 15 lua states.

How should I achieve my goal?


Get this bounty!!!

#StackBounty: #c++ #lua #entity-component How to store Lua script's inner state?

Bounty: 50

Situation:

  • I am working on an Entity-Component system, and I am using LuaBridge as a Lua binder.

  • There is only one Lua State.

  • Currently when I update the game objects, I just check whether it has a script defined or not. If there is, I call luaL_dostring() on it, and I call its update() function.

  • I have a script, where I declare a global variable in its start() (it is called when the script runs for the first time), and increment it at every update() then print it out

Question:

  • I would like to achieve separated inner state saving for my scripts.
    • For example If I add the same script to two different game objects, currently the printed out numbers will be 1,2,3,4,5,6 instead of 1,1,2,2,3,3, etc.
    • This is because they use the same Lua State (correct me if I am wrong)

    • But as I heard it’s not a good practice to have a lua state for every script because If I just have 5 scripts, and I add these to 3 different game objects, there would be already 15 lua states.

How should I achieve my goal?


Get this bounty!!!

#StackBounty: #c++ #lua #entity-component How to store Lua script's inner state?

Bounty: 50

Situation:

  • I am working on an Entity-Component system, and I am using LuaBridge as a Lua binder.

  • There is only one Lua State.

  • Currently when I update the game objects, I just check whether it has a script defined or not. If there is, I call luaL_dostring() on it, and I call its update() function.

  • I have a script, where I declare a global variable in its start() (it is called when the script runs for the first time), and increment it at every update() then print it out

Question:

  • I would like to achieve separated inner state saving for my scripts.
    • For example If I add the same script to two different game objects, currently the printed out numbers will be 1,2,3,4,5,6 instead of 1,1,2,2,3,3, etc.
    • This is because they use the same Lua State (correct me if I am wrong)

    • But as I heard it’s not a good practice to have a lua state for every script because If I just have 5 scripts, and I add these to 3 different game objects, there would be already 15 lua states.

How should I achieve my goal?


Get this bounty!!!

#StackBounty: #c++ #lua #entity-component How to store Lua script's inner state?

Bounty: 50

Situation:

  • I am working on an Entity-Component system, and I am using LuaBridge as a Lua binder.

  • There is only one Lua State.

  • Currently when I update the game objects, I just check whether it has a script defined or not. If there is, I call luaL_dostring() on it, and I call its update() function.

  • I have a script, where I declare a global variable in its start() (it is called when the script runs for the first time), and increment it at every update() then print it out

Question:

  • I would like to achieve separated inner state saving for my scripts.
    • For example If I add the same script to two different game objects, currently the printed out numbers will be 1,2,3,4,5,6 instead of 1,1,2,2,3,3, etc.
    • This is because they use the same Lua State (correct me if I am wrong)

    • But as I heard it’s not a good practice to have a lua state for every script because If I just have 5 scripts, and I add these to 3 different game objects, there would be already 15 lua states.

How should I achieve my goal?


Get this bounty!!!

#StackBounty: #c++ #lua #entity-component How to store Lua script's inner state?

Bounty: 50

Situation:

  • I am working on an Entity-Component system, and I am using LuaBridge as a Lua binder.

  • There is only one Lua State.

  • Currently when I update the game objects, I just check whether it has a script defined or not. If there is, I call luaL_dostring() on it, and I call its update() function.

  • I have a script, where I declare a global variable in its start() (it is called when the script runs for the first time), and increment it at every update() then print it out

Question:

  • I would like to achieve separated inner state saving for my scripts.
    • For example If I add the same script to two different game objects, currently the printed out numbers will be 1,2,3,4,5,6 instead of 1,1,2,2,3,3, etc.
    • This is because they use the same Lua State (correct me if I am wrong)

    • But as I heard it’s not a good practice to have a lua state for every script because If I just have 5 scripts, and I add these to 3 different game objects, there would be already 15 lua states.

How should I achieve my goal?


Get this bounty!!!

#StackBounty: #c++ #lua #entity-component How to store Lua script's inner state?

Bounty: 50

Situation:

  • I am working on an Entity-Component system, and I am using LuaBridge as a Lua binder.

  • There is only one Lua State.

  • Currently when I update the game objects, I just check whether it has a script defined or not. If there is, I call luaL_dostring() on it, and I call its update() function.

  • I have a script, where I declare a global variable in its start() (it is called when the script runs for the first time), and increment it at every update() then print it out

Question:

  • I would like to achieve separated inner state saving for my scripts.
    • For example If I add the same script to two different game objects, currently the printed out numbers will be 1,2,3,4,5,6 instead of 1,1,2,2,3,3, etc.
    • This is because they use the same Lua State (correct me if I am wrong)

    • But as I heard it’s not a good practice to have a lua state for every script because If I just have 5 scripts, and I add these to 3 different game objects, there would be already 15 lua states.

How should I achieve my goal?


Get this bounty!!!

#StackBounty: #c++ #lua #entity-component How to store Lua script's inner state?

Bounty: 50

Situation:

  • I am working on an Entity-Component system, and I am using LuaBridge as a Lua binder.

  • There is only one Lua State.

  • Currently when I update the game objects, I just check whether it has a script defined or not. If there is, I call luaL_dostring() on it, and I call its update() function.

  • I have a script, where I declare a global variable in its start() (it is called when the script runs for the first time), and increment it at every update() then print it out

Question:

  • I would like to achieve separated inner state saving for my scripts.
    • For example If I add the same script to two different game objects, currently the printed out numbers will be 1,2,3,4,5,6 instead of 1,1,2,2,3,3, etc.
    • This is because they use the same Lua State (correct me if I am wrong)

    • But as I heard it’s not a good practice to have a lua state for every script because If I just have 5 scripts, and I add these to 3 different game objects, there would be already 15 lua states.

How should I achieve my goal?


Get this bounty!!!