MilitaryG
-
Posts
116 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Posts posted by MilitaryG
-
-
So there is no "official" way to do this but here is a method.
1) Create an "interface" class that has a virtual function for each entity script
2) Create classes that represent Lua scripts and derive them from the script interface
3) Load your map and then loop over all the entities and you'll need a way to identify at run-time which entity should get what script class. In my example I just look for a key value to see if it's equal to a value of the same name as the script class. This still means you have to attach a script in Lua to set this value. These are reasons why I ask for an editor way to add key values to avoid setting lua scripts if not needed but if we still want to set key values for an entity.
4) Create an instance of that script, set the entities user data to this script class instance (we use this later in the global hooks), add all the hooks, add to a list so we can store each instance.
5) Create global hooks and inside cast the user data to our script interface so we can call the class virtual functions to get the code to enter our class instances so we aren't working in a global space because that's bad.
Here is some code that does what the description above says.
// derive your "script" classes from this interface to make it an "entity script" class IScript { protected: Entity* entity; public: IScript(Entity* e) { entity = e; } virtual void Collision(Entity* entity, float* position, float* normal, float speed); virtual void Draw(); virtual void DrawEach(Camera* camera); virtual void PostRender(Camera* camera); virtual void UpdateMatrix(); virtual void UpdatePhysics(); virtual void UpdateWorld(); }; // example "script" that you would have to make class DoorScript : public IScript { public: virtual void Collision(Entity* entity, float* position, float* normal, float speed) { } virtual void Update() { } }; // define each global hook function here and the same idea applies to all. cast the user data on the entity // to IScript and if it's not NULL call that instance method void CollisionHook(Entity* entity0, Entity* entity1, float* position, float* normal, float speed) { IScript* script = (IScript*)entity0->GetUserData(); if(script != NULL) { script->Collision(entity1, position, normal, speed); } } void UpdateWorldHook(Entity* entity) { IScript* script = (IScript*)entity->GetUserData(); if(script != NULL) { script->UpdateWorld(); } } // keep a list somewhere in App.h/cpp list<Script*> entities; // called in App.cpp Start() Map::Load("maps\start.map"); // after map is loaded list<Entity*>::iterator iter; for(iter = world->entities.begin(); iter != world->entities.end(); ++iter) { Entity* e = (*iter); if(e->GetKeyValue("script") == "DoorScript") { IScript* script = new DoorScript(); e->SetUserData((void*)script); e->AddHook(Entity::Collision, (void*)CollisionHook); // add all hooks here entities.push_back(e); } }
ok is there anything I should include?
and can we get a little bit slower I don't really care if it global and very little as I'm just starting.
and something little and simple would do.
ok let me show the errors only of the 1. class:
4. ‘Entity’ does not name a type 6. expected ‘)’ before ‘*’ token 7. ‘Entity’ has not been declared 9. ‘Camera’ has not been declared 10. ‘Camera’ has not been declared
or am I doing something wrong?
-
You can't attach C++ code as script since C++ code needs to be compiled. You could make a system that mimics C++ in to scripts, but in the end you will need to compile C++ code.
yes I do understand c++ needs to be compiled and all, but still how would I do that?
a simple functional code
function Script:Start() self.entity:SetPosition (10,10,10) end
would do to get me started.
truthfully the more I learn lua the less I like it.
-
You probably want to look at this: http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/entity/entitygetkeyvalue-r773
and how do I help my self with that?
attaching lua script to object is like this:
and how would that page help me do that for c++?
-
I've learned how to add / create lua scripts to object what about c++?
how should I procide for c++ scripts to be run on objects?
-
he he yea it seems it is copy of your answer
was googling for it but couldn't find.
-
I really had to move away from other distros and went to fork, still had problems BUT at least it's solved now
http://forums.linuxmint.com/viewtopic.php?f=90&t=175607&p=909364#p909364
-
I'm wandering if there's a possibility to make white on black scripting?
if not can it be implemented please.
-
ok I installed leadwerks and
in top view or any other if I right click it throws me out
Segmentation fault
if I make cube and right click it it throws me out:
--: command not found
it's little annoying trying to learn if everithing that is not how I should do with engine it just crashes.
also using Linux mint 17 - xfce witch is fork of Ubuntu.
ugh IF I press file it crashes
*** Error in `./Leadwerks': free(): invalid pointer: 0x0bf701c8 *** Aborted
I think there's some dependency I'm missing, ...
witch was not included in the install.sh
-
Here is the list of packages the installer pulls down in Ubuntu.
libc6:i386 libgcc1:i386 libgl1-mesa-glx:i386 libglib2.0-0:i386
libopenal1:i386 libopenal1 libstdc++6:i386 libx11-6:i386 libxxf86vm1:i386
gtk2-engines:i386 gtk2-engines-murrine:i386 unity-gtk2-module:i386 libdbusmenu-glib4:i386
Figure what these are in your repos and you ought to be good to go.
You can do without the Unity specific dependencies but remember that you will need to have multiarch support for 32 bit enabled.
The editor is 32 bit and the engine is 64 bit.
Yes I did find this packages in the .sh file but biggest problem is:
Pacman does not have those kind of packages.
-
Hi I know it's only ubuntu supported and I did read that installing gimp would install most packages for me on other distros.
I've been trying and learning stuff about linux I've never set foot on and I didn't manage to work it on 64bit manjaro.
Did anyone else managed making it work under any other distro and is willing to help me?
Thanks in advance.
-
I do love open world, but I don't like too much following the arrow thingy, ...
Skyrim is not an RPG but looks like 1.
Fallout 3 is kinda same as Skyrim but is RPG iirc.
Also this 2 don't have hidden weapons/armor.
You get them by lvling, ... not by searching and it's a BIG difference.
in morrowind you have to search to find stuff you want or need.
you have to read and world around you changes upon your actions, and there are multiple actions available not just 2 like in skyrim or 1 in oblivion.
you can kill friendly gods if you desire so.
you can kill your own guild master if you desire so.
but this actions do affect you.
skyrim your actions doesn't affect anything. it's linear story nothing more nothing less and side quests aren't any better.
Only need for speed road challenge is ok others are ****.
assasins cread is ****.
if you like open world and so on and if you are still on windows I strongly suggest you to play morrowind.
You'll see how does the real RPG masterpice look like.
Also there are many shooting games that are "closed rooms" but just look at WolF 3D, DooM1, 2 they are still in "Closed rooms" but it feels like it's in open world. Even if it's not.
There are no cinematics there are no stories about it and many people still play it, because it's fun.
Gamers don't want graphics they only think they want graphics it's more like placebo effect, except on the end of the day it doesn't work.
-
cant understand why MilitaryG have this AAA allergy. AAA dont means that the game makes no fun and gameplay is bad and watchdogs makes fun for sure just take a look into the metal gear series they have AAA+++ and the gameplay is awesome. or take a look into the game "the last of us" one of my favorites. when you have this opinion because of games like the latest call of duty or counderstrike GO well sure its always the same and nothing new because changes in gameplay are not good for classic games.
I kinda agree with you I do have an allergy on AAA
Wellll
actually DooM 1, 2 is just a shooter but much more game play than in any CoD much more fun to play too.
good games:
doom, 1, 2, 3
System shock 2
lemings
Unreal Tournament (99)
Duke Nukem 3D
wolfenstein 3D
return to castle wolfenstein
disciples 1, 2
heroes of might and magic 3, 4
quake 1, 2
blood 1
bad quality games ugh this is allot:
fallout 3
oblivion
skyrim
Heroes of might and magic 5
disciples 3
CoD 1, 2, 3, don't know for later ones, ...
Dungeon keeper 1, 2
Unreal tournament (3,4)
Quake arena and later multilayer quakes
blood 2
bioshock 1, 2
This list goes on and on
Actually it used to be that I was like OMG this has better graphics let me try it out, ... and it used to be that game was really worth wile.
today if I see game with good graphics I just don't try it any more I just turn my back and say bye bye, ... I was trying them too often and it all went to the trash in couple of hours.
this might give you some idea, ... and actually I completely agree with him.
Also I have "developed" a certain understanding why is it like this in modern graphics, ...
it used to be you just throw a lightning or 2 and it was already too much for hardware so spending much more on graphics would make game unplayable, and so if they spend 1M$ on a game not more than 5% were on graphics but everything else.
Today if they spend 1M$ on game 99.99% of it goes to graphics, ...
and usually if they do spend 5M$ on a game it goes 95% to graphics.
So what do we have?
complex graphics == no game play.
for complex graphics you really need to spend allot of time.
for only 1 it would take years.
not to mention that for AAA garbage team it takes a year or more for complex graphics. - no offense to team but to what they are doing together.
As they don't develop game play.
-
hmmmm, ... I tried to reproduce the bug but seems that my 1. steps don't work any more or I might even skip few, ...
anyway my dad said he had weird issues with ATI drivers with some games after switching to Nvidia that he needed to complettely format PC.
that could also be the issue that I experienced this weird behavior, ...
-
ok this is weird, .....
My LE just crashed so I had to restart and I didn't change anything and now it works, I mean I can see the box if I run now, ...
-
WTH how can you fly around?
there's no scripts for camera or whatso ever, ...
I meant I do see box in editor but I don't see it when I run the game, ...
-
You can't. This topic will forever remain here to remind you that you were once a noob in 2 years when you are an expert at LE
ha ha ok I made duplicate because I didn't know how else to attach file - map
as you groove suggested, ...
-
uhm, ... how do you delete topic?
-
Ok I've made a simple box lightning and camera to observe this all I get is black.
I went looking at different projects how it's done, ...
But I saw no mayor difference between my camera AND camera in that working scene, ...
and I'm pretty sure it's looking at the box, ...
what am I missing?
- sorry for making duplicate didn't find how to attach a file on edit, ...
-
You did all this from code or in the editor? If code then we need to see your code.
Actually from the editor.
I'm learning to get used to engine and seems that I'm failing at basics, ...
all I did is:
add a camera
Seems there has to be more to it witch I cannot find what else.
-
Ok I've made a simple box lightning and camera to observe this all I get is black.
I went looking at different projects how it's done, ...
But I saw no mayor difference between my camera AND camera in that working scene, ...
what am I missing?
-
-
But well there is lot of hard core gamers that always want better graphics as possible, there is demand it seems.
people that want better graphics only think graphics is involved with gameplay.
in other words better == better.
So most people thing if something is very high graphics in their eyes they thing they will get more gameplay as well as there was put allot of money in there, ...
But they always get slapped in the face.
hey I'm hardcore gamer and do you know why I'm here, ...
Cuz I'm sick and tiered pleading for simple stuff to be made to improve gameplay.
When I started programming, making gameplay better it's impossible hard to write 3 more liines.
that much lazy they are.
that's why I'm here today.
and I hope game industry falls sooner so I can get my hands on some good games that needs loads of time developing - I don't mean graphics but actual RPG like morrowind but much better than that one.
-
I always say this kind of graphics is very good for making movies, not for games, ...
For games graphics good as in Duke Nukem 3D is good enough, ...
what matters most for games is only gameplay.
- 1
-
Is there ability to invert mouse in LE editor?
like if I move my thumb forward it would look down instead of up?
if you are curios this is what I'm used to from age of 3 now I'm 25, ...
C++ scripts
in Programming
Posted
I do care about it when I'm starting to build not when I start to learn the beginnings
______
I'm doing this with monodevelop
and I managed to include Leadwerks.h by copying whole include that's from Leadwerks install dir in to GAC(The Global Assembly cache)
and had to do:
BUT 1 problem it seems includes does not have all of it's own includes.
Include/OpenGL.h line 28
but GL dir does not exist and so does not glew.h now what?
I thought I managed to solve it but I guess I didn't, ...