Not sure how much help this is, since this is quite terrible code. I did it 4 years ago, and it was my first try of this kind. Notice that I hadnt figured out the name "Hotspot" at this point yet, and hence I am using "Touch Sensitive" or "ts" as describing hotspots.
Code: Select all
Function p_CheckTouchSensitiveAreas(currentroom)
mx = MouseX()
my = MouseY()
If my > 100 And mx > 0 And mx < 1800
SelectBGPic(2)
col = ReadPixel(MouseX(), MouseY())
EndSelect()
If Not (col = at.currentcolors[at.currentcolors.currentcolor])
If Not at.mainstatus = 2 Then at.mousepointerstatus=0
For i = 1 To currentroom.numberoftsareas
If col = at.currentcolors[i]
at.currentcolors.currentcolor=i
If at.mainstatus=2
tempnum = currentroom.tsarea[i].textover[0].currenttext
Else
If Not RawGet(currentroom.tsarea[i].textover[at.mousepointerstatus], "currenttext") = Nil
tempnum = currentroom.tsarea[i].textover[at.mousepointerstatus].currenttext
Else
tempnum = currentroom.tsarea[i].textover[0].currenttext
EndIf
EndIf
If at.mainstatus=2
DebugPrint("currentitemname:"..at.item.currentitem.." tsarea:"..i.." text:"..tempnum)
tempstring = "Use "..at.item[at.item.currentitem].name.." with "..currentroom.tsarea[i].textover[2].text[tempnum].text
Else
tempstring = currentroom.tsarea[i].textover[at.mousepointerstatus].text[tempnum].text
p_ChangeMousePointer(currentroom.tsarea[i].textover[at.mousepointerstatus].text[tempnum].mousepointer)
EndIf
p_DisplayNormalText(tempstring)
EndIf
Next
EndIf
If col = at.currentcolors[0]
If at.textdisplaystatus=1
If Not at.mainstatus = 2 Then at.mousepointerstatus=0
at.currentcolors.currentcolor=0
RemoveLayer("textdisplaybox")
RemoveLayer("text-displayed")
nextfreelayer=nextfreelayer-1
nextfreelayer=nextfreelayer-1
at.textdisplaystatus=0
p_ChangeMousePointer("normalpointer")
EndIf
EndIf
ElseIf my < 101 Or my > 1200
If at.textdisplaystatus=1
RemoveLayer("textdisplaybox")
RemoveLayer("text-displayed")
nextfreelayer=nextfreelayer-1
nextfreelayer=nextfreelayer-1
at.textdisplaystatus=0
EndIf
EndIf
EndFunction
I am having trouble reading this even myself. But what I can remember is that room is a table that contains all the necessary stuff for this, heres example room:
Code: Select all
mytable = {}
mytable = { status=1, numberofitems=0, numberoftsareas=5,
music="Easy Lemon.mp3",
filename="home-1800x1200.jpg",
bgfilename="homets-1800x1200.png",
type=1
}
mytable.tsarea = { /* tsarea = Touch Sensitive Area */
[1] = { textover = {
[0] = { amountofdifferenttexts=1, currenttext=1,
text = {
[1] = { text = "Go Out", name="Out",
mousepointer="arrowright" }
}
},
[1] = {
text = {
[1] = { text = "Go Out",
mousepointer="arrowright" }
}
},
[2] = { text = {
[1] = { text = "Out" }
}
}
},
/* Answer types: 1 = normal, just type the text and move To Next one on Line If there is any more
2 = grant an item
3 = go To Next Screen
4 = conversation
*/
answers = {
[0] = { amountofdifferentanswers = 1, currenttext=1,
[1] = { type = 3, roomname="turkumap" }
},
[1] = { amountofdifferentanswers = 1, currenttext=1,
[1] = { type = 3, roomname = "turkumap" }
}
}
},
[2] = { textover = {
[0] = { amountofdifferenttexts=1, currenttext=1,
text = {
[1] = { text = "Look at Computer", name="Computer",
mousepointer="eye" }
}
},
[1] = { amountofdifferenttexts=1, currenttext=1,
text = {
[1] = { text = "Turn on Computer",
mousepointer="hand" }
}
},
[2] = { text = {
[1] = { text = "computer" }
}
}
},
/* Answer types: 1 = normal, just type the text and move To Next one on Line If there is any more
*/
answers = {
[0] = { amountofdifferentanswers=1, currenttext=1,
[1] = { type = 1, text = "Thats my computer."
}
},
[1] = { amountofdifferentanswers=1, currenttext=1,
[1] = { type = 1, text = "I have no reason to" }
}
}
},
[3] = { textover = {
[0] = { amountofdifferenttexts=1, currenttext=1,
text = {
[1] = { text = "Look at Chair", name="Chair",
mousepointer="eye" }
}
},
[1] = { amountofdifferenttexts=1,
text = {
[1] = { text = "Sit on Chair",
mousepointer="hand" }
}
},
[2] = { text = {
[1] = { text = "Chair" }
}
}
},
/* Answer types: 1 = normal, just type the text and move To Next one on Line If there is any more
*/
answers = {
[0] = { amountofdifferentanswers=1, currenttext=1,
[1] = { type = 1, text = "Just ordinary Chair." }
},
[1] = { amountofdifferentanswers=1,
[1] = { type = 1, text = "I dont have time to sit down now." }
}
}
},
[4] = { textover = {
[0] = { amountofdifferenttexts=1, currenttext=1,
text = {
[1] = { text = "Look at Laser Printer", name="Laser Printer",
mousepointer="eye" }
}
},
[1] = { amountofdifferenttexts=1,
text = {
[1] = { text = "Use Laser Printer",
mousepointer="hand" }
}
},
[2] = { text = {
[1] = { text = "Laser Printer" }
}
}
},
/* Answer types: 1 = normal, just type the text and move To Next one on Line If there is any more
*/
answers = {
[0] = { amountofdifferentanswers=1, currenttext=1,
[1] = { type = 1, text = "It is Laser Printer." }
},
[1] = { amountofdifferentanswers=1,
[1] = { type = 1, text = "No point when Computer is not turned on." }
}
}
},
[5] = { textover = {
[0] = { amountofdifferenttexts=1, currenttext=1,
text = {
[1] = { text = "Look at Papers", name="Paper",
mousepointer="eye" }
}
},
[1] = { amountofdifferenttexts=1,
text = {
[1] = { text = "Take Paper",
mousepointer="hand" }
}
},
[2] = { text = {
[1] = { text = "Paper" }
}
}
},
/* Answer types: 1 = normal, just type the text and move To Next one on Line If there is any more
*/
answers = {
[0] = { amountofdifferentanswers=1, currenttext=1,
[1] = { type = 1, text = "Just standard empty white papers." }
},
[1] = { amountofdifferentanswers=1,
[1] = { type = 1, text = "I dont need any paper, i have all the paper i need in here if i want." }
}
}
}
}
mytable.item = {}
OpenFile(1, "home.bin", #MODE_WRITE)
WriteTable(1, mytable)
CloseFile(1)
Notice that when you run this piece, it will create home.bin from this code, which is simply a table that can be loaded at later point in the main program, which uses for example that p_CheckTouchSensitiveAreas(currentroom)
And that currentroom, is for example this home.bin that is being created here.
So it checks what is the color in that hidden picture at current mouse x,y spot. And then depending upon the color it jumps to home.bins table place. For example, if color is 5, then it jumps to that:
Code: Select all
[5] = { textover = {
[0] = { amountofdifferenttexts=1, currenttext=1,
text = {
[1] = { text = "Look at Papers", name="Paper",
mousepointer="eye" }
}
},
[1] = { amountofdifferenttexts=1,
text = {
[1] = { text = "Take Paper",
mousepointer="hand" }
}
},
[2] = { text = {
[1] = { text = "Paper" }
}
}
},
/* Answer types: 1 = normal, just type the text and move To Next one on Line If there is any more
*/
answers = {
[0] = { amountofdifferentanswers=1, currenttext=1,
[1] = { type = 1, text = "Just standard empty white papers." }
},
[1] = { amountofdifferentanswers=1,
[1] = { type = 1, text = "I dont need any paper, i have all the paper i need in here if i want." }
}
}
}
If i correctly remember how this works is that textover and answers are related to each other in that answers[1] is what happens when textover[1] is selected.
Idea is that when you first time move your mouse over that color 5, then it will use textover[0] spot, which in this case is to display text of "Look at papers" and change mouse pointer into eye.
If player clicks it, then happens the Answers[0] place, which in this case is to display text of "Just standard empty papers..
After this, if mouse pointer is moved to same place (color) again, then it will next time be using Textover[1], which means it will display "Take paper", and change mouse pointer to hands picture.
If user clicks, then it will go to Answers[1], which in this case will just display "I dont need any paper, i have all the paper i need in here if i want.".
After this, if once again player moves mouse pointer over this same hotspot area (color 5), it will go to Textover[2], which will simply show text "paper" and not change the mouse pointer indicating the player that there is no use in clicking here anymore. And hence there isnt Answers[2] even existing, since player cant do anything anymore.
amountofdifferenttexts, had perhaps to do with possibility of displaying different texts based upon which mouse pointer you were using, I think there were two different options for mouse pointer from users point of view. That right click mouse and it would change between "Look" and "use", or something like that. But I am not sure anymore at this point.
Anyway, this how the rooms worked.
I cant quite remember what that first snippet is precisely doing and why.