Scripting lua trying get WHILE

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Scripting lua trying get WHILE

Post by Maveritchell »

Deviss wrote:i know and i tested by make crash :S , maybe because WHILE? but supposly while must work without problems in lua, but always i use it cause crash :S , for this reason i need if zerted can save me, or yes or yes i need use IF for no crash xD
I told you why the while loops are probably crashing - you need to be using them only to iterate through something, for example:

Code: Select all

variable = 0
while variable < 10 do
	print(variable) 
	variable + 1
end
Like Zerted said, there's no really good way to check when a character exits a vehicle. The code he's talking about would look like this (this is just the back half of the code to check when the player exits a vehicle):

Code: Select all

checkvehtime = CreateTimer("checkveh")
SetTimerValue(checkvehtime, 1)
StartTimer(checkvehtime)
checkvehicle = OnTimerElapse(
	function(timer)
		if IsCharacterHuman(GetTeamMember(1,0) or IsCharacterHuman(GetTeamMember(2,0) then
			if GetCharacterVehicle(GetTeamMember(1,0)) or GetCharacterVehicle(GetTeamMember(2,0)) then
				SetProperty("vehiclespawnname", "AddHealth", 0)
			end
		end
		SetTimerValue(checkvehtime, 1)
		StartTimer(checkvehtime)
	end,
checkvehtime
)
Deviss
Master of the Force
Master of the Force
Posts: 3772
Joined: Tue Aug 12, 2008 7:59 pm
Projects :: Clone Wars Extended
Games I'm Playing :: BF2

Re: Scripting lua trying get WHILE

Post by Deviss »

Maveritchell wrote:
Deviss wrote:i know and i tested by make crash :S , maybe because WHILE? but supposly while must work without problems in lua, but always i use it cause crash :S , for this reason i need if zerted can save me, or yes or yes i need use IF for no crash xD
I told you why the while loops are probably crashing - you need to be using them only to iterate through something, for example:

Code: Select all

variable = 0
while variable < 10 do
	print(variable) 
	variable + 1
end
Like Zerted said, there's no really good way to check when a character exits a vehicle. The code he's talking about would look like this (this is just the back half of the code to check when the player exits a vehicle):

Code: Select all

checkvehtime = CreateTimer("checkveh")
SetTimerValue(checkvehtime, 1)
StartTimer(checkvehtime)
checkvehicle = OnTimerElapse(
	function(timer)
		if IsCharacterHuman(GetTeamMember(1,0) or IsCharacterHuman(GetTeamMember(2,0) then
			if GetCharacterVehicle(GetTeamMember(1,0)) or GetCharacterVehicle(GetTeamMember(2,0)) then
				SetProperty("vehiclespawnname", "AddHealth", 0)
			end
		end
		SetTimerValue(checkvehtime, 1)
		StartTimer(checkvehtime)
	end,
checkvehtime
)
now i understand sorry i am a bit slow xD, so creating a timer but is unexact i had the idea because when you use pilot in space you gain regen of vehicle and when you exit of it, vehicle dont keep regen, but well is other hardcode more in my list :P, many thanks by your effort and time :D and for teach me again :)
myers73
Lieutenant General
Lieutenant General
Posts: 690
Joined: Fri Apr 03, 2009 11:04 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Atlanta, GA xfire=myers73 IngameName=mYers

Re: Scripting lua trying get WHILE

Post by myers73 »

wont setting the unit type to pilot and adding the lines in the pilot odf about vehicle regen do exactly what you are trying to do?
Deviss
Master of the Force
Master of the Force
Posts: 3772
Joined: Tue Aug 12, 2008 7:59 pm
Projects :: Clone Wars Extended
Games I'm Playing :: BF2

Re: Scripting lua trying get WHILE

Post by Deviss »

myers73 wrote:wont setting the unit type to pilot and adding the lines in the pilot odf about vehicle regen do exactly what you are trying to do?
i didnt try xD and i dont know how lol, but yeah something a bit simil i didnt know had regen because unittype pilot so is harder code yet xD
Post Reply