Questions about group and list
Moderators: Scripting / Modding Moderators, Moderators for English X Forum
-
- Posts: 126
- Joined: Sat, 14. Mar 15, 15:16
Questions about group and list
Hey guys. i have done a lot of asking around and i apologize for the threads. i will try and merge all my question threads into one thread as soon as they are answered.
may i ask what is the difference between group and list and why group cannot have a "count" property ?
may i ask what is the difference between group and list and why group cannot have a "count" property ?
-
- Moderator (Script&Mod)
- Posts: 13486
- Joined: Sun, 15. Feb 04, 20:12
Hi J3ANP3T3R 
Think of groups and lists In terms of sets then the list is an ordered set. So you can add or remove members of a group but since there is no order you cannot have a counter as for lists.
Hope that helps.
Cheers Euclid

Think of groups and lists In terms of sets then the list is an ordered set. So you can add or remove members of a group but since there is no order you cannot have a counter as for lists.
Hope that helps.
Cheers Euclid
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786
-
- Moderator (Script&Mod)
- Posts: 14571
- Joined: Sun, 20. Nov 05, 22:45
huh? groups do have a count attribute... at least according to scriptproperties.html the last timee i checked.. (today morning)
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help

-
- Posts: 126
- Joined: Sat, 14. Mar 15, 15:16
thanks ! that explains the differences and why there had to be a group and a list. although unitrader was right i was looking at a backup copy of scriptproperties and in 3.5 groups have the count property.euclid wrote:Hi J3ANP3T3R
Think of groups and lists In terms of sets then the list is an ordered set. So you can add or remove members of a group but since there is no order you cannot have a counter as for lists.
Hope that helps.
Cheers Euclid
-
- Posts: 126
- Joined: Sat, 14. Mar 15, 15:16
-
- EGOSOFT
- Posts: 13126
- Joined: Sat, 9. Nov 02, 11:45
-
- Posts: 126
- Joined: Sat, 14. Mar 15, 15:16
thanks ! that added clarity. may i additionally ask, how can i create a list containing 2 more lists on each index ?
for example ...
create list $entities contains 10 NPCs
create list $zones contains 10 ZONES
i want to put them on a single list say $details
so that i can do_all $details like
do_all $details.count counter $d
$details.{$d}.$entities.{2}
$details.{$d}.$zones.{2}
something like that.
for example ...
create list $entities contains 10 NPCs
create list $zones contains 10 ZONES
i want to put them on a single list say $details
so that i can do_all $details like
do_all $details.count counter $d
$details.{$d}.$entities.{2}
$details.{$d}.$zones.{2}
something like that.
-
- Moderator (Script&Mod)
- Posts: 14571
- Joined: Sun, 20. Nov 05, 22:45
Code: Select all
<set_value name="$details" exact="
[
[ $entity1 , $zone1 ] ,
[ $entity2 , $zone2 ] ,
……………
[ $entityN , $zoneN ]
]" />
or if you want to create it from existing lists or by iteration through something else:
Code: Select all
<create_list name="$details" />
<do_all exact="$entities.count" counter="$i>
<append to list name="$details" exact="[ $entities.{$i} , $zones.{$i} />
</do_all>
and after posting this i noticed yu meant something a bit diffrent.. but wont remove it now..
EDIT:
the way you want it to be done would require that $details.{$i} resolves to something which can store Values, for example an Entity (you would access its blackboard then) or an MD Cue (remote Var Accesss; MD only) - both have their obvious problems (requires entity or cue of its own)
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help

-
- Posts: 335
- Joined: Mon, 23. Apr 12, 23:56
Also, there is the datatype "table" ego has introduced in 3.50RC3:UniTrader wrote: EDIT:
the way you want it to be done would require that $details.{$i} resolves to something which can store Values, for example an Entity (you would access its blackboard then) or an MD Cue (remote Var Accesss; MD only) - both have their obvious problems (requires entity or cue of its own)
changelog wrote: New script datatype "table" mapping arbitrary keys to values
You can assign values to arbitrary keys, e.g. to $table.{1} or $table.{player.primaryship}
You can assign values to variable-type keys, e.g. to $table.$foo (shortcut for $table.{'$foo'})
Almost all values are allowed as table keys - exceptions:
- Strings must start with '$' (bad: $table.foo, good: $table.$foo)
- Lists, tables, groups and buildplans cannot be used as table keys
- null cannot be used as table key (but the number 0 is valid)
Example syntax for creating and initialising a table:
- "table[]" (empty table)
- "table[$foo = 42]" (a table that maps string '$foo' to 42)
- "table[$bar = $bar, {10} = []]" (mapping '$bar' to the value of the variable $bar, and the number 10 to an empty list)
- "table[{$baz} = null]" (mapping the value of $baz to null)
Use <set_value> and <remove_value> to add/remove table entries, and "?" to check for existence of a key
See scriptproperties documentation for available table properties
-
- Moderator (Script&Mod)
- Posts: 14571
- Joined: Sun, 20. Nov 05, 22:45
ah, didnt know about this one - thx for the hint 

if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help

-
- Posts: 335
- Joined: Mon, 23. Apr 12, 23:56
yeah, found it by accident when working with ui-stuff and return-values from lua to md. everything worked fine until 3.50rc3, but suddenly I got this new table-datatype instead of a list (which I expected of course) and everything broke... but it's nice to have this datatype now 
@J3ANP3T3R: I guess now it would be something like this
although I suspect that UniTraders solution is what you were really seeking

