• 11
• 9
• 11
• 9
• 11
• ### Similar Content

• I'm a formally trained composer (doctorate from Michigan State) who writes what most people would call avant-garde concert music. I love weird abstract projects, and I would like to work with somebody making a weird, abstract, artsy game.
You can find more about me and my music on my site. I have worked with acoustic and electronic sounds, including some algorithmic and interactive computer music.
In particular, I would like to work on a project that lets me use Fmod to prepare an adaptive score for a game built on Unity or Unreal. I've been a music professor and would like to get experience working in this medium so that I can be a better mentor for my students. Send me a DM or email <davidjohnmacdonald@gmail.com> if you would like to discuss working on a project together.
• By Tuner_z

Name: One Level: Stickman Jailbreak
Price: Free
Developer: RTU Studio
Platform: Android
Language: C# (Unity3D)

Hello!
I want to show you my game! "One level: Stickman Jailbreak" is a puzzle game with unusual gameplay where you must help the character to escape from prison. You just need to take the key and get out alive. The game has only one level, and there are many ways to complete it. Not everything is as simple as it might seem at first glance, so there are clues in the game.

Short description:
Nobody escapes from here!

Description:
Tommy got into trouble again! Our hero is behind bars. But he's not going to stay in jail for a long time and he decides to escape. Tommy steals a key and gets out of the jail cell. But our friend doesn't go free: Tommy suddenly finds himself in the same room from which he just escaped! The conditions for escaping change every time. In order to go free Tommy will have to solve logical puzzles and you can help him in this!
At first it will be easy, but the tension will increase, and the tasks will become more complicated with each level. You should use your brain for all 100%, but if your skill is not enough, you can use a hint or ask for help from friends!
You can solve the puzzles alone or with your friends and spend time well!

Features:
Features:
- 48 unique levels;
- the game is translated into 10 languages: English, French, German, Spanish, Italian, Portuguese, Russian, Japanese, Chinese, Korean;
- the function of "help from friend";
- hints;
- instructions.

Trailer:

Screenshots:

• Hello forum,
I have some decent amount of experience in Unity making games for Software Engineering projects in college, these were very specific projects however and I still am fairly new to building games. I wanted to make a game that uses the shadows of objects for collision detecting (i.e. shooting a gun at a characters shadow causes that character damage. What is the best engine to do this in (game will be 3D), and does anyone have any advice on how to approach this concept? I consider myself fairly experienced in programming, but game dev is just an entirely different beast.
• By juicyz
Hey all,
I've been slowly working on my game called AotW for a while now.  I have come to the conclusions that it would be nice to cooperate with 1 or 2 others to help finish it.  Ive been trying to keep my GDD up to date with my ideas and development so that would give a better overview of the game when the time comes.  Currently I have a basic skeleton of the RPG elements needed but everything can still be discussed and talked about and we can transform my idea to something the group likes.
The premise of the game is a Diablo-like procedurally generated map with RPG elements that include sockets, inventory, classes, abilities, crafting, loot, items, sockets, and enchanting.  This will be done in a 2D iso view as I can't do 3D art and I enjoy 2D games a lot.

I don't plan on releasing this as this is more of a hobby project for me and I have a full-time job.  Though I'd like to start putting more hours into development and having others definitely will be motivation.  I also want to be able to say I have finally "finished" a game idea to some degree.  If the time comes and we want to release it, then we can go ahead and do so but that's not my purpose or plan.

Discord:
Juicyz#3683

Thanks,
Juicyz

• Hi, I've been working on this issue for a while and haven't yet found an answer.
Does anyone know the best way to convert unity's LAT & LONG into a vector 3 position that I could use in a virtual world (if it's even possible).

# Unity Changing a C++ vector list via Lua

This topic is 974 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello gamedev-community

I am currently working with Lua 5.1 and C++ and want my Lua-script cause C++ to add a new entry to my vector list.

My whole game consists of multiple states - for this case the playstate will be active.
Furthermore this state contains a playstate-class whose update()-function runs the Lua-script at some point.
This Lua-script contains multiple instructions for the game - including the instruction to create/remove a pointer to the vector list.

The pointer points at objects of the NPC-class.

--here are the predefinitions

function dialogue_text()
while true
do

blendin ("angry", "y")         --This function shall cause C++ to save a new pointer to a new object in the vector list.
y "Hi! How are you?"           --Predefined function, changes the text.
m "I am fine - how about you?" --Same as the last line.

end
end


blending("angry", "y") contains all important attributes of the new object for now. For example y is just a shortcut for the real name of the character and angry describes a certain state. Nonetheless I am not really happy with the syntax of this function but that is not the main focus here.

Secondly there is the C++ header of the class, holding the vector list:

class Npc; //Mentioning that the class Npc exists, this is the object to which a pointer will point.

class Playstate : public Gamestate
{

public:
Playstate();
virtual ~Playstate();
void HandleEvents(Game& game);
void Update(Game& game);
void Draw(Game& game);

std::vector<std::shared_ptr<Npc>>::iterator it; //The vector list which shall hold shared pointers to the objects.

typedef std::vector<std::shared_ptr<Npc>> container;
container c;

private:

//All kind of variables would be defined here.

};

#endif


So if the state manager calls for the playstate-state it's update-function will be called. Now the Lua-script runs and this is where I stuck.

As you can see within the Lua-script there are commands like y "Hi! How are you?" which changes a file with a Lua table in it. This table file is being accessed and extracted by my C++-playstate.

However I feel like saving the characters in a Lua table and adding/removing these entries is a bit weird.

Specially because there would be two "tables/lists" containing nearly the same information. The Lua table and the vector list (which points to the real object).

Additionally being forced to open the Lua-table within the C++-Update() and check if there is something new compared to the vector list is a weird way. I would rather directly manipulate the vector list with a new command/instruction in the Lua-script.

On the other hand calling a static int() from the Lua script is not working out because the vector list is inside the playstate-class (or the current running object of this class at execution time). Though this might be a mistake I have done on my end.

To summarise my post in questions:

How could I access this vector list via Lua? Should I go with my idea of using a Lua-table which will be accessed by C++ when it is needed?

Can I use a struct int() for this instead? If yes, how can I make it possible to access the vector list?

Additionally, is there a way to change my syntax 'blendin("angry", "y")' to 'blendin angry y'?

Thanks for taking your time to read my post. I am looking forward for your ideas and suggestions! If there is any question about my questions/case, then feel free to tell me of course.

Edited by Angelic Ice

##### Share on other sites

Assuming there will be multiple Playstate's, blendin() must know exact instance to call.

It might be some global field (either side, lua or c++), or it might be in environment or lexical closure of blendin(), which should be created/initialized per Playstate now.

If you go with static global field on c++ side, your syntax for blendin() won't change. In "static int()" function you read that global field and pass arguments to exact instance of Playstate.

If you go with dynamic per-Playstate initialization, then blendin() itself, or its environment should be initialized with exact Playstate. Then blendin() might be a wrapper to other function that will pass Playstate pointer/reference as first argument, so "static int()" will know where to take Playstate pointer.

Additionally, is there a way to change my syntax 'blendin("angry", "y")' to 'blendin angry y'?

No. Lua allows calling functions when its only argument is either string or table.

So blendin "angry" "y" is possible, and with some setup blendin { angry, y} also possible (angry and y is some unique values, available from current environment).

But you can't make blending angry y, that's not a valid syntax.

##### Share on other sites

However I have a question: What do you mean by "global field"? Like some static global pointer in which I pass the object of the state when I create it?

No. Lua allows calling functions when its only argument is either string or table.

So blendin "angry" "y" is possible, and with some setup blendin { angry, y} also possible (angry and y is some unique values, available from current environment).

But you can't make blending angry y, that's not a valid syntax.

Oh, not even like predefining keywords similar to local y = function(string)? I once heard about Internal DSL but after a long research I came to no real solution nor an idea how it would work.

Edited by Angelic Ice

##### Share on other sites

What do you mean by "global field"? Like some static global pointer in which I pass the object of the state when I create it?

