Level comparing script

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
LocalFire
Posts: 261
Joined: Thu Feb 21, 2013 1:16 am
Location: Auckland, New Zealand

Level comparing script

Post by LocalFire »

So I want to compare the levels of two characters and grant exp to the one with the lower level until they are the same.

I've tried to do it like this, with the character with ordinal 1 (the starting character) having the lvl of a second character checked when they join the party.

I want to get it so it loops granting exp until they are the same lvl

Code: Select all

if champion:getOrdinal(1):getLevel()==champion:getOrdinal(2):getLevel() then
hudPrint("same Level")

else

champion:getOrdinal(2)
:gainExp(1000)
return

end
end
Thanks for any help in advance
My Dungeons
Paths of the Earth: viewtopic.php?f=14&t=5136
Beneath the Sands: viewtopic.php?f=14&t=5216
Videos: viewtopic.php?f=11&t=5443
User avatar
Leki
Posts: 550
Joined: Wed Sep 12, 2012 3:49 pm

Re: Level comparing script

Post by Leki »

It's easy script and the only way to learn how to do is just to try harder by yourself to find solution :twisted:
Hint: Don't use gainExp, but use Champion:levelUp() until they are the same level.
Champion Scripting reference: http://www.grimrock.net/modding/scripting-reference/
I'm the Gate I'm the Key.
Dawn of Lore
User avatar
LocalFire
Posts: 261
Joined: Thu Feb 21, 2013 1:16 am
Location: Auckland, New Zealand

Re: Level comparing script

Post by LocalFire »

Thanks for the hint heres an update on how this is going

so I have a SE called OrdinalScript with this function

Code: Select all

function getChampionWithOrdinal(ordinal)
  for i=1,4 do
    if ( party:getChampion(i):getOrdinal() == ordinal ) 
 then     return party:getChampion(i);
    end
  end

  return nil;
end
which is called by this function:

Code: Select all

function LvlComp()

if  OrdinalScript.getChampionWithOrdinal(1):getLevel()== OrdinalScript.getChampionWithOrdinal(2):getLevel() then
hudPrint("same Level")

else

OrdinalScript.getChampionWithOrdinal(2)
:levelUp()
return

end
end
so that works! but it only works in as much as one level up, if the first character is lvl 3 or higher it won't keep leveling them up, I thought the return bit would loop the script back until it got the same level or that something else?
My Dungeons
Paths of the Earth: viewtopic.php?f=14&t=5136
Beneath the Sands: viewtopic.php?f=14&t=5216
Videos: viewtopic.php?f=11&t=5443
User avatar
Leki
Posts: 550
Joined: Wed Sep 12, 2012 3:49 pm

Re: Level comparing script

Post by Leki »

Hint No.2 (key word "until" as you wrote in first post): http://lua.gts-stolberg.de/en/schleifen.php :twisted:
I'm the Gate I'm the Key.
Dawn of Lore
User avatar
LocalFire
Posts: 261
Joined: Thu Feb 21, 2013 1:16 am
Location: Auckland, New Zealand

Re: Level comparing script

Post by LocalFire »

Awesome it now works perfectly

Code: Select all

function LvlComp()


repeat

OrdinalScript.getChampionWithOrdinal(2)
:levelUp()

until  OrdinalScript.getChampionWithOrdinal(1):getLevel()== OrdinalScript.getChampionWithOrdinal(2):getLevel() 


end 
thanks for the hints :)
My Dungeons
Paths of the Earth: viewtopic.php?f=14&t=5136
Beneath the Sands: viewtopic.php?f=14&t=5216
Videos: viewtopic.php?f=11&t=5443
Post Reply