YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Adding c++ class methods as squirrel functions
kafka
#1 Posted : Wednesday, November 16, 2016 8:42:14 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/16/2016(UTC)
Posts: 1
Location: Finland

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Hello,

I'm new to squirrel and not that experienced in c++ in general (even though i've been coding with it on and off for years).
I'm building a simple 2D game engine and for the scripting part I first used angelscript, but found it easy to embed, but a little too rigid to actually code gameplay code with.
So I found squirrel, because I have dabbled with lua before and found it to be quite similiar in the embedding apartment.

But I ran into problems early on trying to replace angelscript with squirrel.
I have an Engine -class that has all to appropriate functions for displaying graphics, using sounds etc.
But now trying to put my c++ engine methods in squirrel seems to be hard or even impossible.
This is not an issue in angelscript, in fact it's quite easy to do.

My question is this:
Have I missed something or is it impossible to bind non static class methods as squirrel functions?
absence
#2 Posted : Sunday, November 20, 2016 3:23:03 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 8/23/2014(UTC)
Posts: 109
Man
Location: Northern Germany & Lincolnshire, U.K.

Thanks: 1 times
Was thanked: 10 time(s) in 10 post(s)
Sorry, I'm short on time. But you may want to have a look at SQPlus(outdated, but still does the job when tweaked a bit or if you want to look up how things are done: https://sourceforge.net/projects/sqplus/ ) or preferrably SQRat: http://scrat.sourceforge.net/

(Generally spoken: When using a C++class, you need to create a Squirerl Class representing it, which is a bit more complex than just simple static calls - which you will still need in your C++ class. Usually you store a pointer to your c++ class in the UserPointer of the SQ instance, the static functions of your c++ class then working as a wrapper fetching the user pointer (=pointer to your c++ instance) and call a regular c++ class member function on it). However, if you need only ONE instance of a class, which might be the case here(that is you have kind of singleton requirement), simply make your c++ class fully static and things work out more easily.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.081 seconds.