Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Another Lua question
Another Lua question [message #449318] Fri, 01 July 2011 13:32 Go to next message
hego64 is currently offline  hego64
Messages: 19
Registered: April 2011
Location: Hegoville
Karma: 0
Recruit
Ok, I figured I may be able to use this for my kill hook.

function myscript:Killed(ID, obj, killer)
	print("Killed", ID, obj, killer)
end


Thing is, I don't know how to use it. Anyone have any ideas or know how to use this? I could really use the help with this please.

If not, could someone give me an alternate way like e-mail or a different site that I may be able to reach jnz? I pm'd him but he hasn't been active since April, so I'm not really expecting a response.

Thanks,
-Hego64
Re: Another Lua question [message #449319 is a reply to message #449318] Fri, 01 July 2011 13:57 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4299
Registered: April 2011
Karma: 0
General (4 Stars)
something like:

function OnObjectCreate(o) --whenever an object is created
	if Is_A_Star(o) then --check if they're a real player
		Attach_Script_Once(o, "myscript", "")
--attach myscript to them if they are

myscript = {}

function myscript:Killed(ID, obj, killer)--this function gets called whenever something this script is attached to is killed
	print("Killed", ID, obj, killer)
end

Register_Script("myscript", "", myscript)--register our script with the engine


I don't really know how LUA works and how the LUA plugin works though. I think the print() call in myscript::Killed() is incorrect (what do you want to make it do?), take a look at http://icculus.org/~theoddone33/lua/ for a tutorial on it.


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases

[Updated on: Fri, 01 July 2011 13:59]

Report message to a moderator

Re: Another Lua question [message #449324 is a reply to message #449319] Fri, 01 July 2011 14:41 Go to previous messageGo to next message
sla.ro(master) is currently offline  sla.ro(master)
Messages: 610
Registered: September 2010
Location: Romania
Karma: 0
Colonel
here is the fixed code, i saw some missing 'end'

function OnObjectCreate(o) --whenever an object is created
	if Is_A_Star(o) then --check if they're a real player
		Attach_Script_Once(o, "myscript", "")
              -- attach myscript to them if they are players
        end
end

myscript = {}

function myscript:Killed(ID, obj, killer)
   -- called if someone get killed by someone else, not called if killed by null objects, like dying from falling.
	print("Killed", ID, obj, killer)
end

Register_Script("myscript", "", myscript) --register script 


this should work




Creator of Mutant Co-Op
Developer of LuaTT
Re: Another Lua question [message #449325 is a reply to message #449318] Fri, 01 July 2011 14:48 Go to previous messageGo to next message
Dave Anderson is currently offline  Dave Anderson
Messages: 1953
Registered: December 2004
Location: United States
Karma: 0
General (1 Star)
If you want to know more about the LUA Plugin and LUA, you can view the official legacy support forum here.

Here is the getting started sticky:
http://www.dcomproductions.com/forums/viewtopic.php?f=14&t=678


David Anderson
Founder, Software Consultant
DCOM Productions
Microsoft Partner (MSP)
Re: Another Lua question [message #449326 is a reply to message #449318] Fri, 01 July 2011 14:50 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4299
Registered: April 2011
Karma: 0
General (4 Stars)
I did indeed forget to copy-paste those 'end's, use sla.ro's code. :/

Dave Anderson's suggestion is highly recommended.


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases

[Updated on: Fri, 01 July 2011 14:52]

Report message to a moderator

Re: Another Lua question [message #449336 is a reply to message #449326] Fri, 01 July 2011 19:50 Go to previous messageGo to next message
hego64 is currently offline  hego64
Messages: 19
Registered: April 2011
Location: Hegoville
Karma: 0
Recruit
Ok, I'm going to sound dumb for this, but...How can I edit this for like my previous post about the spectate stuff?

function myscript:Killed(ID, obj, killer) 
	print("Killed", ID, obj, killer)
end


I mean, I can do normal stuff in lua like weps and vehs and stuff, but I'm no hand at functions that I don't know.

Thanks for all your help y'all

-Hego64

Edit: I tried the whole thing that you guys had given me unedited in the server, and I got an error in the FDS on line 176.
(prolly a dumb idea to try it without anything added, but I had just wanted to fiddle with it for a bit)

Line 176: Register_Script("myscript", "", myscript) --register script 


The error said that it couldn't have more than one script named the same thing.

[Updated on: Fri, 01 July 2011 19:55]

Report message to a moderator

Re: Another Lua question [message #449340 is a reply to message #449318] Sat, 02 July 2011 05:30 Go to previous message
Omar007 is currently offline  Omar007
Messages: 1711
Registered: December 2007
Location: Amsterdam
Karma: 0
General (1 Star)
If it says you can't have 2 scripts named the same, it means you probably have another script named 'myscript'.
Try renaming your script. Using something that describes the scripts action in 1 (or a few Razz) word(s) would be a good idea.


http://tiberiumredux.omarpakker.nl/Old Unused Parts/Plaatjes/PromoteBanner_Hades_small.jpg

[Updated on: Sat, 02 July 2011 05:30]

Report message to a moderator

Previous Topic: Level Edit Mayhem!
Next Topic: Shaders.dll Compiling Errors
Goto Forum:
  


Current Time: Thu May 02 07:15:50 MST 2024

Total time taken to generate the page: 0.00769 seconds