generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Table Help

Previous Thread :: Next Thread 
Lightmaster9 is not online. Lightmaster9
Joined: 14 May 2009
Total Posts: 8659
05 Aug 2013 07:51 AM
Things to note;

> The function comes in like this: if CheckWeapon(Wep.Value) ~= false then
> Wep is a variable that leads to a StringValue

This is the part:

local accepted = {"Iron Sword", "Nature"}
local penetrations = {21, 97}
local current_pen = nil

function CheckWeapon(dmg_dealer)
for i = 1, #accepted do
if (string.lower(dmg_dealer)) == (string.lower(accepted[i])) then
print("Hit registered as " .. accepted[i])
current_pen = penetrations[i]
return true
end
return false
end
end

It only reads the first part of the Table even though there are two items. My whole idea is to let the script read what item triggered a hit. Later on in the future, I'll start letting the script in the main function check if I've been hit by an attacker or not. The Nature part is purely for testing and won't be in the final game.

Tell me if you'd like me to post a certain part of the script or the full script.
Report Abuse
Lightmaster9 is not online. Lightmaster9
Joined: 14 May 2009
Total Posts: 8659
05 Aug 2013 08:07 AM
...bump? D:
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
05 Aug 2013 08:14 AM
I don't really understand the situation but note that when you use return the function stops there.
Report Abuse
Lightmaster9 is not online. Lightmaster9
Joined: 14 May 2009
Total Posts: 8659
05 Aug 2013 08:17 AM
@screw,
I know. I need the return to be true so that my main function can tell if the Player has been damaged by a weapon from an enemy. The "for" loop won't read both items in the "accepted" table though. Here's the full script so far (might take a bit of space :P):

local Player = game.Players.LocalPlayer
local Humanoid = Player.Character:findFirstChild("Humanoid")

while Humanoid == nil do
wait()
end

local Stats = Player:findFirstChild("Stats")

while Stats == nil do
wait()
end

local Damage = Stats.DMG
local Arm = Stats.Armor
local Wep = Stats.Weapon_Hit_By
local Hit_Time = Stats["Hit Time"]
local Hit = Stats.Hit
local Blocking = Stats.Blocking
local Gui = script.Parent
local HP_Gui = Gui.Front
local d = false

local accepted = {"Iron Sword", "Nature"}
local penetrations = {21, 97}
local current_pen = nil

function CheckWeapon(dmg_dealer)
for i = 1, #accepted do
if (string.lower(dmg_dealer)) == (string.lower(accepted[i])) then
print("Hit registered as " .. accepted[i])
current_pen = penetrations[i]
return true
end
return false
end
end



Hit.Changed:connect(function()
if Hit.Value ~= false and not Blocking.Value ~= false and not d then
d = true
if CheckWeapon(Wep.Value) ~= false then
if Arm.Value > 1 then
Arm.Value = Arm.Value - current_pen
if Arm.Value < 1 then
Arm.Value = 0
end
if Arm.Value > 1 then
Humanoid:TakeDamage(math.floor(current_pen/Damage.Value)*10)
elseif Arm.Value < 1 then
Humanoid:TakeDamage(math.floor(current_pen/Damage.Value)*100)
end
elseif Arm.Value < 1 then
Humanoid:TakeDamage(math.floor(Damage.Value))
end
local eq = (Humanoid.Health/Humanoid.MaxHealth)*100
HP_Gui:TweenSize(UDim2.new(0,eq,0,10), In, "Quad", Hit_Time.Value, false)
wait(Hit_Time.Value)
end
Hit.Value = false
d = false
elseif Hit.Value ~= false and Blocking.Value ~= false and not d then
print("Blocked!")
Blocking.Value = false
Hit.Value = false
return
end
end)
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
05 Aug 2013 08:22 AM
My point is if the first table value and the damage thing isn't equal, it will return false and not loop again bc of how you set it
Report Abuse
Infocus is not online. Infocus
Joined: 28 Apr 2011
Total Posts: 8022
05 Aug 2013 08:24 AM
Pfft!

Penetrations...lal



Wut da output
Report Abuse
Lightmaster9 is not online. Lightmaster9
Joined: 14 May 2009
Total Posts: 8659
05 Aug 2013 08:26 AM
@infocus
Only the prints.
Report Abuse
Infocus is not online. Infocus
Joined: 28 Apr 2011
Total Posts: 8022
05 Aug 2013 08:29 AM
So wut did u want it to do?

Too lazy to skim
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
05 Aug 2013 08:37 AM
Boi did u evn modify ur script accrding to mah suggestion.
Report Abuse
Infocus is not online. Infocus
Joined: 28 Apr 2011
Total Posts: 8022
05 Aug 2013 08:38 AM
Bro u dnt evn lau
Report Abuse
Lightmaster9 is not online. Lightmaster9
Joined: 14 May 2009
Total Posts: 8659
05 Aug 2013 08:39 AM
@infocus,
NOTES:
> This is a LocalScript is that helps

"local Damage = Stats.DMG
local Arm = Stats.Armor
local Wep = Stats.Weapon_Hit_By
local Hit_Time = Stats["Hit Time"]
local Hit = Stats.Hit
local Blocking = Stats.Blocking"

These are located in the Stats (a model that is in the Player in game.Players). I want the function to firstly check if the Player got hit by anything that would be from a hostile NPC.

That is where the "accepted" table is. I also would like it to check for armor to see if it needs to take down the damage due to the protection of the armor as well as damaging the armor.

The problem is, is that when I get the For loop to scan through accepted, I need it to find the Weapon Name that is located in the String Value (Wep). But I also have the penetration table. This is for when accepted is the 2nd (or higher or lower), the penetration also switches to the 2nd number (or higher or lower) in the table. This then gives that number to current_pen which goes into an equation to calculate the total damage done to the health and armor if there is any.

The For loop only reads the "Iron Sword", and it won't read the "Nature". Sorry for the elephant-sized reply xPP Hope it makes sense :o
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
05 Aug 2013 08:40 AM
Bro who u think i iz, course i lau
Report Abuse
Lightmaster9 is not online. Lightmaster9
Joined: 14 May 2009
Total Posts: 8659
05 Aug 2013 08:41 AM
Sorry I forgot something - the returns are what sends the info about it being a proper hit or not ^^
Report Abuse
Lightmaster9 is not online. Lightmaster9
Joined: 14 May 2009
Total Posts: 8659
05 Aug 2013 08:50 AM
Oh my the maths is so wrong when it comes to the dmg XDDDD It heals the noob instead :D
Report Abuse
Lightmaster9 is not online. Lightmaster9
Joined: 14 May 2009
Total Posts: 8659
05 Aug 2013 09:31 AM
and all this time i thought i had return false in the right place... turned out that i misplaced it *FACEDESK*
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
05 Aug 2013 09:33 AM
Das what I was trying to say q-q
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
05 Aug 2013 09:38 AM
[ Content Deleted ]
Report Abuse
Infocus is not online. Infocus
Joined: 28 Apr 2011
Total Posts: 8022
05 Aug 2013 01:36 PM
Back, i have an idea in mind. It will change the pattern of your script though, so ill try to work with yours.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image