• Am I doing alright so far?
    5 replies, posted
I have never coded in Lua before today, and I'm trying to make an addon... Have I messed up horribly yet on the init.lua? [CODE]AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include( "shared.lua" ) --When a car touches the race line, announce it. ENT=="3d_raceline" if ENT:StartTouch(ENT) then print("It Works!") end if sk_allowdeath == 0 and if player.GetAll(Entity:Health()) < 100 then player.GetAll(Entity:SetHealth(100)) print("Set to 100") end[/CODE] sk_allowdeath being a setting from the addon file Will it run properly?
Can you give a description of what you're trying to do?
[CODE] --When a car touches the race line, announce it. ENT=="3d_raceline" if ENT:StartTouch(ENT) then print("It Works!") end [/CODE] When something touches a brush named 3d_raceline print "It Works!" [CODE]if sk_allowdeath == 0 and if player.GetAll(Entity:Health()) < 100 then player.GetAll(Entity:SetHealth(100)) print("Set to 100") end [/CODE] if a setting named sk_allowdeath is 0, and if any player's health is below 100 then set everyone's health to 100 and print another useless thing.
Is this in a gamemode's init.lua or an entity's?
gamemode.
This is gonna crash and burn immediately. It looks like what you want to do is create a custom entity to act as your starting line. To do that, you should create a new script for the entity, and define the ENT:StartTouch() function there. And define it as a function, instead of trying to call it. [code] function ENT:StartTouch() -- this code runs when your entity touches something. you can use the name 'self' to refer to the current entity instance. end [/code] You will also need to define a few other things for the entity. I suggest finding a tutorial on the wiki.
Sorry, you need to Log In to post a reply to this thread.