Page 1 of 1
Easier way to use global functions?
Posted: Fri Oct 17, 2014 9:42 pm
by lowena
I am making a dungeon that includes the following script:
Code: Select all
function giveskill()
for i=1, 4, 1 do
cclass = party.party:getChampion(i):getClass()
if (cclass == "wizard") then
party.party:getChampion(i):addSkillPoints(25)
end
end
end
Is there an easier way to do the line "party.party:getChampion(i):addSkillPoints(25)" ? Preferably I'd rather not have to do party.party:getChampion() every time. I think I could make a variable and add that part to it, but I'd rather use a way that would do something like keep the current Champion in focus, i.e.:
Code: Select all
party.party:getChampion(1)
addSkillPoints(20)
Or something like that.

Re: Easier way to use global functions?
Posted: Sat Oct 18, 2014 6:50 am
by SnowyOwl47
lowena wrote:I am making a dungeon that includes the following script:
Code: Select all
function giveskill()
for i=1, 4, 1 do
cclass = party.party:getChampion(i):getClass()
if (cclass == "wizard") then
party.party:getChampion(i):addSkillPoints(25)
end
end
end
Is there an easier way to do the line "party.party:getChampion(i):addSkillPoints(25)" ? Preferably I'd rather not have to do party.party:getChampion() every time. I think I could make a variable and add that part to it, but I'd rather use a way that would do something like keep the current Champion in focus, i.e.:
Code: Select all
party.party:getChampion(1)
addSkillPoints(20)
Or something like that.

One easy way i'd think to do this is make an Script_Entity and keep it as embedded, and just call it partyDo and add a simple function such as
Code: Select all
function party()
return function()
party.party()
end
end
Now Since I'm still new to lua that might work and it might not you may have to do this
Make a Script_Entity and keep it as embedded and call it partChamp or something
and and do the following
Code: Select all
function champ(i)
return function()
party.party:getChapion(i)()
end
end
That might work but have fun trying them out

Re: Easier way to use global functions?
Posted: Sat Oct 18, 2014 8:09 am
by lowena
Well, that might work, but I think that's even clunkier than typing the full line each time.

I was hoping for something like "using namespace std;" in C++ or whatever, but it's not that big of a deal.
Re: Easier way to use global functions?
Posted: Sat Oct 18, 2014 8:18 am
by SnowyOwl47
lowena wrote:Well, that might work, but I think that's even clunkier than typing the full line each time.

I was hoping for something like "using namespace std;" in C++ or whatever, but it's not that big of a deal.
Lol well the reason why I told you that was because you can add your own things to do even more complicated things so you can turn spawning entities into simpler things or other stuff the examples i gave I know arnt, really gonna help you much