@J3ANP3T3R: I guess now it would be something like this
Code: Select all
<set_value name="$details" exact"=
[
table[
$entities = [ ... ],
$zones = [ ... ]
],
...
]" />
-
- Posts: 585
- Joined: Thu, 26. Feb 04, 00:08
-
- Posts: 126
- Joined: Sat, 14. Mar 15, 15:16
Phipsz wrote:yeah, found it by accident when working with ui-stuff and return-values from lua to md. everything worked fine until 3.50rc3, but suddenly I got this new table-datatype instead of a list (which I expected of course) and everything broke... but it's nice to have this datatype now
@J3ANP3T3R: I guess now it would be something like thisalthough I suspect that UniTraders solution is what you were really seekingCode: Select all
<set_value name="$details" exact"= [ table[ $entities = [ ... ], $zones = [ ... ] ], ... ]" />
Thank you all guys. i think the table would do if the normal list on a list will not work. what i actually wanted to do is add the two lists as properties of a main list. each member of the list $details will each have two property $entities and $zones both of which are also lists.
if i use your example
<set_value name="$details" exact"=
[
table[
$entities = [ ... ],
$zones = [ ... ]
],
...
]" />
how do i access each property ? is there really an = after 'exact" ' ? what does = mean ? i think unitrader's list within a list could also work it makes sense. thank you

-
- Posts: 126
- Joined: Sat, 14. Mar 15, 15:16
-
- Posts: 585
- Joined: Thu, 26. Feb 04, 00:08
In general a list is index based just like an array in C/C++ so:J3ANP3T3R wrote:Thank you all guys. i think the table would do if the normal list on a list will not work. what i actually wanted to do is add the two lists as properties of a main list. each member of the list $details will each have two property $entities and $zones both of which are also lists.
how do i access each property ? is there really an = after 'exact" ' ? what does = mean ? i think unitrader's list within a list could also work it makes sense. thank you
Code: Select all
<set_value name="$a" exact="1"/>
<set_value name="$b" exact="20"/>
<set_value name="$c" exact="300"/>
<set_value name=$myList exact=[$a, $b, $c]/>
$myList.{1} is value 1
$myList.{2} is value 20
$myList.{3} is value 300
Code: Select all
<set_value name="$myTable" exact="[ $keya=$a, $keyb=$b, $keyc=$c] />
now I can access these as properties:
$myTable.$keya is value 1
$myTable.$keyb is value 20
$myTable.$keyc is value 300
<set_value name="$myVariable" exact="12.07"/>
is equivalent to something like:
float myVariable = 12.07;
in C.
Edit: Just seen your last post - I don't think you can have NULL as a key but it should be fine as a value.
-
- Posts: 2774
- Joined: Tue, 29. Oct 13, 21:59
I could only find a data type entry then this in common.xsd, so I assume the mechanism is more designed for passing tables from lua than for creating them in xml.
I would infer from this that we access the data as if it was a list of lists in the same way as it's done in the md for npc wares + prices data.
Code: Select all
<xs:element name="clear_table">
<xs:annotation>
<xs:documentation>
Clear a table, i.e. remove all keys and values from it
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attributeGroup ref="action" />
<xs:attribute name="table" type="table" use="required" />
</xs:complexType>
</xs:element>
X Rebirth - A Sirius Cybernetics Corporation Product
Split irritate visiting pilot with strange vocal patterns.
Split irritate visiting pilot with strange vocal patterns.
-
- Posts: 126
- Joined: Sat, 14. Mar 15, 15:16
ah so in '<set_value name="$details" exact"= ' its <set_value name="$details" exact=" ?
also about the null thing ... the list wont accept it ? darn i was hoping i can have for example
$list.{1} = 'a'
$list.{2} = 'b'
$list.{3} = null
$list.{4} = 'c'
to synchronize data from another list and they both had to use the same index.
also about the null thing ... the list wont accept it ? darn i was hoping i can have for example
$list.{1} = 'a'
$list.{2} = 'b'
$list.{3} = null
$list.{4} = 'c'
to synchronize data from another list and they both had to use the same index.
-
- Moderator (Script&Mod)
- Posts: 14571
- Joined: Sun, 20. Nov 05, 22:45
list.{3} = null does work
(or appending a null value to a list) what does not work is list.{null} = 3 obviously
similiar for tables - null does not work as key name (no idea how you could even write that) - but it would work as resulting value

similiar for tables - null does not work as key name (no idea how you could even write that) - but it would work as resulting value

if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help

-
- Posts: 126
- Joined: Sat, 14. Mar 15, 15:16
Thanks ! i was hoping it would work because i still don't understand the table thing and im a programmer in real life working with tables. one with rows and columns.UniTrader wrote:list.{3} = null does work(or appending a null value to a list) what does not work is list.{null} = 3 obviously
similiar for tables - null does not work as key name (no idea how you could even write that) - but it would work as resulting value
if i may... i would like to insert another question without spamming a new thread. is there a way for me to remove ware reservations from an entity without specifying the object and the ware ?
for example
<remove_ware_reservation entity="this" />
will this work ?
what about getting the ware reservations of an entity
<get_ware_reservation entity="this" />
thanks

-
- Moderator (Script&Mod)
- Posts: 14571
- Joined: Sun, 20. Nov 05, 22:45
for both (get and remove) nope, object is required according to doc.
but you can iterate through the Shoppinglist ( <get_trade_from_shoppinglist /> to see which Stations a Ship/entity plans to trade with
but you can iterate through the Shoppinglist ( <get_trade_from_shoppinglist /> to see which Stations a Ship/entity plans to trade with

if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
