ULX

Author Topic: derma chaos / learning  (Read 2131 times)

0 Members and 1 Guest are viewing this topic.

Offline nathan736

  • Full Member
  • ***
  • Posts: 143
  • Karma: 4
derma chaos / learning
« on: January 30, 2013, 09:54:23 PM »
this is my first shot at codeing  derma panels but i need help! give me feed back on what i can do better.
idone it link
http://ideone.com/JLKscx
http://steamcommunity.com/sharedfiles/filedetails/?id=124675629

Code: [Select]

-- Lua generated by DermaDesigner
function dermatest() -- allows the box to not run on start
    print("loading lua box") -- tell the world we are loading
   
    DFrame1 = vgui.Create('DFrame')
    DFrame1:SetPos(0, 600)
    DFrame1:SetSize(235, 216)
   
    DFrame1:SetTitle('points:'.. tostring(LocalPlayer():PS_GetPoints())) -- set this so its not blank and this is where the points are
    DFrame1:SetSizable(false) -- we dont have scaleing on our objects
    DFrame1:SetDeleteOnClose(false) -- you will not be able to delete this anyways
    DFrame1:ShowCloseButton(true) -- debug abilty
    DFrame1:SetVisible(true) -- need this or it will not work
    DFrame1.Paint = function() -- paints the trans of the back panel
    draw.RoundedBox( 8, 0, 0, DFrame1:GetWide(), DFrame1:GetTall(), Color( 0, 0, 0, 150 ) )
    end
   
   
   
    ------------------
    fTextEntry5 = vgui.Create('DTextEntry',DFrame1) -- text box create
    fTextEntry5:SetPos(8, 33)  -- set that pos
    fTextEntry5:SetSize(218, 170) -- how big is this
    fTextEntry5:SetText('') -- we want this blank
    fTextEntry5:AllowInput(false) -- we dont want them to screw with our text
    fTextEntry5.OnEnter = function() end -- place holder
    -----------------
   
    -----------------
    minibutton = vgui.Create('DImageButton',DFrame1) --create button to make box smaller
    minibutton:SetPos(100, 3)
    minibutton:SetSize(20, 20)
    minibutton:SetImage("gui/silkicons/add") -- place holder icon
    minibutton:SizeToContents()
    minibutton.DoClick = function()  -- clicker function
        DFrame1:SetSize(235,30)
        minibutton:SetVisible(false) -- hide it because its small now
        immagefact:SetVisible(true) -- show it because we want to be able to make this big once more
    end
    minibutton.DoRightClick = function() end -- place holder
    -------------------
    immagefact = vgui.Create('DImageButton',DFrame1) -- create the make big button
    immagefact:SetPos(100, 3) -- set that pos
    immagefact:SetSize(20, 20) -- that size  (roughly the same as the other)
    immagefact:SetImage("gui/silkicons/add")
    immagefact:SizeToContents() -- idk seems like a great idea
    immagefact:SetVisible(false) -- hide this because its big already
    immagefact.DoClick = function() -- clicker function
        DFrame1:SetSize(235, 216) -- make big
        minibutton:SetVisible(true) -- show make small
        immagefact:SetVisible(false) -- hide make big
    end
    immagefact.DoRightClick = function() end
   
   
   
    ------------------------
    print("done!") -- the derma panel booted and nothing went wrong we should yell this
   
    timer.Create("update cash", 5, 0,function() -- update this  every so often because we need to
    DFrame1:SetTitle('points:'.. tostring(LocalPlayer():PS_GetPoints()))
    end)
end
local function mydatacapture (data) -- catch the data  the server throws at us
    words = data:ReadString()
    fTextEntry5:SetText(words) -- show the data
end

-- add hooks
usermessage.Hook( "sendpointinfo", mydatacapture )
concommand.Add("dermatest",dermatest)

« Last Edit: February 05, 2013, 10:04:50 AM by nathan736 »
a person asked me how to code lua and i said this " its like building a rocket up side down then  realizing you did it all wrong."

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: derma chaos / learning
« Reply #1 on: February 02, 2013, 12:15:47 PM »
You should include a screen shot of the output so we can see what you are doing visually as well as in code.

Offline nathan736

  • Full Member
  • ***
  • Posts: 143
  • Karma: 4
Re: derma chaos / learning
« Reply #2 on: February 02, 2013, 06:39:27 PM »
updated main post with request im busy so i did it fast ish
a person asked me how to code lua and i said this " its like building a rocket up side down then  realizing you did it all wrong."

Offline nathan736

  • Full Member
  • ***
  • Posts: 143
  • Karma: 4
Re: derma chaos / learning
« Reply #3 on: February 11, 2013, 09:54:48 AM »
Alright im working on the string construction of the message is it better off for me to send the stuff i want to be made into a string to the client and do it there or do it server side ?
a person asked me how to code lua and i said this " its like building a rocket up side down then  realizing you did it all wrong."