TLOs and accessing character health

Discussion of Inner Space

Moderators: Lavish Software Team, Moderators

Post Reply
Evilfairy
GamingTools Subscriber
Posts: 7
Joined: Sat Jun 22, 2013 9:24 am

TLOs and accessing character health

Post by Evilfairy » Thu Jul 04, 2013 6:35 am

First of all I know the title is probably wrong but I have no idea what to name this thread

I'm looking for some help with accessing data produced by my extension (built with ISXDK) via LavishScript. I was reading through the wiki and I've noticed 2 things

1. There are a few pages in the wiki that are just... blank. The only other documentation I could find were the extensive comments in the source code produced by mkisx, is that what I should be relying on? Is the wiki going to be updated? Do I already have the information I need to update the wiki myself?
2. On the page regarding TLOs, it stated that
For example, you do not want to have a Top-Level Object that specifically retrieves your character's health in a game -- that should be a part of a character object, and referenced by something like "Me" (short and sweet, and easy to understand).
Which is understandable enough, but how would I go about accessing my health? Do I need to create my own "Player" data type? I fully understand the concept of classes in C++ and C#, but is a TLO similar to that or should I be using something completely different?

Let's say for example in C++ I had

Code: Select all

class Player
{
private:
    uint32 _health;
public:
    std::string _name;

    uint32 GetHealth()
    {
        _health = UpdateHealthFromElsewhereInProgram();
        return _health;
    }

    Player(uint32 health) { _health = health; _name = GetNameFromElsewhere(); }
};
ignoring the fact that there'd be a bunch of other functions, how would I go about creating that in such a way that I can access it all from LavishScript?

By all means, if the information I need is already on the wiki and I've just missed it somehow feel free to tell me to just go read it. I'm not an expert on C++ but I know my way around, I just don't understand what I should be doing to access this. I know I could probably do it by iterating the va_list passed to me when calling the TLO but that feels... wrong. I don't know if I need to make my own datatype or not but I'm assuming if at any point I want to handle Player objects externally I'll need to create a datatype for that.

Thanks for your time and again, I've already spent a long time reading through both the wiki and the source code comments, but if you're 100% certain all the information I need is there then I don't mind going back and reading some more. I just feel pretty stuck at a conceptual level right now, it feels like even though I have a solution it's not what I should be doing :(

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Thu Jul 04, 2013 9:02 am

1. There are a few pages in the wiki that are just... blank. The only other documentation I could find were the extensive comments in the source code produced by mkisx, is that what I should be relying on? Is the wiki going to be updated? Do I already have the information I need to update the wiki myself?
Red links in the wiki are missing pages, which is why they would be blank.

The ISXDK wiki is unlikely to be updated soon as IS2 and the IS2 development kit are works in progress and much better to work with.

I don't know what specific information or missing pages you're thinking of, in order to answer this. The comments in the source should be enough to go on, where provided.
Which is understandable enough, but how would I go about accessing my health? Do I need to create my own "Player" data type? I fully understand the concept of classes in C++ and C#, but is a TLO similar to that or should I be using something completely different?
A TLO is not similar to a class, no. A TLO is a way to grab an instance of an object. A LavishScript data type is similar to a class.

The template from ISXDK produces an example that defines a TLO and a data type. Create a TLO that accesses a specific instance of a data type (e.g. your player object) and a Data Type that accesses members (e.g. health) and methods of that type, given a way to identify the particular object (e.g. a pointer to it, or an index number, etc).

${Me.Health} would first grab the "Me" TLO, and access the Health member from the returned object.

Parameters to the TLO are used to differentiate between the possible objects you might return. e.g. ${Player[1]} might be different than ${Player[2]}.

There's nothing that says you MUST use this paradigm, you can also just make a TLO and have the parameters to it return different values, like your health. You could set up ${Me[health]} to return your health. It would just be weird. ;)

Evilfairy
GamingTools Subscriber
Posts: 7
Joined: Sat Jun 22, 2013 9:24 am

Post by Evilfairy » Thu Jul 04, 2013 3:25 pm

Lax wrote:
1. There are a few pages in the wiki that are just... blank. The only other documentation I could find were the extensive comments in the source code produced by mkisx, is that what I should be relying on? Is the wiki going to be updated? Do I already have the information I need to update the wiki myself?
Red links in the wiki are missing pages, which is why they would be blank.

The ISXDK wiki is unlikely to be updated soon as IS2 and the IS2 development kit are works in progress and much better to work with.

I don't know what specific information or missing pages you're thinking of, in order to answer this. The comments in the source should be enough to go on, where provided.
Which is understandable enough, but how would I go about accessing my health? Do I need to create my own "Player" data type? I fully understand the concept of classes in C++ and C#, but is a TLO similar to that or should I be using something completely different?
A TLO is not similar to a class, no. A TLO is a way to grab an instance of an object. A LavishScript data type is similar to a class.

The template from ISXDK produces an example that defines a TLO and a data type. Create a TLO that accesses a specific instance of a data type (e.g. your player object) and a Data Type that accesses members (e.g. health) and methods of that type, given a way to identify the particular object (e.g. a pointer to it, or an index number, etc).

${Me.Health} would first grab the "Me" TLO, and access the Health member from the returned object.

Parameters to the TLO are used to differentiate between the possible objects you might return. e.g. ${Player[1]} might be different than ${Player[2]}.

There's nothing that says you MUST use this paradigm, you can also just make a TLO and have the parameters to it return different values, like your health. You could set up ${Me[health]} to return your health. It would just be weird. ;)
Thanks for replying, I think I understand what to do now (: I'll play around and ask if I have any more questions

I've used wikis before and I understand what red links mean, I was referring to pages like http://www.lavishsoft.com/wiki/index.ph ... Data_Types which just have nothing on them

My biggest confusion came from
A TLO is not similar to a class, no. A TLO is a way to grab an instance of an object. A LavishScript data type is similar to a class.
I understand the difference now and should be able to figure out what to do from here

I know that most paradigms aren't strictly enforced, but after seeing several pieces of code like this beauty (http://paste2.org/t2thWU4B) from other people, I've come to realise that it's worth just taking the time to figure out how other people expect you to do things and making your own decisions from there

Post Reply