Data Realms Fan Forums http://45.55.195.193/ |
|
Tagging/Naming http://45.55.195.193/viewtopic.php?f=73&t=24176 |
Page 1 of 1 |
Author: | Dylanhutch [ Thu Jun 09, 2011 1:30 pm ] |
Post subject: | Tagging/Naming |
Is it possible to add a actor based tagging system, that is also global? As in, not to one specific actor but to all actors once one of something - such as a brain case - is placed. For example: local name = Actor1 --(Entered in console)(Not sure if the 'local' part would be accurate to this use) --Then: Actor1: Gibthis; --(Also entered in console) --Or something like that. This would make it possible to tag enemies from your perspective, with advanced Lua, like a curser based tagging system. Make sense? |
Author: | Geti [ Thu Jun 09, 2011 2:11 pm ] |
Post subject: | Re: Tagging/Naming |
Make a global table and dump all the actors into there using their presetname and a random number (or a non-random number if you like). You'll need an "organisation" actor on the map (probably at 0,0 for simplicity, or your brain case if you so wish) that would keep a track of anything dying or coming into play. You could build a GUI with MOSPs, or just use the CLI by making a bunch of functions members of that fancy global table you just made (oh look its a namespace). Then you can do something like Code: world_CLI:getFirst("Dimitri"):GibThis(1000); |
Author: | Dylanhutch [ Thu Jun 09, 2011 3:20 pm ] |
Post subject: | Re: Tagging/Naming |
I was sort of hoping for something a little more simple than that. I mean to say, naming is the main thing, the stuff about a curser based tagging system was - to me - probably not going to happen. And just so you know: I know hardly anything about Lua. Only the logic, and some commands to do with CC. Thanks. |
Author: | Geti [ Fri Jun 10, 2011 2:41 am ] |
Post subject: | Re: Tagging/Naming |
Making a global table is as simple as Code: if (CC_CLI == nil) then CC_CLI = {}; end You could also define functions inside and outside of that block like Code: --expects a table function populateWithActors(a,c) c = c or 0; for actor in MovableMan.Actors do --iterate all the actors c = c + 1; --increment "count" table.insert(a,actor,actor.PresetName .. count); end end --pads a string to a set length with spaces function padStringToLength(s,l) local length = s:len() if length > l then s = s:sub(1,l); elseif length < l then s = s .. " ":rep(l-length); end return s end --initialising CC_CLI if needed if (CC_CLI == nil) then CC_CLI = {}; --set up a global table to hold everything CC_CLI.count = 0; --start a count CC_CLI.Actors = {}; --create a table for the actors --populate the CLI's actor table with actors NOTE THIS IS ONLY VALID FOR THIS FRAME THINGS MIGHT DIE OR COME INTO EXISTANCE! populateWithActors(CC_CLI.Actors, CC_CLI.count); --this returns the first found actor with a string in its tag or nil if none is found function CC_CLI.firstWithTag(a) for k,v in pairs(CC_CLI.Actors) do if type(k) ~= "string" then continue; elseif k:find(a) ~= nil then return v; end end return nil; end --dumps tags, names, and positions in a visual table. function CC_CLI.dumpAll() print(padStringToLength("TAG",30) .. "|" .. padStringToLength("PRESETNAME",30) .. "|" .. padStringToLength("POS",15)); for k,v in pairs(CC_CLI.Actors) do print(padStringToLength(k,30) .. "|" .. padStringToLength(v.PresetName,30) .. "|" .. padStringToLength(v.Pos:toString(),15)); end end end |
Author: | Dylanhutch [ Fri Jun 10, 2011 3:20 am ] |
Post subject: | Re: Tagging/Naming |
... Well, I was hoping not to make a releasable mod, but just make it as a proof of concept sort of thing. I wasn't going to release it or anything. I think this is best left to you Lua pros. :] I'll just wait until someone gets so bored that they make this into an actual mod. |
Author: | Geti [ Sat Jun 11, 2011 3:55 am ] |
Post subject: | Re: Tagging/Naming |
... It would've been nice to know you didn't have any drive whatsoever to learn before I bothered typing educational code. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |