WML Shop help

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
Beastss
Posts: 15
Joined: December 23rd, 2007, 9:57 am

WML Shop help

Post by Beastss »

What I'm trying to do is make text in the shop appear "white"/normal color if the character has the relevant amount of gold, but if not then it would appear red. I've tried different coding but they don't seem to work, and I can't figure it out. By the way, I'm a WML noob.... Here's what I've tried already...

First I tried this:

Code: Select all


[if]
[variable]
greater_than_equal_to=150
[/variable]
[then]
[option] 
message=_ "Wooden Longbow (2-3 R, P): 150g" 
[command] 
[if] 
[variable] 
name=gold 
greater_than_equal_to=150
[/variable] 
[then] 
[gold] 
amount=-150 
side=$side_number 
[/gold] 
[object] 
silent=yes 
[effect]
apply_to=new_attack
name=W. Longbow 
range=ranged 
type=pierce
damage=2 
number=3 
defense_weight=100
[/effect] 
[/object] 
[/then] 
[/if] 
[/command] 
[/option]
[/then]
[else]
[option] 
message=_ "#Wooden Longbow (2-3 R, P): 150g" 
[/option]
[/else]
[/if]


Then I tried:

Code: Select all


[option] 
[if]
[variable]
greater_than_equal_to=150
[/variable]
[then]
message=_ "Wooden Longbow (2-3 R, P): 150g" 
[command] 
[if] 
[variable] 
name=gold 
greater_than_equal_to=150
[/variable] 
[then] 
[gold] 
amount=-150 
side=$side_number 
[/gold] 
[object] 
silent=yes 
[effect]
apply_to=new_attack
name=W. Longbow 
range=ranged 
type=pierce
damage=2 
number=3 
defense_weight=100
[/effect] 
[/object] 
[/then] 
[/if] 
[/command] 
[/then]
[else]
message=_ "#Wooden Longbow (2-3 R, P): 150g" 
[/else]
[/if]
[/option]

That didn't work, didn't think it would. It was worth a try, so then I remembered "show_if" so I tried:

Code: Select all


[option]
message=_ "Wooden Longbow (2-3 R, P): 150g"
[show_if] 
[variable] 
name=gold 
greater_than_equal_to=150
[/variable]
[command] 
[if] 
[variable] 
name=gold 
greater_than_equal_to=150
[/variable] 
[then] 
[gold] 
amount=-150 
side=$side_number 
[/gold] 
[object] 
silent=yes 
[effect]
apply_to=new_attack
name=W. Longbow 
range=ranged 
type=pierce
damage=2 
number=3 
defense_weight=100
[/effect] 
[/object] 
[/then] 
[/if] 
[/command]
[/show_if]
[/option]

[option]
message=_ "#Wooden Longbow (2-3 R, P): 150g"
[show_if] 
[variable] 
name=gold 
less_than=150
[/variable]
[/show_if]
[/option]


Here's a picture of the last try I did...
Image

So what am I doing wrong? Thanks for any help you could give...
User avatar
Blueblaze
Posts: 418
Joined: June 24th, 2007, 12:16 am

Post by Blueblaze »

Okay, I tested this, a simplified version of your two options. This code works perfectly fine.

Code: Select all


[option] 
message=_ "#Wooden Longbow (2-3 R, P): 150g" 
[show_if] 
[variable] 
name=gold 
less_than=150 
[/variable] 
[/show_if] 
[/option] 

[option] 
message=_ "Wooden Longbow (2-3 R, P): 150g" 
[show_if] 
[variable] 
name=gold 
greater_than=150 
[/variable] 
[/show_if] 
[command]
[message]
message=_ "Hi"
[/message]
[/command]
[/option] 


Your problem is, you cannot stick everything in the [show_if]. You need to only put the variable in there. See how I put the message outside of the [show_if]s but inside the [command]s?

Secondly, you should also use "geater_than_equal_to" instead of "greater_than" because if someone goes to shop with exactly 150 gold, they won't be able to purchase the product, and it won't show in red for them either, even though they have the required gold.

Thirdly, now that [show_if] exists, you don't have to check and see if the player has enough gold. All you have to do is subtract the gold from them, since [show_if] already checked the gold amount.

Finally, I see you're using my map :P
Beastss
Posts: 15
Joined: December 23rd, 2007, 9:57 am

Post by Beastss »

thank you...
Quick question, would it allow them to buy the object and see it in white if I put:

Code: Select all

[option]
message=_ "#Wooden Longbow (2-3 R, P): 150g"
[show_if]
[variable]
name=gold
less_than=150
[/variable]
[/show_if]
[/option]

[option]
message=_ "Wooden Longbow (2-3 R, P): 150g"
[show_if]
[variable]
name=gold
[b]greater_than=149[/b]
[/variable]
[/show_if]
[command]
[message]
message=_ "Hi"
[/message]
[/command]
[/option] 

And yea, I am using your map... its a simple map to work from... but its not the game map that I am going with :oops:

hopefully, I'll have a test of this game up by the end of the month, with just a few of my shops working... got lots and lots of shops with special items to put in there... :D
but the test will only have the map, and the general shops in the game... I want to see if it will be balanced...

thanks for your help!
User avatar
Blueblaze
Posts: 418
Joined: June 24th, 2007, 12:16 am

Post by Blueblaze »

Why do you have the bold code around the variable check? Without the b's it would work.
Beastss
Posts: 15
Joined: December 23rd, 2007, 9:57 am

Post by Beastss »

I tried the code, it didn't work for me. I mean, both options showed up at the same time, so it wasn't really working. Another problem that occurred, it would take gold from the character even after you don't have enough and just keep selecting it. Here's what I used:

Code: Select all

[option]
message=_ "#Wooden Longbow (2-3 R, P): 150g"
[show_if]
[variable]
name=gold
less_than=150
[/variable]
[/show_if]
[/option]

[option]
message=_ "Wooden Longbow (2-3 R, P): 150g"
[show_if]
[variable]
name=gold
[b]greater_than=149[/b]
[/variable]
[/show_if]
[command]
[gold] 
amount=-150 
side=$side_number 
[/gold] 
[object] 
silent=yes 
[effect]
apply_to=new_attack
name=W. Longbow 
range=ranged 
type=pierce
damage=2 
number=3 
defense_weight=100
[/effect] 
[/object] 
[/command]
[/option] 
I don't know if I messed it up or something, but I just dropped the idea for now. However, it would be good to know in case I decide to try it again. Plus I would like to have it shown in my new topic. I am going to put your last one in there for now though.
User avatar
Blueblaze
Posts: 418
Joined: June 24th, 2007, 12:16 am

Post by Blueblaze »

Blueblaze wrote:Why do you have the bold code around the variable check? Without the b's it would work.
I quote myself because I answered this question already.

Code: Select all

[b]greater_than=149[/b]
Needs to be...

Code: Select all

greater_than=149
Beastss
Posts: 15
Joined: December 23rd, 2007, 9:57 am

Post by Beastss »

that wasn't in the original coding, its just that I deleted what I used for my test so instead of rewriting it, I just copied what was already up there. I'm not such an idiot to leave that in there. Just test it and see what happens.
Post Reply