-
Posts
7,936 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Downloads
Posts posted by Rick
-
-
Just a small little demo of the early works of my lua scripting scene library. Basically it allows you to make complex "scenes" in your game through scripting and a few map elements.
Here is the code to the scene. The scene library functions have the Do in front of them and the GetEntityByName() and RunScript(). In the beginning you can the pivots setup and in the code you can see I assign those to variables for easier access.
The library currently has:
DoWait() -- waits x ms before continuing on with the script. Note I said just the script because the entire game continues to play. Only the function you defined waits. This is the best part of this. Your function isn't blocking to the game.
DoSound() -- waits to continue with your script until the sound is finished. All the sound you hear are wav files that I created
DoMoveTo() -- waits to continue until one entity reaches a destination entity
function MyScript(cr) local pivot1 = GetEntityByName("pivot1") local pivot2 = GetEntityByName("pivot2") local pivot3 = GetEntityByName("pivot3") local pivot4 = GetEntityByName("pivot4") local general = GetEntityByName("pivot_7") local generalModel = GetEntityByName("1_4") local soldier = GetEntityByName("pivot_5") local miscSoldier = GetEntityByName("1_42") local miscSoldierModel = GetEntityByName("1_6") local camera = fw.main.camera PositionEntity(camera, EntityPosition(pivot1)) PointEntity(camera, miscSoldier, 3, 1, 0) DoWait(cr, 2000) DoSound(cr, "abstract::hello1.wav") PositionEntity(camera, EntityPosition(pivot2)) PointEntity(camera, soldier, 3, 1, 0) DoSound(cr, "abstract::ripoff.wav") DoWait(cr, 500) PositionEntity(camera, EntityPosition(pivot3)) PointEntity(camera, general, 3, 1, 0) DoSound(cr, "abstract::whosaidthat.wav") DoWait(cr, 500) PositionEntity(camera, EntityPosition(pivot2)) PointEntity(camera, soldier, 3, 1, 0) DoSound(cr, "abstract::idid.wav") DoWait(cr, 1000) PositionEntity(camera, EntityPosition(pivot1)) PointEntity(camera, miscSoldier, 3, 1, 0) DoMoveTo(cr, generalModel, pivot4, .005, .5, miscSoldierModel) DoSound(cr, "abstract::private_joker.wav") DoWait(cr, 250) PositionEntity(camera, EntityPosition(pivot2)) PointEntity(camera, soldier, 3, 1, 0) DoSound(cr, "abstract::from.wav") DoWait(cr, 500) -- debugging, makese it easier to go back to starting point PositionEntity(camera, EntityPosition(pivot1)) PointEntity(camera, miscSoldier, 3, 1, 0) SetGlobalNumber("runGame", 2) end -- this kicks the script off RunScript(MyScript)
There is a bug in the DoMoveTo() which you can see at the end. The "general" guy seems to be slowly moving upward as he moves.
This scene took me about 20 mins to setup. This is pretty powerful because you can create very complex "scenes"/interactions in your game with very little effort and logical flow. I will release the lua code when I'm complete but if you are interested in how I did this you can look into lua's coroutines.
- 1
-
cast it to BP
-
I'll try that. Thanks!
-
I have all those. The 2 I meant was when I select mpg, then I have 2 more options under that. Do you know what other formats youtube supports? I thought it was just mpeg-2, mpeg-4.
-
Yeah but the 2 formats that are in there are just MPEG2. This is what I used and youtube didn't seem to like it. The other one is MPEG1. Youtube says
H.264 or MPEG-2 preferred. I'm guessing MPEG2 and MPEG-2 are different because the MPEG2 didn't work.
-
http://www.leadwerks.com/wiki/index.php?title=Entities#Animate
Probably the same way you animated models using C++/BMax. I think your Animate() function would need to be in the entities Update() method since some values passed to Animate() will need to change each cycle.
-
You don't access the menu value directly. What you do is in the SetKey() function (you can look at other entities to see how the SetKey() works) for the model you added this property to, you would use http://www.leadwerks.com/wiki/index.php?title=Entities#SetEntityKey to assign this model instance a key/value. In your case you would do something like:
model:SetKey("hand_icon", "true")
Then in your fps lua file where you pick, you are picking the model and when you get the model you can do:
if(model:GetKey("hand_icon")) then
-- change icon to the hand icon
end
So the ideas is you create menu options. When the menu options are set the SetKey() function is called which allows you to assign the value to your entities OR models that you can later get at other places.
-
I can't get the Debut Video Capture Software video I do uploaded correctly to youtube. The format must be different but I can't find where to change the video format to something youtube likes.
-
-
That didn't work out well. It killed the fps to about 9. Plus I only get 30 seconds.
-
I want to make a video showing what I'm doing. It also would need sound. Is there any free software that could capture a window like the Leadwerks Editor?
-
Are we able to set a lua table to a models user data? I'm not sure if someone mentioned this before but that would also solve the multi lua state issue. Since we are able to cycle through all world entities, we could get the entity lua table that is assigned to the model, that would make things global.
-
I can scale models in the editor. So that part is working.
-
I actually like the airplane one. I'll spin off that.
First person camera view
You are in your seat next to some big fat guy who won't shut up.
You can move your camera around but can't move yet.
Things are happening around you like people talking, people getting drinks, etc.
The ride starts getting rough
Captain comes on and says things are ok and there is nothing to be worried about
You notice people saying something about their window is making a strange noise.
You lose control of your camera and it slowly turns to the seats on the other side of
the plane.
Then a hole blows open and all hell breaks out. Those people fly out of the plane in their seats.
You have control of our camera in terms of looking around.
The plane pitches forward to indicate it's spinning out of control.
Crazy wind sound and people screaming.
You hear a noise getting closer and closer (hint: it's the ground)
Big crash noise and screen goes black.
Load Scene. Camera is laying on the ground. It does some blinking (black over screen kind) and things are blurry.
The camera slowly rotates upright (you are standing up) and things get focused.
You now have full control and the game starts.
All of this is fully possible with the scripting system I have. The only issue I'd have is the assets. So for now it'll be crappy programmer art.
This will be my goal.
-
From what I remember it wouldn't work because your models needs a .phy file to handle collisions. I'm guessing the .phy file isn't getting scaled the same as your model.
I don't see why it couldn't though. LE would need to look at the model scale and adjust the .phy file accordingly.
-
I'm not 100% sure how to use the SetKey and GetKey functions. I have the following in the switch.lua:
--hand icon menu group=grid:AddGroup( "Hand icon" ) group:AddProperty( 'Show hand icon', PROPERTY_BOOL,'showicon')
function SetKey(model,key,value) if key=="showicon" then entity.pickable=tonumber(value) end return 1 end
Is 'showicon' in AddProperty the Key here?
In the FPScontroller I use a raytrace:
pick=CameraPick(camera,Vec3(GraphicsWidth()/2,GraphicsHeight()/2,2.0),0,0) if pick~=nil then repeat if pick.entity:GetClass()==ENTITY_MODEL then break end pick.entity=pick.entity.parent until pick.entity==nil -- show hand true or false if pick.entity~=nil then ????GetKey("showicon","true") handIcon = true end else handIcon = false end
At the question marks I need to retrieve if the value is true or false from 'showicon' in the switch.lua. As I understand this is done by the GetKey.
In your set key I think you need to get the entity from the model passed into the function. I think there is some base_Entity() or whatever where you can pass in a model and get the entity (which would really be a lua table object and not an LE TEntity).
You would probably need to do the same thing in your picking code as well because I think pick.entity is TEntity and not the lua table object, but I could be wrong there.
-
sounds like left4dead's opening scene... if you can create that scene, I'd be duly impressed.
But what would be impressive about it? The functionality or the graphics? I'm more looking for the functionality side since I suck at graphics, but maybe if I can get the functionality someone will make the graphics.
-
Josk, where is this in the wiki for the lua form?
***edit- Ah found it-PointEntity
There are so many different pages for a single command in the wiki, you just never know what you are looking at it is correct...
Ah perfect, thanks guys. I keep forgetting that's how he set it up.
-
Use the Kill function. Example:
function Kill(model) local entity entity=entitytable[model] if entity~=nil then if entity.tire[0]~=nil then entity.tire[0]:Free() end if entity.tire[1]~=nil then entity.tire[1]:Free() end if entity.tire[2]~=nil then entity.tire[2]:Free() end if entity.tire[3]~=nil then entity.tire[3]:Free() end end end
- 1
-
I must be missing something. I can't seem to get my camera to point at another entity using PointEntity(). I know I have the camera object and the other object because I can set the position of my camera to the position of the object, but when I try pointing my camera to this object it doesn't seem to work.
What am I missing? I'm using the fpscontroller.lua but I commented out any camera movement/rotation code in there.
m = GetEntityByName("pivot01") PointEntity(fw.main.camera, m, 3, 1.0, 0.0)
-
Anything you want. Just think of a cool intro to a game that is in-game (not a video cut scene). Any genre you want.
-
I need some ideas for a cool opening scene that is played out in the engine as a script. Just say anything that you would like to see and you think would be cool. Any perspective or anything. I just need ideas.
Thanks
-
From my understanding the entity is a lua table where the model is an LE TModel. You can create/load any number of models and add a variable to the entity assigning your loaded model.
entity = base_Entity(model)
entity.mycrazyvariablename = LoadModel("abstract::mymodel.gmf")
entity.anothercrazyvariablename = 5
And now these variables added to the entity table can be used anytime in your entities script
I think Josh mentioned he might change the naming from entity to object since LE has a TEntity and it can be confusing when we see the word entity because does it mean a TEntity or just a lua variable? It's a lua variable but it can be confusing.
-
You could give a setting for models that you want to be picked. pickable = true for example. Then check this setting.
send message
in Programming
Posted
Do I send messages via the lua entity table or can I send messages directly to the LE model? When I loop through the main world entities I want to send a message to one and then receive it, but from what I see it looks like those messages are via the lua entity. Does the ReceiveMessage() function get fired if I send a message through the LE model?