Jump to content

ThePlayer vs GetPlayer()


Recommended Posts

What is the difference between ThePlayer and GetPlayer() ? The first is a constant and the second a function, but do they return the same?

If I have on a server_only mod an "inst", which has inst:HasTag("player"), how to get the Player from this char? I want to display an Icon in his, and only his HUD.

Is there really no documentation?! This game is several years old, at least the singleplayer version. And the devs seems to be quite good and allowing mods. So I definitely don't understand, why there is no documentation from the devs =/

 

edit:

And how can I test my mod if I'm not able to login with two laptops with the same account ?! I can't call a friedn everytime I want to test if something works -.- (I tried both in offline mod, but the game still detects, that this account is already logged in...)

Edited by Serpens
Link to comment
Share on other sites

ThePlayer is global constant that is defined after player is initialized - aka after AddPlayerPostInit is fired. GetPlayer() is the function that was used in DS to get player, it is depricated in DST, but is still supported. Usually people redefine GetPlayer in their cross DS-DST mods. You can learn more reading the first sticky thread on this forum.

You can use pairs iterator on any variable (e.g. inst) to get list of props it has. Usually player is addressed as inst.owner, can't look into the code right now to check that one out.

In your case I'm pretty sure that if inst has tag player, then it is actually player.

 

As for how to learn modding, you gotta look in the game source code and in code of simillar modes. Once you figure out how prefabs, components, widgets and post inits work it'll be a lot easier.

Edited by IvanX
Link to comment
Share on other sites

so if it is inst.owner, instead of

GLOBAL.ThePlayer.HUD.controls.HomeBase_baseicon:Show()

I can use

inst.owner.HUD.controls.HomeBase_baseicon:Show()

to show an icon for a specific player? And that would mean I can use a server_only mod, right?

 

Are you able to tell me the interesting parts of the first sticky thread? Because of course this was the first thing I glanced through when I came here. But as far as I see, there is nothing like a documentation. Just lua stuff and "look at game code to find things out". And of course porting from DS to DST, but I don't know DS :D

 

edit:
hm.. inst.owner is nil.
 

Edited by Serpens
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...