It works by SpawnBuilder command and setting builder costs. Like a command (Set values) is done "at once" before the engine routine starts (remove the gold, spawn the builder). So Setting the defaults values (650 gold) must be outside the command.
This sample script remove 2000 gold and spawns an extra builder. Don't know how go get the ID of the newly spawned builder. We could iterate of all of all entitys until we got him, but it would be a waste of resources. Well... we know S2 Games...
The SpawnBuilder() can be forced by of "onload" widget which is called by the UICall command.
Set _takeAwayMoney 2000
UICall ShowWidget takeAwayMoney
UICall HideWidget takeAwayMoney
Set _takeAwayMoney 0
<button name="ToggleRepairable" y="0" width="15" height="15" valign="bottom" align="center" onclick="ToggleRepairable(); echo (1000); Set (g_workerCost, 2000); Set (g_workerMaxActive, 4); SpawnWorker();echo (1111);" onmouseout="Set (g_workerCost, 650); Set (g_workerMaxActive, 3);" color="invisible" ontrigger="SetVisible(param);">
Ugly work around for tower defense: Make the stronghold invulnerable and place an enemy npc who kills the pets with 1 hit.
I love VOIP
sing: "base, base, base, base, base, base, base"
Why only 15 year old girls? Since 4 Years, damn I'm doing something wrong...
One day I will find out who is responsible for the K2 scripting "language" and the modding "support". And then...