Wiki Requests

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Wiki Requests

Post by T-Bone »

Perhaps a tutorial on proper usage of multiple .lua files would be nice. All my knowledge comes from trial and error, and asking people on the forums here, and every once in a while I notice large gaps in my knowledge :neko:
User avatar
XQYZ
Prole
Posts: 20
Joined: Sat Jul 30, 2011 4:23 pm
Location: Europe
Contact:

Re: Wiki Requests

Post by XQYZ »

T-Bone wrote:Perhaps a tutorial on proper usage of multiple .lua files would be nice. All my knowledge comes from trial and error, and asking people on the forums here, and every once in a while I notice large gaps in my knowledge :neko:
It's basically do whatever you want, all there is is convention and personal preference. Lua itself doesn't care where you define your functions or your classes.
User avatar
zohnny
Prole
Posts: 7
Joined: Mon Jul 25, 2011 9:53 pm

Re: Wiki Requests

Post by zohnny »

I think a good system for both newbies and experienced users would be a sort of request system.

Users who think they are 100% proficient in a subject can put their name in one of the sections. When users hit a "request example" button, the experienced user will get an email or something saying that so-and-so has requested an example for this section. If nobody has applied for one section, if something is requested then all experienced users will get the email.

With this system, newbies can get the examples they need, and experienced members don't have to make an example for every section right off the bat.

Just an idea ;D
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Wiki Requests

Post by tentus »

Request: joystick examples.

Here is the joystick class from my game Kurosuke:

Code: Select all

joystick = class:new() 

function joystick:init()
	self.pressed = {}
	self.password = 1
end

function joystick:update(dt)
	self.password = (self.password % 2) + 1		-- change the password each update, for use in cleaning
	for j=0, love.joystick.getNumJoysticks() do
		for h=0, love.joystick.getNumHats(j) do
			local direction = love.joystick.getHat(j, h)
			if direction ~= "" and direction ~= "c" then
				local key = "j"..j.."_h"..h.."_d"..direction
				self:check(key)
			end
		end
		for a=0, love.joystick.getNumAxes(j) do
			local direction = love.joystick.getAxis(j, a)
			if direction > .5 or direction < -.5 then
				direction = round(direction)	-- to keep it even between sticks and buttons
				local key = "j"..j.."_a"..a.."_d"..direction
				self:check(key)
			end
		end
	end
	for key, value in pairs(self.pressed) do		-- clean out hats that aren't being pressed any more
		if self.pressed[key] ~= self.password then
			self.pressed[key] = nil
		end
	end
end

function joystick:check(key)
	if self.pressed[key] == nil then
		scene:keypressed(key)
	end
	self.pressed[key] = self.password
end
It pains me to post such inelegant code. Does anyone have some good code that they could put up as examples on the wiki?
Kurosuke needs beta testers
User avatar
XQYZ
Prole
Posts: 20
Joined: Sat Jul 30, 2011 4:23 pm
Location: Europe
Contact:

Re: Wiki Requests

Post by XQYZ »

tentus wrote:It pains me to post such inelegant code. Does anyone have some good code that they could put up as examples on the wiki?
Imho if you want to handle Input correctly, then you should keep it more abstract, ie. handle keyboard, mouse and gamepad input in one separate class which can be accessed independently from you main loop/input function. Something like if InputManager:isActionButtonPressed() then and so on.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Wiki Requests

Post by tentus »

XQYZ wrote:
tentus wrote:It pains me to post such inelegant code. Does anyone have some good code that they could put up as examples on the wiki?
Imho if you want to handle Input correctly, then you should keep it more abstract, ie. handle keyboard, mouse and gamepad input in one separate class which can be accessed independently from you main loop/input function. Something like if InputManager:isActionButtonPressed() then and so on.
Input is handled based on which scene (gamestate) you're in. For example, the character select screen has a very different set of bindings than the main game, which is very different from the nogame screen. Within the scenes some of the input is passed on to specific objects based on relevance (for example, if a key or joystick is bound to a player control, the input is passed onto that player object).
Kurosuke needs beta testers
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Wiki Requests

Post by tentus »

Question: What is the proper way to note that a function is getting renamed? I'm thinking specifically about threads, since send will become set and receive will become get in 0.8.0.
Kurosuke needs beta testers
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Wiki Requests

Post by bartbes »

Using the oldin template in the old one and the newin in the new one.
Another option might be moving the page to the new one, leaving a link in place then list both (with oldin and newin).
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Wiki Requests

Post by tentus »

Hello, thread necromancy, how have you been?

Since I noticed that love.update had no examples, I've been going through some of the more commonly used functions on the wiki and adding more practical examples (not just the function being called, but it being called in a quasi-useful way). I've also been adding more See Also links, such as love.mouse.isVisible‎ to love.mouse.setVisible‎.

My point is, if anyone wants to pitch in, please do. My example-writing skills are pretty poor, and there are plenty of functions I've never even used (love.thread, I'm not looking at you). Having some more experienced Lovers than me working on the wiki would be a good thing.
Kurosuke needs beta testers
Post Reply

Who is online

Users browsing this forum: aikusuuta, Bing [Bot], Google [Bot] and 8 guests