ensiform Posted December 19, 2006 Share Posted December 19, 2006 Lua is a programming language now being widely used for many script situations for games, such as Far Cry/Crysis? HL2, etc, ETPro, etc. Currently, I'm trying to get ICARUS removed and adding in Lua to JKA. Eventually, I would like to add a regular API where people can add scripts that control other things than map scripting similar to what ETPro does but not quite advanced because I felt they went a little overkill with supporting so much stuff. As of right now, you can call the following: game.Print(string...) integer = game.Time() game.Broadcast(string...) entity = game.FindEntity(string) entity = game.FindScriptEntity(string) game.Remove(string) game.Declare(type string, string) game.Set(ent, string, string) game.SetVar(string, string) string = game.GetString(ent, string) number = game.GetFloat(ent, string) vector = game.GetVector(ent, string) string = game.GetStringVar(string) number = game.GetFloatVar(string) vector = game.GetVectorVar(string) game.UseEnt(ent, string) game.PlaySound(ent, string, string) game.Version = "base_lua" sys.Printf(string...) sys.LogPrintf(string...) integer = sys.Argc() string = sys.Argv(number) integer = sys.Time() string = sys.Cvar_Get(string) sys.Cvar_Set(string, string) sys.Cvar_Clear(string) sys_Command(integer, string) sys.Version = "base_lua" sys.EXEC_NOW = 0 sys.EXEC_INSERT = 1 sys.EXEC_APPEND = 2 number = entity.GetNumber(ent) boolean = entity.IsClient(ent) vector = entity.Spawn() entity.Print(ent, string...) entity.CenterPrint(ent, string...) string = entity.ToString(ent) number = qmath.abs(number) number = qmath.sin(number) number = qmath.cos(number) number = qmath.tan(number) number = qmath.asin(number) number = qmath.acos(number) number = qmath.atan(number) number = qmath.atan2(number, number) number = qmath.ceil(number) number = qmath.floor(number) number = qmath.fmod(number, number) number, number = qmath.modf(number) number = qmath.sqrt(number) number = qmath.pow(number, number) number = qmath.log(number) number = qmath.log10(number) number = qmath.exp(number) number = qmath.deg(number) number = qmath.rad(number) number = qmath.frexp(number) number = qmath.ldexp(number, integer) number = qmath.min(number...) number = qmath.max(number...) number = qmath.random() - random num between 0 and 1 number = qmath.random(integer) - random int between 1 and number number = qmath.random(integer, integer) - random int between num1 and num2 qmath.randomseed(integer) qmath.pi = 3.14159265358979323846f qmath.huge = not really sure on this one (suz) vector = vector.New() vector = vector.Construct(number, number, number) vector.Set(vector, number, number, number) number = vector.__index(vector, string) vector.__newindex(vector, string) string = vector.__tostring(vector) strlib also works (for string.format, string.find, etc) if you change the . between the main type and the function to a _ it becomes a global function instead of a local function. ... signifies a va type arg expected Link to comment Share on other sites More sharing options...
ensiform Posted December 19, 2006 Author Share Posted December 19, 2006 Scripts that work now with Lua: mp/wander.lua { -- Set Droid to Wander local droid = game.FindEntity("droidhead") game.Set(droid, "SET_BEHAVIOR_STATE", "BS_WANDER") return 1 } mp/siege_desert.lua { -- Spawn Swoops local ent1 = game.FindEntity("worldspawn_script") game.UseEnt(ent1, "swoop1"); game.UseEnt(ent1, "swoop2"); game.UseEnt(ent1, "swoop3"); game.UseEnt(ent1, "swoop4"); game.UseEnt(ent1, "swoop5"); game.UseEnt(ent1, "swoop6"); game.UseEnt(ent1, "swoop7"); game.UseEnt(ent1, "swoop8"); game.UseEnt(ent1, "swoop9"); game.UseEnt(ent1, "swoop10"); game.UseEnt(ent1, "swoop11"); game.UseEnt(ent1, "swoop12"); game.UseEnt(ent1, "swoop13"); game.UseEnt(ent1, "swoop14"); game.UseEnt(ent1, "swoop15"); game.UseEnt(ent1, "swoop16"); return 1 } mp/siege_hoth/atst_forward.lua { -- Change Target On ATST local atst = game.FindEntity("atst_rear") game.Set(atst, "SET_TARGET", "atst_2") return 1 } mp/siege_hoth/hangar_turrets.lua { -- Remove Hangar Turrets On Hoth game.Remove("hangar_turrets") return 1 } mp/siege_hoth/npc_spawner.lua { -- Call the AT-ST to Spawn local ent1 = game.FindEntity("worldspawn_script") game.UseEnt(ent1, "atst_1") return 1 } Unused Scripts: mp/siege_hoth/update_atst_spawnpoint mp/siege_hoth/atst_death mp/siege3_shipspawn Link to comment Share on other sites More sharing options...
Tinny Posted December 19, 2006 Share Posted December 19, 2006 Woah, i've been interested in Lua. I'm fairly new to scripting, what does Lua allow that Icarus does not? Link to comment Share on other sites More sharing options...
ensiform Posted December 19, 2006 Author Share Posted December 19, 2006 Well for starters: ICARUS scripts need to be compiled to something we cannot read and Lua is just raw script files that we can, plus with a cmd you can load on the fly. And because ICARUS code is not shared to us, we cannot change it much from what is not already in the server code, but since I have full access to Lua and am in total control of it, I can do practically anything and everything with it. Link to comment Share on other sites More sharing options...
Tinny Posted December 19, 2006 Share Posted December 19, 2006 Nice, I want to get familiar with this as it seems to be pretty widespread. Know of any good tutorials that wouldn't show up on google? Link to comment Share on other sites More sharing options...
ensiform Posted December 19, 2006 Author Share Posted December 19, 2006 Not really, I'm just learning for myself :embarrassed: You could try googling "etpro lua" and goto the LuaMod API - WolfWiki Link to comment Share on other sites More sharing options...
ensiform Posted December 20, 2006 Author Share Posted December 20, 2006 Added some file handle support to the system library: handle, len = sys.FileOpen(path, mode) sys.FileClose(handle) string = sys.FileRead(handle, len) sys.FileWrite(string, count, handle) Link to comment Share on other sites More sharing options...
ensiform Posted December 20, 2006 Author Share Posted December 20, 2006 sys.Time renamed to sys.GameTime because it is level.time integer = sys.Milliseconds() added which calls trap_Milliseconds(). sys.DropClient(integer, string) Link to comment Share on other sites More sharing options...
ensiform Posted December 20, 2006 Author Share Posted December 20, 2006 basically same as $tag("name", "ORIGIN/ANGLES") game.GetTag(ent, string, string) Link to comment Share on other sites More sharing options...
ensiform Posted December 22, 2006 Author Share Posted December 22, 2006 game.Kill(ent, string) ent is basically who is calling the func, and who to use if string says "self" or "enemy" use enemy based on ent. Link to comment Share on other sites More sharing options...
ensiform Posted December 22, 2006 Author Share Posted December 22, 2006 Working on simple task functions too but Not really sure what exactly they will do, and it would be nice to see the actual ICARUS engine code. void lua_TaskIDClear( int *taskID ) { *taskID = -1; } qboolean lua_TaskIDPending(gentity_t *ent, int taskType) { if ( ent->taskID[taskType] >= 0 ) { return qtrue; } else { return qfalse; } } void lua_TaskIDSet(gentity_t *ent, int taskType, int taskID) { int i = 0; for ( i = 0; i < 10; i++) { if (ent->taskID[i] = taskID) return; } ent->taskID[taskType] = taskID; } void lua_TaskIDComplete(gentity_t *ent, int taskType) { ent->taskID[taskType] = -1; } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.