Page 1 of 2

Get values of other pawns through simkin command?

Posted: Thu Jul 31, 2008 2:00 pm
by Jay
I wondered... is there any way to get and set the values of other pawns by a built-in-skimkin command?

I mean we can already do:

Pawn1.Value="ABC";

What i want to do is:

SetValue("Pawn1","Value","ABC");

This would allow alot more flexibility in my scripts. I am planning to do a 'chatchannel feature' where pawns 'chat' and can ask others for help, like shout for healing, or the healers would ask others to attack the ones that are attacking them. Bosses can boss other minor monsters around and they can coordinate their attacks.
I need this because there are various chatchannels, like the channels 'boss', 'group', 'global', 'monster type' and of each channel the leader of the group holds the channel (and if the leader dies, sometimes the monsters are disoriented or their moral decreases and they flee :D ). So a pawn must know who th boss is, and as this can change from pawn to pawn, and because of this i need this feature.

Re: Get values of other pawns through simkin command?

Posted: Thu Jul 31, 2008 2:09 pm
by Graywolf
I think this should give you what you need.

Code: Select all

CHAT_PAWN [Pawn1]

DoChatThingy[()
{

	@CHAT_PAWN.Value = "ABC";

}]
The "@" is Simkin's indirection operator. It let's you use a variable like a pointer. "@CHAT_PAWN" is interpreted literally as "Pawn1.Value".

Re: Get values of other pawns through simkin command?

Posted: Thu Jul 31, 2008 2:20 pm
by Jay
Woooooow :shock: :shock: :shock:

i didn't know simkin was capable of indirection!!!!

This is just wow.


Thank you so much :D

Re: Get values of other pawns through simkin command?

Posted: Thu Jul 31, 2008 2:24 pm
by Juutis
Whoa, I think I should start reading the simkin docs. :shock:

I had no idea you could do something like that.

Re: Get values of other pawns through simkin command?

Posted: Thu Jul 31, 2008 2:27 pm
by Graywolf
Hey, I was happy to help. That little "gem" is hidden under the obscure topic of "Scope" in the docs.

Re: Get values of other pawns through simkin command?

Posted: Thu Jul 31, 2008 2:39 pm
by Graywolf
This can be combined with the built-in field "label" to great effect, such as:

Code: Select all


SetChatPawn[(thePawn)
{
	CHAT_PAWN = thePawn.label;
}]

Re: Get values of other pawns through simkin command?

Posted: Thu Jul 31, 2008 2:44 pm
by Jay
And what does this label do? I don't know what you are trying to say....

Re: Get values of other pawns through simkin command?

Posted: Thu Jul 31, 2008 2:52 pm
by Graywolf
Okay... Sorry, that was a little sparse. And, I just double-checked, the label isn't set properly for pawns...

The label gives you the name of the object in Simkin. In other words, the word you need for "@", in case you don't have it(like passing an object as a parameter... Or, when the object isn't a pawn(so, so self.entity_name field.))

It's basically the compliment to "@".

Re: Get values of other pawns through simkin command?

Posted: Fri Aug 01, 2008 12:53 pm
by Jay
I have more questions about that '@'

First, is it possible to point it towards an array and do something like that: (This would be a pointer to a struct :wink: )

Code: Select all

ITEM [NULL]

ITEM_SWORD
{
   0 [Sword]
   1 [4]
   2 [10]
}

ITEM_DAGGER
{
   0 [Dagger]
   1 [2]
   2 [4]
}

SomeFunction[ ()
{
   ITEM="ITEM_SWORD";
   ProcessItem();
   ITEM="ITEM_DAGGER";
   ProcessItem();
} ]

ProcessItem[ ()
{
   debug(@ITEM[0]);
   debug(@ITEM[1]);
   debug(@ITEM[2]);
} ]

Second, i want to know if i can do that: (Yes, it's the function pointer :D )

Code: Select all


FUNCTION [NULL]

FunctionA[ ()
{
   debug("FUNCTION A");
} ]
FunctionB[ ()
{
   debug("FUNCTION B");
} ]

DoThing[ ()
{
   FUNCTION="FunctionA";
   @FUNCTION();
   FUNCTION="FunctionB";
   @FUNCTION();
} ]
are those possible?

Re: Get values of other pawns through simkin command?

Posted: Fri Aug 01, 2008 6:33 pm
by Graywolf
Yes, both are possible. I think the only real limitation is that it's a single level of inderection(can't use ITEM="Items.Weapons" successfully, sadly... In other words, no pointer-to-member. :shock: )

Also...

Code: Select all

ProcessItem[ (ITEM)
{
	for each IT in @ITEM
	{
		debug(IT.label#" = "#IT);
	}
} ]

SomeFunction[ ()
{
   ProcessItem("ITEM_SWORD");
   ProcessItem("ITEM_DAGGER");
} ]

Those "for each in" commands are very convenient.

P.S. - About your timer framework... Using these mechanisms, you could really soup it up. "for each" through the timer list, and use indirection to call a function when the timer triggers.

Re: Get values of other pawns through simkin command?

Posted: Fri Aug 01, 2008 7:44 pm
by Kiji8989
Thats a wonderful idea about the pawn teams. Can you do this for...If a pawn could fight for you?

Re: Get values of other pawns through simkin command?

Posted: Sat Aug 02, 2008 10:00 am
by Jay
Yes, and that's what i am planning to do too. In the game i am working on at the moment, the player can revive dead enemies, and then they will fight for you. You can also have allies and such.

I don't want to much to 'leak out' before i am finished, but i can tell you... The KI in this game will be really cool... There are more thinghs about it that i haven't told yet :twisted:

@topic: I think this topic is really usefull for more advanced scripters. It would be good to make a topic where all interesting/cool thinghs about simkin are summarised, like a Simkin-FAQ.

Re: Get values of other pawns through simkin command?

Posted: Sat Aug 02, 2008 11:18 am
by Juutis
Graywolf wrote:Those "for each in" commands are very convenient.
Could you explain a little what this command does and how to use it? I read about it in the Simkin docs but couldn't quite understand it. The example they have doesn't really help... :?

Re: Get values of other pawns through simkin command?

Posted: Sat Aug 02, 2008 11:24 am
by Danimita92
Sorry for my ignorance, but where are these docs? The only one I found is this one, that says something about Java:
http://www.simkin.co.uk/Docs/java/

Re: Get values of other pawns through simkin command?

Posted: Sat Aug 02, 2008 11:31 am
by Juutis
http://www.simkin.co.uk/Docs/cpp/index.html
Check 'Simkin Script Syntax'. There's some pretty useful info there.

Note: we are using the TreeNode format, so ignore the XML stuff.