Torrent Posted May 24, 2015 Share Posted May 24, 2015 Hey everyone. I'm just messing around with modding PZ and getting to grips with everything. I made a small script that retrieves the player's name and prints it to the console. Annoyingly, it always prints out "Bob" instead of my character's name. Does anyone know why? My code is as follows: function TestMod.keyPress(_keyPressed)if _keyPressed == 25 then local player = getSpecificPlayer(0); local name = player:getForname(); print("Player name: " .. name); player:Say(name);endend I've attached the console message with the player name, along with my character's actual name. I am playing single player sandbox. Any help would be greatly appreciated, as I'm thoroughly confused! Link to comment Share on other sites More sharing options...
EnigmaGrey Posted May 24, 2015 Share Posted May 24, 2015 Well, let's see what ctrl + f says: if instanceof(o, "IsoPlayer") then self.objectView:addItem("Player: ".. o:getDescriptor():getForename() .. " ".. o:getDescriptor():getSurname(), o); endSo, it looks like you have to get the descriptor from IsoPlayer, then get the name from that. Torrent 1 Link to comment Share on other sites More sharing options...
Torrent Posted May 24, 2015 Author Share Posted May 24, 2015 Well, let's see what ctrl + f says: if instanceof(o, "IsoPlayer") then self.objectView:addItem("Player: ".. o:getDescriptor():getForename() .. " ".. o:getDescriptor():getSurname(), o); endSo, it looks like you have to get the descriptor from IsoPlayer, then get the name from that. Thank you for your reply! It worked perfectly. Slightly confusing as the documentation for the descriptor has a getForename() method, whilst the IsoPlayer has a getForname method. The spelling difference caused a few null errors when calling the wrong method by accident. Link to comment Share on other sites More sharing options...
EnigmaGrey Posted May 24, 2015 Share Posted May 24, 2015 Probably just a hold-over from the early days, when men were Bobs and women didn't exist. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now