Page 1 of 1

How to get a Widget to unitcreated

Posted: 11 Oct 2010, 15:35
by bobthedinosaur
If I want a widget that runs on a unitcreated trigger how do I go about doing that, since unit created is synced and widgets are not?

Re: How to get a Widget to unitcreated

Posted: 11 Oct 2010, 16:09
by Niobium
widget:UnitCreated(...)

Voila. Widgets aren't limited to unsynced callins or callouts. They just can't use functions which change synced data, i.e. SetUnitPosition, but they have no trouble reading the sycned data, i.e. GetUnitPosition, or using some of the synced callins, i.e. :GameFrame, Unit_____, etc.

Re: How to get a Widget to unitcreated

Posted: 12 Oct 2010, 03:55
by bobthedinosaur
Then I must be doing something wrong.
http://sl.pastebin.com/HY37GTR2

Probably with the list?

Re: How to get a Widget to unitcreated

Posted: 12 Oct 2010, 03:57
by aegis
Spring.SelectUnitArray{unitArray[1]}
you don't want curly braces there, you want parentheses

Re: How to get a Widget to unitcreated

Posted: 12 Oct 2010, 04:29
by bobthedinosaur
they didn't really help either. Plus that code works just fine from where I ripped it from.

Re: How to get a Widget to unitcreated

Posted: 12 Oct 2010, 04:42
by Niobium
SelectUnitArray takes a unit array, so you would use: 'Spring.SelectUnitArray(unitArray)'.

Re: How to get a Widget to unitcreated

Posted: 12 Oct 2010, 05:43
by bobthedinosaur
Ah yes. You are correct. That makes it work just fine.

Re: How to get a Widget to unitcreated

Posted: 01 Nov 2010, 17:45
by Pithikos
They just can't use functions which change synced data
You can use UnitCreated only on your own units right? Or can you read synced data no matter?

Re: How to get a Widget to unitcreated

Posted: 01 Nov 2010, 18:24
by knorke
You can read synced data, ie unit positions but it is limited to what the player sees:
When used in a widget, UnitCreated, UnitDestroyed and similiar callins only "see" what the player sees.
ie your own units, allied units and enemy units that are Created/Destroyed in your LOS.
For spectators, the widget "sees" everything, same for replays.

Re: How to get a Widget to unitcreated

Posted: 01 Nov 2010, 19:35
by Pithikos
So there isn't a way to use UnitFinished to count some other team's units? Other than using a gadget..

Re: How to get a Widget to unitcreated

Posted: 01 Nov 2010, 21:20
by knorke
enemy = no, unless the units are always visible or something
allies = yes
you can check if uniteam == local players team, or what do you mean?

Re: How to get a Widget to unitcreated

Posted: 02 Nov 2010, 07:03
by Pithikos
Well I work on a mod and I want to count the units of the bot(the enemy bot) in a widget. In that way a user can disable and enable it on her/his own preference. So even if all users have the same widget that is located in the mod there isn't a way to use synced read?

Re: How to get a Widget to unitcreated

Posted: 02 Nov 2010, 11:37
by zwzsg
Widget are "helper" scripts, that players are free to grab or code themselves. Since you can have a widget and your opponent not, what widgets can do is severly limited to make sure they won't allow for cheats & exploits. As a typical exemple, if widgets could know about enemy units, then within hour we'd have a widget to display every units on the map, useable in any mod, without opponent knowing about it. That'll ruin all the games!


Gadget are parts of the mod, they can't be removed or added from a mod without making a new mod, and so they are given full power to change the simulation and the gameplay.