Page 1 of 2

cooking script

Posted: February 11th, 2012, 11:48 am
by kddekadenz
I wanted to make a guislider for the amount of meat which should be cooked.

The guislider doesn't show up for me (note that 19 is the ID of raw meat and 20 the ID of cooked meat):

Code: Select all

meat_count = (r_get_amount player 19)

r_script_signal interact [
			r_chat self 0
]


r_script_say "What do you want to cook?" [ //0
	if ( > (r_get_amount player 19) 0) [
		r_response "[Cook 'Meat']" 1
	]
	r_response "Nothing." -1
]

r_script_say "How much you want to cook?" [ //1
guislider meat_count
r_response "[OK]" 2
r_response "Nothing" -1
]

r_script_say "The meat is cooked." [ //2
	r_response "Take the meat." -1 [
	r_additem player 20 (meat_count)
	r_remove player 19 (meat_count)
	]
	
]
Any idea what's my mistake?

Re: Guislider in RPG dialog?

Posted: February 12th, 2012, 3:42 pm
by arcones
A common mistake that trips me up is missing quotation marks ( " ) or a bracket. So if there's quotation marks missing for you guislider meat count, that might be it, but I would think Sandbox would pick it up.

That would be my suggestion.

Re: Guislider in RPG dialog?

Posted: February 12th, 2012, 9:21 pm
by Hirato
RPG dialogue just doesn't work that way. the r_response thing is meant to be a UI system independent means of defining dialogue.
Naturally sliders won't work

Re: Guislider in RPG dialog?

Posted: February 12th, 2012, 9:26 pm
by chocolatepie33
from your devblog:
We've picked it up again and we hope to have UI replace the old 3dgui by 2.8.0, we unfortunately have a LOT of work to do before the switch is even feasible.
For starters, there are the missing elements, there are basically 3 scenarios we need to be able to cover which the current UI facilities don't provide. As follows they are...

1. a guislider equivalent
2. some sort of dynamic text
3. a guifield equivalent
4. a guikeyfield equivalent
5. the ability to wrap text

We can more or less tackle the first case by jury-rigging the scrollbar code to function as the sliders and this is the approach I've taken, so our sliders have scrolling areas as well as a button in the centre to signify its position. While this has been completed, it's still a bit buggy, for example it handles integers (read: ID_VAR) very poorly. In addition it also lacks 2 capabilities I'd very much like some sort of "onchange" scrip and the ability to scroll up/left and down/right usign the mouse wheel or even the appropriate directional keys.
So you have it, it's just not quite implemented yet?

Re: Guislider in RPG dialog?

Posted: February 13th, 2012, 2:36 am
by Hirato
We've already implemented that.
UI should very much explain why the dialogue system was designed as is; UI system agnostic.

There are some screenshots on moddb regarding an earlier more experimental version.
http://www.moddb.com/games/platinum-art ... 2#imagebox

Re: Guislider in RPG dialog?

Posted: February 13th, 2012, 12:58 pm
by kddekadenz
Hirato wrote:RPG dialogue just doesn't work that way. the r_response thing is meant to be a UI system independent means of defining dialogue.
Naturally sliders won't work
Hmm.
And could be a command be executed when the response is chosen?

Code: Select all

r_response (format "%1 meat" (meat_cook)) [meat_cook = meat_cook + 1]
This displays the first dialogue when chosen :/ Note: setted meat_cook to 0 at beginning

Re: Guislider in RPG dialog?

Posted: February 13th, 2012, 8:36 pm
by Hirato
the syntax is r_response text dst script.
so yes, you could do something like that. Though I'd suggest using a series of fixed size queries for now.
eg, cook 1, cook 5, cook 10, cook 20, cook 50, cook 100, etc

Re: Guislider in RPG dialog?

Posted: February 14th, 2012, 11:29 am
by kddekadenz
Works now fine :D

Here is the code, for anyone who is interested:

Code: Select all

//cook stuff, currently only meat
// 19 - ID of raw meat
// 20 - ID of cooked meat

meat_cook = 0

r_script_signal interact [
			r_chat self 0
]


r_script_say "What do you want to cook?" [ //0
	if ( > (r_get_amount player 19) 0) [
		r_response "[Cook 'Meat']" 1
	]
	r_response "Nothing." -1
]

r_script_say "How much you want to cook?" [ //1
r_response "everything" 2 "meat_cook = (r_get_amount player 19)"
r_response "1 meat" 2 "meat_cook = 1"
if ( > (r_get_amount player 19) 4) [r_response "5 meat" 2 "meat_cook = 5"]
if ( > (r_get_amount player 19) 9) [r_response "10 meat" 2 "meat_cook = 10"]
r_response "nothing" -1
]

r_script_say "The meat is cooked." [ //2
	r_response "Take the meat." -1 [
	r_additem player 20 (meat_cook)
	r_remove player 19 (meat_cook)
	]
	
]

Re: Guislider in RPG dialog?

Posted: February 14th, 2012, 10:30 pm
by chocolatepie33
Good job, kdd.

Anyways, *Slaps self*

Sorry about the (idiotic) post about the newUI slider, I just went from slider to slider and ignored the RPG to newui stuff. Again, sorry about that.
However, that means that when newUI comes about, it'll be just fine to use for everything?

Re: Guislider in RPG dialog?

Posted: February 15th, 2012, 2:04 am
by Hirato
RPG wise? Yeah
I still need to do something about the FPS's scoreboard...

Most of the non-editing UIs should be up to scratch with their 3dgui counterparts.