hudPrints from specific party members

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
User avatar
FeMaiden
Posts: 290
Joined: Wed Jan 16, 2013 8:16 am

hudPrints from specific party members

Post by FeMaiden »

okay, i'm sure this question has already been answered somewhere and it's probably really simplistic but I can't find the answer
I tried searching the forums already.


how do I make the game call up a champion's name and then display it next to text in a hudPrint

I know how to do a hudPrint and put a message and i was just doing something like hudPrint ("party: I have a bad feeling about this")

but what if I wanted to have the game pull the name of the champion in the first slot so that it a text pops up saying something
and then another message pops up with another party member's name like they are having a conversation

so it looks like this

Femaiden : I have a bad feeling about this
Jenni : you always say that
Femaiden : that's because i'm always right
(that's just a made up example, I probably won't use those exact words lol)

but then if someone else is playing and they name their champions like Bob and Susan or something then it will substitute those names instead.


I know it has to do with the getChampion and getName commands but I keep getting crashes because i'm not using proper syntax maybe? I dunno.

I pulled this from another post and tried it

hudPrint(party.party:getChampion(1):getName()"hello")

and i have an error message says "attempt to call a string value X"
User avatar
THOM
Posts: 1281
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: hudPrints from specific party members

Post by THOM »

You were close...

Code: Select all

hudPrint(" "..party.party:getChampion(1):getName().." important message")
But therfore a champion could be not alive I prefer this:
if party.party:getChampion(1):isAlive() then
hudPrint(" "..party.party:getChampion(1):getName().." important message")
else
hudPrint("important message")
end
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
User avatar
FeMaiden
Posts: 290
Joined: Wed Jan 16, 2013 8:16 am

Re: hudPrints from specific party members

Post by FeMaiden »

THOM wrote:You were close...

Code: Select all

hudPrint(" "..party.party:getChampion(1):getName().." important message")
But therfore a champion could be not alive I prefer this:
if party.party:getChampion(1):isAlive() then
hudPrint(" "..party.party:getChampion(1):getName().." important message")
else
hudPrint("important message")
end
so you have to put those double periods before party and after getName? I kind of thought those were just the person overusing ellipses...
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: hudPrints from specific party members

Post by minmay »

.. is the operator to concatenate strings in Lua.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Post Reply