object.name=msg ^\w{4}(?<this.name>)$HegemonKhan wrote:Can someone show me what the syntax would look like, as I can't figure it out from the wiki link ???
Avantar wrote:Well, Pixie.
Since it is your script I am busy with, maybe you can help; since the idea I had does not work.
The script I am using from you is the 'Shop'.
So with the shop, you are able to buy, but not sell. I added the selling part, but if the shop sells shoes and you buy some shoes, it clones it obviously and create the name shoes1,2,3....
If I want to sell shoes I have bought from the shop, it will ask me which shoes I want to sell - it also includes the shoes in the shop; since it is visible too.
That is why I wanted to actually change the actual name of the shoes in the shop and the cloned shoes (but not shoes1) - but you are not allowed to do that outside editor mode. Come to think of it, it still wouldn't have worked anyway - it would end up trying to make duplicate names.
Would there be a way around this?
<command name="sell_command">
<pattern>sell #text#</pattern>
<script>
if (GetBoolean (game.pov.parent, "shop") {
sell_function (text)
} else {
msg ("This is not a shop, you must be at a shop to sell your items.")
}
</script>
</command>
<function name="sell_function" parameters="text"><![CDATA[
equipment_x = GetObject (text)
if (equipment_x = null) {
foreach (item_x, ScopeInventory ()) {
if (item_x.alias = text) {
equipment_x = item_x
} else {
msg ("You don't possess this item, so you can't sell what you don't have!")
}
}
}
if (equipment_x <> null) {
if (game.pov.parent.cash >= equipment_x.cash) {
game.pov.parent.cash = game.pov.parent.cash - equipment_x.cash
game.pov.cash = game.pov.cash + equipment_x.cash
equipment_x.parent = game.pov.parent
} else {
msg ("The shop owner unfortunately can't afford the item that you're trying to sell to him.")
}
}
]]></function>
<library>
<command name="buy_stuff">
<pattern>buy #text#; purchase #text#</pattern>
<script><![CDATA[
object_x = GetObject (text)
foreach (i, AllObjects()) {
if (i.alias=text){
text = i.name
object_x=GetObject (text)
}
}
if (object_x = null) {
foreach (obj, AllObjects()) {
if (obj.alias=text or obj.name=text) {
object_x = obj
}
}
}
if (object_x=null){
msg ("There is no such item!")
}
else {
if (GetBoolean(player.parent, "shop")) {
if (HasInt(object_x, "price")) {
if (player.money < object_x.price) {
msg ("You can not afford it.")
}
else if (not GetAttribute (object_x,"parent")=SoldItems and not object_x.parent = player.parent){
msg ("There is no such item here!")
}
else if (GetAttribute (object_x,"parent")=SoldItems){
msg ("You buy a " + object_x.name + " for " + object_x.price + " coins.")
object_x.parent = game.pov
player.money = player.money - object_x.price
}
else {
msg ("You buy a " + object_x.name + " for " + object_x.price + " coins.")
b = Clone(object_x)
MoveObject (b, player)
player.money = player.money - object_x.price
b.take = True
b.scenery = False
}
}
else {
msg ("That item is not for sale.")
}
}
else{
msg ("You are not in a shop.")
}
}
]]></script>
</command>
<command name="sell_stuff">
<pattern>sell #text#</pattern>
<script><![CDATA[
if (GetBoolean(player.parent, "shop")) {
ProcessScopeCommand ("sell_object", ScopeInventory(), text, "You do not have this item in your inventory.", "You can not sell this item.")
}
else {
msg ("[NotAShop]")
}
]]></script>
</command>a = 0
msg ("You can buy a hat for 6 gold coins or a coat for 11.")
foreach (i, AllObjects()) {
if (GetAttribute (i,"parent")=SoldItems) {
a = a + 1
if (a>0) {
msg ("You can re-buy your sold items: " + i.name + " for " + i.price + " coins.")
}
}
}