Newbie problem

Newbie problem

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
Das Bruce
Posts: 3544
Joined: 23 Nov 2005, 06:16

Newbie problem

Post by Das Bruce »

I have no clue what is wrong with this, does anyone have a clue? It's supposed to just draw the texture, it was working when it was in a test widget but it doesn't seem to like being a gadget. Should this part be synced or not?

Code: Select all

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function gadget:GetInfo()
	return {
		name = "Button",
		desc = "It's a button",
		author = "Das Bruce",
		date = "2009-07-01",
		license = "Public Domain",
		layer = 1,
		enabled = true
	}
end

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local viewx=0
local viewy=0
local width=100
local height=100
local blx=200
local bly=200

if (gadgetHandler:IsSyncedCode()) then
	function gadget:DrawScreen(viewx,viewy)
		gl.PushMatrix()
			gl.Translate(blx, bly, 0)
			gl.Color( 1, 1, 1)
			gl.Texture(":n:bitmaps/UI/button.png")
			gl.TexRect(0, 0, width, height)
			gl.Texture(false)
		gl.PopMatrix()
	end
end
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: Newbie problem

Post by Kloot »

No, the DrawScreen callin doesn't exist in synced gadget space.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Newbie problem

Post by Argh »

Right.

Code: Select all

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function gadget:GetInfo()
   return {
      name = "Button",
      desc = "It's a button",
      author = "Das Bruce",
      date = "2009-07-01",
      license = "Public Domain",
      layer = 1,
      enabled = true
   }
end

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------


if (gadgetHandler:IsSyncedCode()) then

else

local viewx=0
local viewy=0
local width=100
local height=100
local blx=200
local bly=200

   function gadget:DrawScreen(viewx,viewy)
      gl.PushMatrix()
         gl.Translate(blx, bly, 0)
         gl.Color( 1, 1, 1)
         gl.Texture(":n:bitmaps/UI/button.png")
         gl.TexRect(0, 0, width, height)
         gl.Texture(false)
      gl.PopMatrix()
   end
end
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Newbie problem

Post by smoth »

Code: Select all

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function gadget:GetInfo()
	return {
		name = "Button",
		desc = "It's a button",
		author = "Das Bruce",
		date = "2009-07-01",
		license = "Public Domain",
		layer = 1,
		enabled = true
	}
end

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local viewx=0
local viewy=0
local width=100
local height=100
local blx=200
local bly=200

if ( not gadgetHandler:IsSyncedCode()) then
	function gadget:DrawScreen(viewx,viewy)
		gl.PushMatrix()
			gl.Translate(blx, bly, 0)
			gl.Color( 1, 1, 1)
			gl.Texture(":n:bitmaps/UI/button.png")
			gl.TexRect(0, 0, width, height)
			gl.Texture(false)
		gl.PopMatrix()
	end
end
fixed
User avatar
Das Bruce
Posts: 3544
Joined: 23 Nov 2005, 06:16

Re: Newbie problem

Post by Das Bruce »

And yet it still eludes me, my next guess would be the directory it's in but that seems to be right.

Code: Select all

mod.sdd\LuaRules\gadgets\button.lua
What else do you normally have to do to get a gadget to function?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Newbie problem

Post by Argh »

Check the infolog.
User avatar
Das Bruce
Posts: 3544
Joined: 23 Nov 2005, 06:16

Re: Newbie problem

Post by Das Bruce »

Nothing to suggest any problems.

Code: Select all

[      0] Creating sky
[      0] Loading LuaRules
[      0] Loading LuaGaia
[      0] Loading LuaUI
[      0] Using LUAUI_DIRNAME = LuaUI/
[      0] Reloaded ctrlpanel with: LuaUI/ctrlpanel.txt
[      0] LuaUI: bound F11 to the widget selector
[      0] LuaUI: bound CTRL+F11 to tweak mode
[      0] Hello Spring
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Newbie problem

Post by Argh »

Are you loading the GadgetHandler?

I.E. ... are these files present?

Not sure why these aren't loaded by default nowadays, but I think they're still required.
Attachments
draw.lua
(53 Bytes) Downloaded 23 times
main.lua
(100 Bytes) Downloaded 13 times
User avatar
Das Bruce
Posts: 3544
Joined: 23 Nov 2005, 06:16

Re: Newbie problem

Post by Das Bruce »

Fucking bingo.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Newbie problem

Post by Argh »

Cool.
Post Reply

Return to “Lua Scripts”