Some noob questions

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
NoAim91
Prole
Posts: 38
Joined: Mon Feb 20, 2017 10:28 am
Location: Germany

Some noob questions

Post by NoAim91 »

Hello, I try since several hours and i don´t get it, so i´m sorry for this simple questions but i can´t figure out how to do it.

1.) I have a function with some if statements, and at the last if statement i like to set a global variable from true to false. I know how to change is in the local, but how do i get the scope to global? (i have tryed return, but it doesn´t work)

2.) How to call a function? Sounds stupid, i know .. but at the end of the if statement it should say to a function "do your thing" without give any value input.
Zireael
Party member
Posts: 139
Joined: Fri Sep 02, 2016 10:52 am

Re: Some noob questions

Post by Zireael »

1) the same way you set a local variable, just without the local keyword
2) DoYourThing() (capitalization is entirely optional) - however you need to have the DoYourThing() function defined beforehand
NoAim91
Prole
Posts: 38
Joined: Mon Feb 20, 2017 10:28 am
Location: Germany

Re: Some noob questions

Post by NoAim91 »

thanks for the reply ... like every time my problem was something other. But I solved it.

But I have a new Question :-)

What GUI should i use? Should i write my own at the very beginning?

edit: is there any good GUI Tutorial für lua (and probebly löve?)
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Some noob questions

Post by Positive07 »

I recommend SUIT or Gööi, or if you dare, binary ones like imgui or nuklear
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
NoAim91
Prole
Posts: 38
Joined: Mon Feb 20, 2017 10:28 am
Location: Germany

Re: Some noob questions

Post by NoAim91 »

Thank you SUIT looks fine :-)

another question ... when/why I use " : " in lua?
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Some noob questions

Post by zorg »

You can use it wherever you want (it's just syntactic sugar); more importantly, here's the shortest way (for me) to show how it differs from dot notation:

Code: Select all

local t = {}
function t.f(a,b) return self,a,b end
function t:g(a,b) return self,a,b end
t.f(1,2) --> nil, 1, 2
t:f(1,2) --> nil, t, 1
t.g(1,2) --> 1, 2, nil
t:g(1,2) --> t, 1, 2
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Some noob questions

Post by Positive07 »

This

Code: Select all

local t = {}

function t.func (self, a, b, ...)
   print(self) --Prints t
   --Code
end

Is equivalent to this

Code: Select all

local t = {}

function t:func (a, b, ...)
   print(self) --Prints t
   --Code
end

And this

Code: Select all

t.func(t, 1, 2, 3)
Is equivalent to this

Code: Select all

t:func(1, 2, 3)
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 31 guests