Yes, sort of that. It should store currently active Playstate, updated every time you switch states.

Oh, not even like predefining keywords similar to local y = function(string)?

What do you mean? You can't define new keywords in Lua, and there's no macros in language.

I once heard about Internal DSL but after a long research I came to no real solution nor an idea how it would work.

By "internal dsl" keywords I found this: http://www.lua.org/wshop11/luaws11_ag.pdf

Do you mean the same by "internal"?

All examples there built using Lua's syntactic sugar - parentheses around function's arguments can be omitted when there's just one argument, and it's either table constructor or string literal.

That's how you can implement blendin "angry" "y" - blendin() takes first string literal "angry", and returns another function. That second function will take second literal "y", and might finally do something. E.g:

local function blendin(key)
return function(value)
print('Want make assignment "'..key..'"="'..value..'"')
-- do some actual work to create new entry in c++ list
end
end

blendin "angry" "y"


Note that in case of 'blendin angry y' row - angry and y is not a string literal, those are variables, local or global.

So it's not the case of calling function with string literal or table constructor, and will be treated as syntax error.

Edited by vstrakh

##### Share on other sites

If you really wanted to you could add #define capabilities to Lua by simply running the C preprocessor on your scripts before executing them (it's not hard) but I think it would be a questionable approach for what you're trying to do.

My suggestion: stop trying to come up with a DSL and just use normal Lua constructs. There's quite a bit of syntactic sugar available so you can be creative and still manage to write something nice without resorting to horrible hacks just to e.g. remove parentheses.

##### Share on other sites

Yes, sort of that. It should store currently active Playstate, updated every time you switch states.

I managed to make it work! Thanks a lot

For the ones who might have the same problem, here is my solution to it:

- I created an extra pointer outside of the Playstate-class.

- Before the Playstate-class is going to call the Lua-script, I pointer = this; the object to the pointer.

- Lua runs the blendin()-function and ends up calling the static int() within my C++ code.

- The static int() accesses the pointer and does: pointer->container.push_back(const char* var);

By "internal dsl" keywords I found this: http://www.lua.org/wshop11/luaws11_ag.pdf

Do you mean the same by "internal"?

All examples there built using Lua's syntactic sugar - parentheses around function's arguments can be omitted when there's just one argument, and it's either table constructor or string literal.

That's how you can implement blendin "angry" "y" - blendin() takes first string literal "angry", and returns another function. That second function will take second literal "y", and might finally do something.

That looks interesting. Well, the reason why I came up to this is was inspired by this under the point Simple Scripting Language

label family:
scene bg beach2
with dissolve

"It wasn't long before Mary broke the silence, by asking me a question."

show mary dark smiling
with dissolve

p "When I'm on the island here, I live with my aunt and uncle, but back home, I live with my mother, father, and sister."

m "A sister? Is she older or younger?"


It is using Phyton, though I have no experience with it. So I tried to figure out if there is any similar approach to this syntax with Lua. However thanks for informing me that this is not the case.

If you really wanted to you could add #define capabilities to Lua by simply running the C preprocessor on your scripts before executing them (it's not hard) but I think it would be a questionable approach for what you're trying to do.

My suggestion: stop trying to come up with a DSL and just use normal Lua constructs. There's quite a bit of syntactic sugar available so you can be creative and still manage to write something nice without resorting to horrible hacks just to e.g. remove parentheses.

Oh, but why do you call these "horrible hacks"? What makes them horrible?

Edited by Angelic Ice

##### Share on other sites

Oh, but why do you call these "horrible hacks"? What makes them horrible?

They are horrible because they invariably break down at some point in the future when you need to add some more functionality and suddenly realize it's impossible, and start coming up with alternatives and end up with something really nasty compared with just using the language as it's meant to be used.

##### Share on other sites

Oh, but why do you call these "horrible hacks"? What makes them horrible?

They are horrible because they invariably break down at some point in the future when you need to add some more functionality and suddenly realize it's impossible, and start coming up with alternatives and end up with something really nasty compared with just using the language as it's meant to be used.

Thanks for explaining! It makes totally sense to me thus I will avoid this.