LUA questions
Moderator: Moderators
-
myers73
- Lieutenant General

- Posts: 690
- Joined: Fri Apr 03, 2009 11:04 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Atlanta, GA xfire=myers73 IngameName=mYers
LUA questions
anyone know how to remove a weapon that a unit has via LUA. that is to say, like remove force from a jedi...i know how to change it to something different, not how to remove one
- Teancum
- Jedi Admin

- Posts: 11080
- Joined: Wed Sep 07, 2005 11:42 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Indiana
Re: LUA questions
Well, you could always set the values in that weapon to zero using SetProperty(). That would nullify the ability to force push/pull/choke/throw saber.
- eliminator
- Second Lance Corporal

- Posts: 118
- Joined: Wed Aug 19, 2009 3:39 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Germany
Re: LUA questions
why don't you make a force that doesn't do anything and change it then to it?
-
myers73
- Lieutenant General

- Posts: 690
- Joined: Fri Apr 03, 2009 11:04 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Atlanta, GA xfire=myers73 IngameName=mYers
Re: LUA questions
that would work, thanks. so I set it up like this?: SetProperty( "charactername", "Property", #) where # is the new value?Teancum wrote:Well, you could always set the values in that weapon to zero using SetProperty(). That would nullify the ability to force push/pull/choke/throw saber.
that would work for a mod map, but would crash what i am trying to do.eliminator wrote:why don't you make a force that doesn't do anything and change it then to it?
EDIT: i think it would be SetProperty(weap_name, "variable_to_change, #) is t
- Fiodis
- Master of the Force

- Posts: 4145
- Joined: Wed Nov 12, 2008 9:27 pm
- Projects :: Rannoch + Tientia + Tools Programming
Re: LUA questions
Tean - I thought you couldn't edit weapons via lua?
-
myers73
- Lieutenant General

- Posts: 690
- Joined: Fri Apr 03, 2009 11:04 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Atlanta, GA xfire=myers73 IngameName=mYers
Re: LUA questions
another question... what is the function for killing someone via lua, also to force spawn them would also be nice. basically i want to detect who they spawned as, and if it is the wrong unit kill and respawn them as the correct unit
EDIT
I have never really worked with timers. could someone please post a basic timer setup, ie when the map starts start the timer and when the time runs out end map? thanks in advance
EDIT
I have never really worked with timers. could someone please post a basic timer setup, ie when the map starts start the timer and when the time runs out end map? thanks in advance
-
kinetosimpetus
- Imperial Systems Expert

- Posts: 2381
- Joined: Wed Mar 25, 2009 4:15 pm
- Projects :: A secret project
Re: LUA questions
see hoth campaign script, it uses a timer just like that.
-
myers73
- Lieutenant General

- Posts: 690
- Joined: Fri Apr 03, 2009 11:04 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Atlanta, GA xfire=myers73 IngameName=mYers
Re: LUA questions
^^ thanks, now would you know how to kill and respawn a player?
From Other Topic:
so i am attempting to kill someone when they spawn as hansolo. I didnt know the kill function, so i tried to set the health to zero. I am new to lua, so dont know if i did this right, please help.
From Other Topic:
so i am attempting to kill someone when they spawn as hansolo. I didnt know the kill function, so i tried to set the health to zero. I am new to lua, so dont know if i did this right, please help.
Hidden/Spoiler:
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: LUA questions
You would want to use CurHealth instead of MaxHealth, but KillObject() on the character's unit is simpler.
If GetEntityClassName() returns the class name and not the class ID number, then all_hero_hansolo_tat should be in quotes because it's a string. If that function returns the ID, then all_hero_hansolo_tat should be changed to that unit's ID number.
You have one two many thens.
Forced spawning has been posted a bunch of times to GT. It uses the SelectCharacter() and SpawnCharacter() functions. Search on GT or look at the ambush script.
You can't change weapon properties using SetProperty(). You can change which weapon a unit has in which weapon slot (that is changing a unit property not a weapon property), but those types of changes cause crashes in MP.
If GetEntityClassName() returns the class name and not the class ID number, then all_hero_hansolo_tat should be in quotes because it's a string. If that function returns the ID, then all_hero_hansolo_tat should be changed to that unit's ID number.
You have one two many thens.
Forced spawning has been posted a bunch of times to GT. It uses the SelectCharacter() and SpawnCharacter() functions. Search on GT or look at the ambush script.
You can't change weapon properties using SetProperty(). You can change which weapon a unit has in which weapon slot (that is changing a unit property not a weapon property), but those types of changes cause crashes in MP.
-
myers73
- Lieutenant General

- Posts: 690
- Joined: Fri Apr 03, 2009 11:04 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Atlanta, GA xfire=myers73 IngameName=mYers
Re: LUA questions
so would this work?
also, my timer istn working. it shows up, but never actually starts counting, it just stays at 15:00
Hidden/Spoiler:
Hidden/Spoiler:
- Fiodis
- Master of the Force

- Posts: 4145
- Joined: Wed Nov 12, 2008 9:27 pm
- Projects :: Rannoch + Tientia + Tools Programming
Re: LUA questions
I believe you need StartTimer("timeout") in there somewhere.
As for your killing thing, no. You need unit = GetCharacterUnit(player) and KillObject(unit). Or something like that; you need to kill the player's unit.
As for your killing thing, no. You need unit = GetCharacterUnit(player) and KillObject(unit). Or something like that; you need to kill the player's unit.
-
myers73
- Lieutenant General

- Posts: 690
- Joined: Fri Apr 03, 2009 11:04 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Atlanta, GA xfire=myers73 IngameName=mYers
Re: LUA questions
duh *facepalm* my bad, but thanks a bunch anywayFiodis wrote:I believe you need StartTimer("timeout") in there somewhere.
im guessing this goes right after function(player) ?Fiodis wrote:As for your killing thing, no. You need unit = GetCharacterUnit(player) and KillObject(unit). Or something like that; you need to kill the player's unit.
EDIT
so this is what i did, the time is working fine now (thanks), but the killing people isnt, i think its being ignored.
Hidden/Spoiler:
- Fiodis
- Master of the Force

- Posts: 4145
- Joined: Wed Nov 12, 2008 9:27 pm
- Projects :: Rannoch + Tientia + Tools Programming
Re: LUA questions
You only need 1 GetCharacterUnit.
-
myers73
- Lieutenant General

- Posts: 690
- Joined: Fri Apr 03, 2009 11:04 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Atlanta, GA xfire=myers73 IngameName=mYers
Re: LUA questions
it still is being ignored
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: LUA questions
Toss in a print("Player unit class is:, GetEntityClassName(unit)) after the local unit = GetCharacterUnit(player) line and check the debug log to review the output.
-
myers73
- Lieutenant General

- Posts: 690
- Joined: Fri Apr 03, 2009 11:04 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Atlanta, GA xfire=myers73 IngameName=mYers
Re: LUA questions
here is the debug log, iv pulled out what seems to be the important parts, it was too big to post the whole thing
and this
EDIT: so i cleaned the log and then replayed the map to get one without extra stuff...
EDIT2
sry to double post, but the last post was full.
this seems to not work in my user script ff_healthRegen( 100, "humans" ), any clue why.
also when i use this SetClassProperty("all_hero_hansolo_tat", MaxHealth, 5) in my user script it is being ignored, and when i use it everything that comes after it is ignored... very odd
Hidden/Spoiler:
Hidden/Spoiler:
Hidden/Spoiler:
EDIT2
sry to double post, but the last post was full.
this seems to not work in my user script ff_healthRegen( 100, "humans" ), any clue why.
also when i use this SetClassProperty("all_hero_hansolo_tat", MaxHealth, 5) in my user script it is being ignored, and when i use it everything that comes after it is ignored... very odd
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: LUA questions
Oh, I forgot a ". Here is the codeYou could also reduce the if/elseif statements into one if statement using ors.
You need to understand the difference between variables and strings. SetClassProperty("all_hero_hansolo_tat", MaxHealth, 5) is wrong. In that code, MaxHealth is a variable which contains nil unless you set it to something else using MaxHealth =. What you want is the string MaxHealth which is "MaxHealth" (with quotes).
Code: Select all
OnCharacterSpawn(
function(player)
local unit = GetCharacterUnit(player)
local name = GetEntityClassName(unit)
print("Spawned a character unit with the entity class name:", name)
if name == "all_hero_hansolo_tat" then
KillObject(unit)
elseif name == "all_hero_leia" then
KillObject(unit)
elseif name == "all_hero_chewbacca" then
KillObject(unit)
elseif name == "imp_hero_bobafett" then
KillObject(unit)
elseif name == "cis_hero_jangofett" then
KillObject(unit)
end
end
)You need to understand the difference between variables and strings. SetClassProperty("all_hero_hansolo_tat", MaxHealth, 5) is wrong. In that code, MaxHealth is a variable which contains nil unless you set it to something else using MaxHealth =. What you want is the string MaxHealth which is "MaxHealth" (with quotes).
-
myers73
- Lieutenant General

- Posts: 690
- Joined: Fri Apr 03, 2009 11:04 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Atlanta, GA xfire=myers73 IngameName=mYers
Re: LUA questions
ok, all of that makes sense.
