LSL7 style Cursor/GUI

Started by Nixxon, Thu 13/11/2003 01:53:26

Previous topic - Next topic

Nixxon

Hi :)
Just wondering if a lsl7 gui style was currently possible?
If so, what's the most simplistic way to make one? is there a template already available?
Thanks a lot,
very much appreciated :)

Gilbert

What's the LSL7 GUI like?

Nixxon

#2
One transparent onscreen cursor... when you clicked on a hotspot it expanded a transparent menu with "look. use. take. talk. use with inventory -" etc.
I have a feeling the KQ7 GUI was similar... too long ago to remember
I could bring up a GUI when the cursor clicks on a hotspot with look, take, speak etc.
Only prob is... the GUI needs to have modifiable actions. Certain hotspots may have unique actions... i dont want these to be selectable actions on every single hotspot.
e.g
click on giant novelty ball of cheddar
Eat
Lick
molest
etc.

Gilbert

Ah. The transparent cursor part may be impossible at the moment, so I'll just ignore it for now.

For teh customizable actions on GUI, actually it's not really difficult to script (as I had actually planned exactly the same thing myself).
First you may decide for a max limit on how many actions a hotspot/object could have, here for definiteness, I'll use 3.
Next you have to make a list on what number represents what action, example:
0 - no action
1 - look
2 - use
3 - pick up
4 - smell... etc

Now, here is the important part:
In agsedit goto hotspot/object etc screen and select "property...", you may have to choose "edit schema..." if you already defined some properties (all game items share the same set of properties at the moment, so just create these stuffs once and all objects/characters/hotspots are immediately capable of having them), right click and create a new property.

Call it "action1", make a description like "action for 1st GUI option", select "Number" in type and set its default value to 0 (ie "no action" from your list). Repeat this to create properties "action2" and "action3".

Now, when making your game, if say, you want to bring up the GUI with the actions "look", "smell" and "no action" while clicking on a hotspot, just set the property of the hotspot (see your list):
1 for "action1"
4 for "action2"
0 for "action3"

(Same procedure for characters, objects, etc)

(too long, continue on next post)


Gilbert

#4
(continued)

First put on top of global script:
int loctype, locnum, clickx, clicky;

Now you can script the code for bringing up the GUI (prolly in "onmouseclick() event), so when the player clicks on something, do something like (warning: may contain pseudo code, please clean it yourself, here I assume the GUI is number 5 and the three action buttons are #1, #2, #3):
[code
clickx=mouse.x;
clicky=mouse.y;
loctype=GetLocationType(clickx,clicky);
int actions[2];
if (loctype==0){//nothing, GUI or inventory
//Blah bla bla do something or ignore it, depends on what you need
} else
{if (loctype==1){//hotspot
locnum=GetHotspotAt(clickx,clicky);
action[0]=GetHotspotProperty (locnum , "action1");
action[1]=GetHotspotProperty (locnum , "action2");
action[2]=GetHotspotProperty (locnum , "action3");}
else if (loctype==2){//character
locnum=GetCharacterAt(clickx,clicky);
action[0]=GetCharacterProperty (locnum , "action1");
action[1]=GetCharacterProperty (locnum , "action2");
action[2]=GetCharacterProperty (locnum , "action3");}
else if (loctype==3){//object
locnum=GetObjectAt(clickx,clicky);
action[0]=GetObjectProperty (locnum , "action1");
action[1]=GetObjectProperty (locnum , "action2");
action[2]=GetObjectProperty (locnum , "action3");}

int act,coutn=3;
while(coutn){
coutn--;
act=action[coutn];
if (act==0) SetLabelText(5,coutn+1,"no action");else
if (act==1) SetLabelText(5,coutn+1,"look"); else
if (act==2) SetLabelText(5,coutn+1,"use"); else
... blah bla bla
GUIOn(5);
}

Then you could just do lazy things, set the action of button #1 to "run script..." and type in:
ProcessClick(clickx,clicky,MODE_LOOK);

set the action of button #2 to "run script..." and type in:
ProcessClick(clickx,clicky,MODE_USE);

set the action of button #3 to "run script..." and type in:
ProcessClick(clickx,clicky,MODE_TALK);

Just make sure you remove/comment all part of the codes concerning mouse mode changing and make it stick to MODE_WALK.

When you want to script a respond for a say, hotspot (same for character, obect,etc), just put whatever you want to happen for it with "action1" in the "look at hotspot" interaction, put whatever you want to happen for it with "action2" in the "Interact with hotspot" interaction, and put whatever you want to happen for it with "action2" in the "Talk to hotspot" interation.


I think it may be quite messy (and untested, so you may need modifications), but I hope that gives you some idea.

damn the []'s are messing up with YABB codes, just reply to it to see the plain text.

Timosity

wasn't there also a text parser included in the gui too, in the sense that after you typed in a word it stored it so you could use it in other situations.

This was good as it wasn't just left up to the cursors.

probably hard to implement it aswell, but it was a cool feature

Nixxon

Gilbot your an absolute champion!
Thanks a million.
Currently unable to fix the code up though... will browse through the manual and see if i can peice it together slowly but surely :P
So glad it's possible, thanks again :D

Yeh the text parser was a pretty cool novelty type funtion, t'was used for a few puzzles.

Gilbert

Note I just made some slight mods (eg I mistakenly used () instead of [] for arrays), there may be more.

Scorpiorus

As about the transparent cursor you could make a transparent GUI representing that cursor, then hide the real cursor by importing a transparent sprite.

On start up:
SetGUITransparency (GUIFAKECURSOR, 50);

Next, in the repeatedly_execute:

SetGUIPosition (GUIFAKECURSOR, mouse.x, mouse.y);

Just two limitations:

1. Wait() command blocks the script so the position of GUICURSOR isn't updated then. A workaround is to make your own wait function:

function MyWait(int time) {
int i = time;
while (time > 0) {
SetGUIPosition (GUIFAKECURSOR, mouse.x, mouse.y);
Wait(1);
i--;
}
}


2. Make sure it's the LAST gui you have added, otherwise it can be covered by another GUI (because of Z-order). AFAIK, in the last AGS beta it's possible to change z-order though.

~Cheers

Nixxon

oh my god cool...! cheers
can't wait to get this whole thing working, could be uploaded as a reference somewhere if any other AGS'ers would be interested in using this style of GUI.
Anyways ill post again soon on it's progress,
many thanks :)

SMF spam blocked by CleanTalk