Hi, I am creating my first derma (oh yeah ...)
Here the code :
[lua]
function ChoixMeteo()
local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 200, 250 )
DermaPanel:SetTitle( "Changer la meteo" )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()
local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel"
DermaButton:SetText( "Ensoleille" )
DermaButton:SetPos( 25, 50 )
DermaButton:SetSize( 150, 50 )
DermaButton.DoClick = function ()
RunConsoleCommand( "meteo_selectionner ensoleille" )
local DermaButton2 = vgui.Create( "DButton" )
DermaButton2:SetParent( DermaButton ) "
DermaButton2:SetText( "Pluvieux" )
DermaButton2:SetPos( 25, 50 )
DermaButton2:SetSize( 150, 50 )
DermaButton2.DoClick = function ()
RunConsoleCommand( "meteo_selectionner pluvieux" )
end
concommand.Add( "meteo_menu", ChoixMeteo );
[/lua]
When I go into the console and when I type meteo_menu, nothing appear, there is not any error messages.
I've tryed to put the meteo_selectionner.lua file into autorun/, autorun/server, autorun/client
but same.
Somebody can help me ?
Thanks !
Sorry for my bad english, I study english by my own !
Why are you putting it into 3 different folders? The right place is /lua/autorun/client/
Other than that, put a print somewhere to ensure the file is being loaded. I didn't play arround with it but it seems to be fine, it should work like that.
Looks like you aren't closing your DoClick functions which would result in an error that should show up in your console. Try this:
[lua]function ChoixMeteo()
local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 200, 250 )
DermaPanel:SetTitle( "Changer la meteo" )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()
local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel"
DermaButton:SetText( "Ensoleille" )
DermaButton:SetPos( 25, 50 )
DermaButton:SetSize( 150, 50 )
DermaButton.DoClick = function ()
RunConsoleCommand( "meteo_selectionner ensoleille" ) end
local DermaButton2 = vgui.Create( "DButton" )
DermaButton2:SetParent( DermaButton ) "
DermaButton2:SetText( "Pluvieux" )
DermaButton2:SetPos( 25, 50 )
DermaButton2:SetSize( 150, 50 )
DermaButton2.DoClick = function ()
RunConsoleCommand( "meteo_selectionner pluvieux" ) end
end
concommand.Add( "meteo_menu", ChoixMeteo );[/lua]
Same : Unknow Command : meteo_menu
Maybe script enforcer is on?
[QUOTE=KyleWollasto;32125019]Looks like you aren't closing your DoClick functions which would result in an error that should show up in your console. Try this:
[lua]function ChoixMeteo()
local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 200, 250 )
DermaPanel:SetTitle( "Changer la meteo" )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()
local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel"
DermaButton:SetText( "Ensoleille" )
DermaButton:SetPos( 25, 50 )
DermaButton:SetSize( 150, 50 )
DermaButton.DoClick = function ()
RunConsoleCommand( "meteo_selectionner ensoleille" ) end
local DermaButton2 = vgui.Create( "DButton" )
DermaButton2:SetParent( DermaButton ) "
DermaButton2:SetText( "Pluvieux" )
DermaButton2:SetPos( 25, 50 )
DermaButton2:SetSize( 150, 50 )
DermaButton2.DoClick = function ()
RunConsoleCommand( "meteo_selectionner pluvieux" ) end
end
concommand.Add( "meteo_menu", ChoixMeteo );[/lua][/QUOTE]
Look at line 20
[lua]
function ChoixMeteo()
local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 200, 250 )
DermaPanel:SetTitle( "Changer la meteo" )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()
local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( DermaPanel )
DermaButton:SetText( "Ensoleille" )
DermaButton:SetPos( 25, 50 )
DermaButton:SetSize( 150, 50 )
DermaButton.DoClick = function ()
RunConsoleCommand( "meteo_selectionner ensoleille" )
end
local DermaButton2 = vgui.Create( "DButton" )
DermaButton2:SetParent( DermaPanel )
DermaButton2:SetText( "Pluvieux" )
DermaButton2:SetPos( 25, 50 )
DermaButton2:SetSize( 150, 50 )
DermaButton2.DoClick = function ()
RunConsoleCommand( "meteo_selectionner pluvieux" )
end
end
concommand.Add( "meteo_menu", ChoixMeteo );
[/lua]
That should work.
[QUOTE=c-unitV2;32133543]Look at line 20
[lua]
function ChoixMeteo()
local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 200, 250 )
DermaPanel:SetTitle( "Changer la meteo" )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()
local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( DermaPanel )
DermaButton:SetText( "Ensoleille" )
DermaButton:SetPos( 25, 50 )
DermaButton:SetSize( 150, 50 )
DermaButton.DoClick = function ()
RunConsoleCommand( "meteo_selectionner ensoleille" )
end
local DermaButton2 = vgui.Create( "DButton" )
DermaButton2:SetParent( DermaPanel )
DermaButton2:SetText( "Pluvieux" )
DermaButton2:SetPos( 25, 50 )
DermaButton2:SetSize( 150, 50 )
DermaButton2.DoClick = function ()
RunConsoleCommand( "meteo_selectionner pluvieux" )
end
end
concommand.Add( "meteo_menu", ChoixMeteo );
[/lua]
That should work.[/QUOTE]Wow, I'm blind. Thanks for catching that :p.
There would be an error message for that.
I think the error would be something about an unfinished string
XD the error is :
[addons\meteomod\lua\autorun\client\meteo_selectionner.lua:26] RunConsoleCommand: Command has invalid characters! (meteo_selectionner pluvieux (' '))
The first parameter of this function should contain only the command, the second parameter should contain arguments.
And only the "Pluvieux" button appear !
Thanks for any other help, I'm so bad in lua ...
You can't have spaces in RunConsoleCommand.
RunConsoleCommand(command,arguments,...)
So use
RunConsoleCommand("meteo_selectionner" , "pluvieux")
The "ensoleille" button do not appear on the derma ! Why ?
But the "pluvieux" button now work :)
I've tryed
[lua]
function ChoixMeteo()
local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 200, 250 )
DermaPanel:SetTitle( "Changer la meteo" )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()
local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( DermaPanel )
DermaButton:SetText( "Ensoleille" )
DermaButton:SetPos( 25, 50 )
DermaButton:SetSize( 150, 50 )
DermaButton.DoClick = function ()
RunConsoleCommand( "meteo_selectionner" ,"ensoleille" )
end
local DermaButton2 = vgui.Create( "DButton" )
DermaButton2:SetParent( DermaButton )
DermaButton2:SetText( "Pluvieux" )
DermaButton2:SetPos( 25, 50 )
DermaButton2:SetSize( 150, 50 )
DermaButton2.DoClick = function ()
RunConsoleCommand( "meteo_selectionner" ,"pluvieux" )
end
end
concommand.Add( "meteo_menu", ChoixMeteo );
[/lua]
But now only the "ensoleille" button appear and don't work !
Thanks for any other help
You're setting them to the same place. Set them to different positions.
also if the buttons are 150 long, and the screen is only 200 long ... then 2 buttons = 300 alone, which is bigger then your panel
Okay thanks you very much !!!
Subject Closed :)
Sorry, you need to Log In to post a reply to this thread.