• 3D2D : draw.DrawText(Variable, .. , .. , .. , .. )
    6 replies, posted
Hi First sorry for my English , i'm French ° ^ °. So i was trying to put a Variable on a draw.DrawText and i tried : [QUOTE]shared.lua : local WaterAmount = 20[/QUOTE] [QUOTE]cl_init.lua : cam.Start3D2D(self:GetPos() + Vector(0,-15,25) , Angle(0,0,75) , 0.1) draw.DrawText("Water:WaterAmount","TheDefaultSettings",-120,80,Color(255,127,80)) [/QUOTE] and [QUOTE]shared.lua : function ENT:SetupDataTables() self:NetworkVar("Init" , 1 , "WaterAmount") end [/QUOTE] [QUOTE]cl_init.lua : cam.Start3D2D(self:GetPos() + Vector(0,-15,25) , Angle(0,0,75) , 0.1) draw.DrawText(WaterAmount,"TheDefaultSettings",-120,80,Color(255,127,80)) or draw.DrawText(self:GetWaterAmount,"TheDefaultSettings",-120,80,Color(255,127,80)) [/QUOTE] But it do a error message on the console , or it just draw "Water:WaterAmount" ... etc I know that i probably did big misstakes but i'm clearly a noob at programming ^^' . If you still didn't understood , I didn't succeed to do someting like this : [url]https://image.noelshack.com/fichiers/2017/44/2/1509409414-schema-3d2d-text-and-une-variable.png[/url] By The Way : If you know French , a French answer could be awesome to better understand <3
I do not really understand how to adapt it ^^' . Is it : cl_init.lua [CODE] function ENT:Draw() self.Entity:DrawModel() cam.Start3D2D(self:GetPos() + Vector(0,-15,25) , Angle(0,0,75) , 0.1) draw.DrawText("Conteneur D'eau","TheDefaultSettings",-10,0,Color(120,120,255),1,1) draw.DrawText("Water:"WaterAmount,"TheDefaultSettings",-120,80,Color(255,127,80)) cam.End3D2D() end [/CODE] shared.lua [CODE] local WaterAmount = 10 [/CODE] Because actually it makes a bugged map , and still no what i wanted. :/
It's called [url=https://www.lua.org/pil/3.4.html]concatenation[/url]
You concatenate the variable to a string, in Lua concatenate is done using two periods, I would try [code]" "..<variable>[/code]
YESSSS ! Thanks guys : P ! so finnally the "local WaterAmount = 20" is in cl_init.lua . THANKS ! : P But now there is still this map bug : [url]https://image.noelshack.com/fichiers/2017/44/2/1509417602-buggg.png[/url] with this script : [CODE] include("shared.lua") local WaterAmount = 20 surface.CreateFont( "TheDefaultSettings", { font = "Arial", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name extended = false, size = 50, weight = 500, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = false, additive = false, outline = false, } ) function ENT:Draw() self.Entity:DrawModel() cam.Start3D2D(self:GetPos() + Vector(0,-15,25) , Angle(0,0,75) , 0.1) draw.DrawText("Conteneur D'eau","TheDefaultSettings",-10,0,Color(120,120,255),1,1) draw.DrawText("Water:"..WaterAmount,"TheDefaultSettings",-120,80,Color(255,127,80)) cam.End3D2D() end [/CODE] If you could help me ^^' .
Ok so finnally everything is ok . Thanks .
Sorry, you need to Log In to post a reply to this thread.