Get values of other pawns through simkin command?
Get values of other pawns through simkin command?
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 ). 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.
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 ). 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.
-----
-----
Re: Get values of other pawns through simkin command?
I think this should give you what you need.
The "@" is Simkin's indirection operator. It let's you use a variable like a pointer. "@CHAT_PAWN" is interpreted literally as "Pawn1.Value".
Code: Select all
CHAT_PAWN [Pawn1]
DoChatThingy[()
{
@CHAT_PAWN.Value = "ABC";
}]
"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
RF System X:
http://www.realityfactory.info/forum/vi ... f=9&t=3599
Re: Get values of other pawns through simkin command?
Woooooow
i didn't know simkin was capable of indirection!!!!
This is just wow.
Thank you so much
i didn't know simkin was capable of indirection!!!!
This is just wow.
Thank you so much
Everyone can see the difficult, but only the wise can see the simple.
-----
-----
Re: Get values of other pawns through simkin command?
Whoa, I think I should start reading the simkin docs.
I had no idea you could do something like that.
I had no idea you could do something like that.
Pain is only psychological.
Re: Get values of other pawns through simkin command?
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
RF System X:
http://www.realityfactory.info/forum/vi ... f=9&t=3599
Re: Get values of other pawns through simkin command?
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
RF System X:
http://www.realityfactory.info/forum/vi ... f=9&t=3599
Re: Get values of other pawns through simkin command?
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.
-----
-----
Re: Get values of other pawns through simkin command?
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 "@".
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
RF System X:
http://www.realityfactory.info/forum/vi ... f=9&t=3599
Re: Get values of other pawns through simkin command?
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 )
Second, i want to know if i can do that: (Yes, it's the function pointer )
are those possible?
First, is it possible to point it towards an array and do something like that: (This would be a pointer to a struct )
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]);
} ]
Code: Select all
FUNCTION [NULL]
FunctionA[ ()
{
debug("FUNCTION A");
} ]
FunctionB[ ()
{
debug("FUNCTION B");
} ]
DoThing[ ()
{
FUNCTION="FunctionA";
@FUNCTION();
FUNCTION="FunctionB";
@FUNCTION();
} ]
Everyone can see the difficult, but only the wise can see the simple.
-----
-----
Re: Get values of other pawns through simkin command?
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. )
Also...
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.
Also...
Code: Select all
ProcessItem[ (ITEM)
{
for each IT in @ITEM
{
debug(IT.label#" = "#IT);
}
} ]
SomeFunction[ ()
{
ProcessItem("ITEM_SWORD");
ProcessItem("ITEM_DAGGER");
} ]
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
RF System X:
http://www.realityfactory.info/forum/vi ... f=9&t=3599
Re: Get values of other pawns through simkin command?
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
(O.o) copy bunny into your signature to
( >< )help him achieve world domination
Re: Get values of other pawns through simkin command?
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
@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.
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
@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.
-----
-----
Re: Get values of other pawns through simkin command?
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...Graywolf wrote:Those "for each in" commands are very convenient.
Pain is only psychological.
-
- Posts: 335
- Joined: Sat Feb 09, 2008 5:47 pm
- Location: Lanzarote/Canary Islands/Spain
Re: Get values of other pawns through simkin command?
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/
http://www.simkin.co.uk/Docs/java/
Re: Get values of other pawns through simkin command?
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.
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.