Jump to content

CoolBeans

Members
  • Posts

    39
  • Joined

  • Last visited

Posts posted by CoolBeans

  1. Decreasing Food / Thirst.

     

    Hello,

     

    Trying to figure out how to have a calorie and thirst system. Ive already cheated and copied

    the health system twice and renamed both of them. Ive also set up 3 meters on screen

    health, hunger and thirst. Eventually I want to use calories and dehydration when my charater

    walks, chops, crafts, or any kind of activity for the most part. For now Id settle for a timed

    system first. I just want the food and thirst levels to decrease as time goes on in game.

    --float so i can adjust the speeds individually on the fly wink.png

     

    Thirst script on bottle of water or what ever fluids.

     

    Script.thirst = 15.0 --float "Thirst"

    Script.useOnce = true --bool "Use once"

     

    function Script:Start()

    if self.thirst < 0 then

    error("Thirst can't be a negative value.")

    end

    end

     

    function Script:Use(player)

    if player.script.thirst < player.script.maxThirst then

    player.script:ReceiveThirst(self.thirst)

    if self.useOnce then

    self.entity:Release()

    end

    end

    end

     

     

    FPSPlayer Script

     

    Script.thirst = 100 --float "Thirst"

    Script.maxThirst = 100 --float "Max Thirst"

     

    **

     

    function Script:Thirst(Thirsty,distributorOfThirst)

    if self.thirst>0 then

    self.sound.damage[math.random(#self.sound.damage)]:Play()

    self.thirst = self.thirst - damage

    if self.thirst<=0 then

    self:Kill()

    end

    end

    end

     

     

    **

     

     

     

     

    --If thirst lower or equal to zero, the player is dead

    if self.thirst <= 0 then

    self.alive = false

    --Call the OnDead output

    self:OnDead()

    end

    end

     

    --Increase thirst

    function Script:ReceiveThirst(thirstPoints)--in

    --Increase thirst

    self.thirst = self.thirst + thirstPoints;

     

    --Thirst can not be more then maximum thurst

    if self.thirst > self.maxThirst then

    self.thirst = self.maxThirst

    end

     

    --Call Thurst received output

    self.component:CallOutputs("ThirstReceived")

    end

     

    --when thirst is zero or lower, an output call is made

    function Script:OnDead()--out

    --Extra check to make sure that the player is no longer alive

    if not(self:IsAlive()) then

    self.component:CallOutputs("Ondead")

    end

     

     

    Any help on the timed decrease would be awesome!

     

    If you can help with other details like faster decrease of thirst in different environments like desert

    or when chopping a tree etc would be a plus wink.png At least point me the direction. Further If I could have

    it start to decrease your health after a certain point I just thought of! Please O' man help an amateur out!

     

    Sneaking one in...

    Another question. Best way to have a map full of different trees and have it to where I can chop them

    down and convert them to wood. Maybe play the tree falls over animation. I found one topic

    in here on this matter and it fizzled out. Need some detailed help / direction if possible. Thank you!

     

    CB!

  2. Yes Rick its "player" the only part of this I'm fully understanding. Some lessons would be nice. I currently have no cash

    but when I do I will consider your services for sure. I'm just a guy tired of his job trying to changed gears half way through

    life while sitting at home with no work. Ive got 150 hours into this so no I don't know the most basic stuff. However I am trying

    to keep my motivation going with what I have achieved so far. (Impressed myself anyways) I will study up more on functions.

    I'm still in the if, then, and, early stages of comprehension so bare with me biggrin.png

  3. I'm hoping to take this topic further as I do want to make my zombies drop random ammo per gun.

    I have random spawning zombies and random dropping guns and health packs working. I have the

    hud working, day night cycle, zombie kill score all working. Once I get this going motivation will be

    great and lean towards level design since Ill be satisfied with mechanics at that point for a while.

    Oh quick question too why can't the FPSplayer crouch? I admit I have not looked the code over

    for contrl key use. I will now and try to answer my own question lol. Too much coffee!!!

  4. I deleted my post above because it is giving me problems too....every time I think I have it figured out it gives me more problems...I will post again if I get it figured out...Rick is right about the 'person.entity.script.variable' being silly...it does work well with the Health though....sorry for any inconvenience....

     

    No problem man your help big or small is greatly appreciated!

    I'm glad someone is in the same boat with me I just hope it doesn't sink on us smile.png

     

    CB

  5. Yes I assumed that "person" could be any name. Ie Player, Character, John, Moses. Whatever your "player" is named.

    Since the FPSplayer script uses player it makes more sense to me to keep it that way.

     

    I'm trying to understand what Rick said but I'm not far along enough to fully make it all click and work. Wont

    stop me from trying however.

     

    All I know is BlueH doesn't go over adding any code anywhere else. He makes a box. Give is a mass of 1

    makes it a prop and give this code to the box.

     

     

     

    ********************************************************************

     

    AMMOBOX-

    attempt to index field 'weapons' (anil value) line 3

     

     

    Script.AmmoAmount=50 --float

    function Script:Use(player)

    player.weapons[player.currentweaponindex].ammo =

    player.weapons[player.currentweaponindex].ammo + self.AmmoAmount

    self.entity:Release()

    end

     

    Then he uses the stock prefab FPSplayer in the scene and it works fine so you got me as to why it does not work.

    Same with his small hurt script above and health script. The tutorials are 2 months old so its very frustrating they don't work.

     

    Honestly I figured most of you experts could look at things like this and in 5 sec say

    "hey here the problem" am I crazy to be thinking this? Specially dealing with stock or add-on assets...

     

    Thanks again

    CB

  6. Same error. His script calls for "person.weapons" I even tried changing all instances to "player"

    same error

     

    Script.ammoamount=6 --int "Ammo Amount"

    Script.ammotype=1 --int "Ammo Type"

     

    function Script:Use(player)

    for a=0,6 do

    if player.weapons[a]~=nil then

    if player.weapons[a].index==self.ammotype then

    if player.weapons[a].ammo+player.weapons[a].clipammo<player.weapons[a].maxammo then

    player.weapons[a].ammo= player.weapons[a].ammo + self.ammoamount

    if player.weapons[a].ammo+player.weapons[a].clipammo>player.weapons[a].maxammo then

    player.weapons[a].ammo=player.weapons[a].maxammo-player.weapons[a].clipammo

    end

    self.entity:Release()

    self.entity=nil

    return

    end

    end

    end

    end

    end

     

    If I could get it to work and define ammo type per gun that would be aces! I think something must be added

    to FPSplayer.

  7. BluHornets Tutorial. Gone over them can't find the obvious.

    He makes a helath box, ammo box and hurt box. The scripts below.

    I either miss where he adds something to the FPSplayer script

    or he forgets to mention it to avoid these errors?

     

     

     

    ********************************************************************

     

    AMMOBOX-

    attempt to index field 'weapons' (anil value) line 3

     

     

    Script.AmmoAmount=50 --float

    function Script:Use(player)

    player.weapons[player.currentweaponindex].ammo =

    player.weapons[player.currentweaponindex].ammo + self.AmmoAmount

    self.entity:Release()

    end

     

    ********************************************************************

    HEALTHBOX-

    atempt to call method 'ReceiveHealth' (a nil value) line 4

     

     

    Script.HealthAmount=50 --float

     

    function Script:Use(entity)

    entity:ReceiveHealth(self.HealthAmount)

    self.entity:Release()

    end

     

     

    ********************************************************************

     

    HURTBOX-

    attempt to call 'Hurt' (a nill value) line 7

     

     

    Script.HurtAmount=25 --float

     

    function Script:Start()

    end

     

    function Script:Use(entity)

    entity:Hurt(self.HurtAmount)

    end

     

    *************************************

     

     

     

     

     

     

     

     

     

     

    This is Jorns health kit I got working but If I remember right something is added to FPSplayer for i

    to work. Maybe that's the problem above. I tired to PM bluH about this he must be busy.

     

    Thanks

    CB

     

    Script.health = 15.0 --float "Health"

    Script.useOnce = true --bool "Use once"

     

    function Script:Start()

    if self.health < 0 then

    error("Health can't be a negative value.")

    end

    end

     

    function Script:Use(player)

    if player.script.health < player.script.maxHealth then

    player.script:ReceiveHealth(self.health)

    if self.useOnce then

    self.entity:Release()

    end

    end

    end

  8. Thanks for the tip BH. I'm starting to see how every problem overcome is a valuable learning experience.

    Just a few weeks ago I thought I would never get this but already I'm fixing things and learning fast. I know

    I'm a long long long way away but every time I think that I learn something new and the motivation sticks.

    Never thought it could be so frustrating wanting to learn everything yesterday. Why wasn't it like that

    back in school wink.png. Of course I have many of you to thank for your help so thanks again!

  9. 0o0 OMG! I may as well throw in the towel too much to learn. This is amazing man!

     

    If only there was organized information somewhere on this stuff people could actually learn from...

  10. Odd it was there, copied it from his tutorial wink.png Again thanks so much you have helped me advance more in 24 hours then I have in 2 weeks. I got some oddities I'm going to try to tune on myself with the display but the ammo count works as well as clip and health.This is awesome! 2 Problems I got to ask at this point since you are so kind to help. Do you know how I can start with no weapon and not get the nil error? In my game you start with no guns. The other problem is the prefab machete doesn't work if added to a game with the Hud script active. I get the hand icon and I can manually pick it up. Swept over auto pickup not working as well as can't equip or use it.I added shot gun working fine. Something to do with the machete not having ammo mechanics .. and the Hud script?

     

    I have awesome in game sound, day night cycle and now the hud sorta working as well as navmash and ai, this is monumental ;) Can anyone tell me how to make screen shots in game? It doesn't capture the game app.

     

    CB

  11. Thanks for the fix on the health bar flashing from the other topic.

    http://www.leadwerks.com/werkspace/topic/10817-problem-with-pistol-prefab/

     

    Well maybe I'm in too deep on this one. This is the HUD tutorial from Blue Hornet.

    I'm starting to think he did some prior tutorials and there is some code I'm missing in other areas like FPSplayer for example.

    Besides the one already done.

     

    Killscore for example must be else where. I need to learn the global, local, place in lua.app or not ect have not gone over a good description of how the order of things work in lua perhaps I shall.

     

    I added the killscore = 0 at the top of lua got me passed that error and on to the next ;(

     

    error in function 'DrawImage'.

    argument #6 is '[no object]';'number' expected.

    line 66

     

     

    context:DrawImage(self.HudRightImage,context:GetWidth()-self.HudRightImage:GetWidth(),context:GetHeight()-self.HudRightImage:GetWidth(),context:GetHeight())

     

    Thank you,

    CB

     

    Edit: another problem I'm having with a lot of tutorials is the FPSplayer is not the same code in most examples.

    even on tutorials that are only 2 months old.

  12. I knew it had to be something simple but vastly missed. Thanks a ton it got me further but with trouble still.

    That also explains the intermittent working. Problem now is if I try the healthbar from Jorns on its own it works

    but when I fire a weapon the health bar changes yellow. Sometimes I can hold the fire down and keep it

    yellow. Must have something to do with Red for background and green for overlay mixed with muzzle blast problem?

     

    As for the Hud I have a new error and checked the code on the line I think it's ok?

     

    Attempt to index a nil value line 40

     

    self.ClipAmmoText = "Round in Mag = " .. self.player.script.weapons[self.player.script.currentweaponindex].clipammo

     

    Thanks again.

     

    CB

     

     

     

    Edit:

     

    Hmmm I added the prefab weapon to the player and got passed that error to a new one.

    I hope I dont have to have a weapon in inv already for it to work. New error I get after adding

    prefab gun is.

     

    attempt to concatenate global 'killScore' (a nil value

    line 42

     

    self.ScoreText = "Score = " .. KillScore

     

    Assuming I'm missing something again, obviously. Looking into it wink.png

     

    CB

  13. I hate to start a topic for this but just about every tutorial I do comes up with it from Jorns

    Health bar tutorial to Blue Hornets awesome Hud tutorial to others as well.

    Is my FPSplayer script goofed or something? Even when starting a new project with new

    FPSplayer script same error. Odd thing is sometimes I get Jorns health bar to work.

    I tripled checked the code so there should be few errors now.

     

    Ive added the hud code - line 38 error please help.

    l also added the FPSplayer script just in case.

     

    **********************************************************************

     

    I just created a new project. Made a box. Dragged FPSplayer prefab to scene.

    Added Pivot. Added script helathbar.lua back up direct from Jorns download.

    Error line 27 as mentioned. ARRRRRRRRRRRR included in download.

     

    line 27

    local healthFactor = self.player.script.health / self.player.script.maxHealth

     

    Thanks a lot

    CB

  14. Sorry I wasn't more clear and thank you very much for answering! I meant to say I can't find in LeadWerks where to

    edit the .mat file. Is there a material editor in LW? From the screen shot it looks like its edited in LW, thanks.

  15. Thanks a lot. I can't find where you edit the .mat file. for the muzzle flash problem.

    The topic you redirect to is locked so I can't ask there. Looks like from your image its being edited in LW but I can't find it.

    Thanks again.

  16. Thanks for the info. I don't have a first person prefab. I just created a new project. Made a box. Added a camera. Its camera 2 again. Good to hear on segments in LW Ill be spending much more time in 3dsmax'

     

    I did get spawning to work via death trigger script from Jorns tutorial and renaming from Player to ball so when I roll off I start over at least wink.png

     

    Anyways I'm still having the problem if the ball is idle / not moving the blades sweep right thru the ball not moving it.

     

    I'm also now stuck trying to get a collision to work. If I roll over a small box for example with the ball, the box makes a sound and disappears. Entity(hide) rather. Later to be added to the goal count or score count. What little script can I add to the object?

    I tried dissecting the pickupobject script from the FPS character but it has prefab coding in there and I got a bit lost...

     

    Thanks again for any help fellas.

    CB

  17. There must be a default camera. Odd. I can make a new project place a platform press play and see fine no camera made.

     

    Anyways I made a sphere in 3dsmax 2015 with 64 segments. Learned how to export the FBX file. Imported as a mdl file

    to Leadwerks and its as smooth as GLASS now! Woot! Progress in the smallest form is rewarding muhahaha ok ok...

    I noticed in Leadwerks you can only make 32 segments. If I import a model with 64 is it down graded to 32?

     

    Still cant figure out these physics. Also dragging 3dsmax .mat files into the Leadwerks mat file dir doesn't work?

    I get blank materials when I try to open them in Leadwerks after.

     

    Thanks

    CB

×
×
  • Create New...