Get values of other pawns through simkin command?

Topics regarding Scripting with Reality Factory
Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Get values of other pawns through simkin command?

Post by Jay » Thu Jul 31, 2008 2:00 pm

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.
Everyone can see the difficult, but only the wise can see the simple.
-----

User avatar
Graywolf
Posts: 75
Joined: Mon Apr 14, 2008 8:36 pm
Location: Anchorage, Alaska
Contact:

Re: Get values of other pawns through simkin command?

Post by Graywolf » Thu Jul 31, 2008 2:09 pm

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".
"So, what's the life of a programmer like?" "...Huh? What life?!"

RF System X:
http://www.realityfactory.info/forum/vi ... f=9&t=3599

Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Re: Get values of other pawns through simkin command?

Post by Jay » Thu Jul 31, 2008 2:20 pm

Woooooow :shock: :shock: :shock:

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

This is just wow.


Thank you so much :D
Everyone can see the difficult, but only the wise can see the simple.
-----

User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: Get values of other pawns through simkin command?

Post by Juutis » Thu Jul 31, 2008 2:24 pm

Whoa, I think I should start reading the simkin docs. :shock:

I had no idea you could do something like that.
Pain is only psychological.

User avatar
Graywolf
Posts: 75
Joined: Mon Apr 14, 2008 8:36 pm
Location: Anchorage, Alaska
Contact:

Re: Get values of other pawns through simkin command?

Post by Graywolf » Thu Jul 31, 2008 2:27 pm

Hey, I was happy to help. That little "gem" is hidden under the obscure topic of "Scope" in the docs.
"So, what's the life of a programmer like?" "...Huh? What life?!"

RF System X:
http://www.realityfactory.info/forum/vi ... f=9&t=3599

User avatar
Graywolf
Posts: 75
Joined: Mon Apr 14, 2008 8:36 pm
Location: Anchorage, Alaska
Contact:

Re: Get values of other pawns through simkin command?

Post by Graywolf » Thu Jul 31, 2008 2:39 pm

This can be combined with the built-in field "label" to great effect, such as:

Code: Select all


SetChatPawn[(thePawn)
{
	CHAT_PAWN = thePawn.label;
}]
"So, what's the life of a programmer like?" "...Huh? What life?!"

RF System X:
http://www.realityfactory.info/forum/vi ... f=9&t=3599

Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Re: Get values of other pawns through simkin command?

Post by Jay » Thu Jul 31, 2008 2:44 pm

And what does this label do? I don't know what you are trying to say....
Everyone can see the difficult, but only the wise can see the simple.
-----

User avatar
Graywolf
Posts: 75
Joined: Mon Apr 14, 2008 8:36 pm
Location: Anchorage, Alaska
Contact:

Re: Get values of other pawns through simkin command?

Post by Graywolf » Thu Jul 31, 2008 2:52 pm

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 "@".
"So, what's the life of a programmer like?" "...Huh? What life?!"

RF System X:
http://www.realityfactory.info/forum/vi ... f=9&t=3599

Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Re: Get values of other pawns through simkin command?

Post by Jay » Fri Aug 01, 2008 12:53 pm

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?
Everyone can see the difficult, but only the wise can see the simple.
-----

User avatar
Graywolf
Posts: 75
Joined: Mon Apr 14, 2008 8:36 pm
Location: Anchorage, Alaska
Contact:

Re: Get values of other pawns through simkin command?

Post by Graywolf » Fri Aug 01, 2008 6:33 pm

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.
Last edited by Graywolf on Fri Aug 01, 2008 8:01 pm, edited 1 time in total.
"So, what's the life of a programmer like?" "...Huh? What life?!"

RF System X:
http://www.realityfactory.info/forum/vi ... f=9&t=3599

User avatar
Kiji8989
Posts: 209
Joined: Tue Jul 22, 2008 11:39 pm

Re: Get values of other pawns through simkin command?

Post by Kiji8989 » Fri Aug 01, 2008 7:44 pm

Thats a wonderful idea about the pawn teams. Can you do this for...If a pawn could fight for you?
(\_/)
(O.o) copy bunny into your signature to
( >< )help him achieve world domination

Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Re: Get values of other pawns through simkin command?

Post by Jay » Sat Aug 02, 2008 10:00 am

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.
Everyone can see the difficult, but only the wise can see the simple.
-----

User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: Get values of other pawns through simkin command?

Post by Juutis » Sat Aug 02, 2008 11:18 am

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... :?
Pain is only psychological.

Danimita92
Posts: 335
Joined: Sat Feb 09, 2008 5:47 pm
Location: Lanzarote/Canary Islands/Spain

Re: Get values of other pawns through simkin command?

Post by Danimita92 » Sat Aug 02, 2008 11:24 am

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/

User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: Get values of other pawns through simkin command?

Post by Juutis » Sat Aug 02, 2008 11:31 am

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.
Pain is only psychological.

Post Reply