OpenMods / OpenPeripheral

https://openmods.info
MIT License
67 stars 25 forks source link

Terminal glasses User Surface changing when pulling out glasses #144

Closed LIMachi closed 10 years ago

LIMachi commented 10 years ago

well, the problem is that when i pull out my glasses, my user surface id change, and i have no way back to change the objects displayed on my terminal glasses. i tryed multiple ways to avoid that (using the "getAllIds()" per example) bug i can't found a text i have added on my terminal glass 10s before. There is one of the codes i tryed on this problem:

bridge=peripheral.wrap("right")
bridge2=bridge.getUserSurface("LIMachi_")
test=bridge2.addText(1,1,"test1",0xFFFFFF)
tmp1=bridge2.getAllIds()
print("part 1")
write("bridge: ") print(bridge2)
for i,j in pairs(tmp1) do
  write(i) write(": ") print(j)
end
sleep(10) --i pull out my glasses during the sleep command
test.setText("test2")
newBridge=bridge.getUserSurface("LIMachi_")
print("part 2")
print(newBridge)
tmp2=newBridge.getAllIds()
for i,j in pairs(tmp2) do
  write(i) write(": ") print(j)
end

when the program have finished to run, i still have "test1" on the top left corner of my glasses, and there is that printed on the monitor (that mean no item have been found after moving the glasses, but the text is still there, and there is no way to edit it):

part 1 1: 0 bridge: table: 2af7ecaf part 2 table: 18132ce8

PS: sorry if my english is not perfect, i'm frensh, i hope you understand this issue report

NolanSyKinsley commented 10 years ago

Are multiple people using the same terminal glasses bridge? If not, there is no need to set the user surface, and it will just write to the glasses linked with the bridge.

LIMachi commented 10 years ago

no, i tested it on a new placed terminal glasses bridge, and in a single player world

2014-04-05 2:23 GMT+02:00 NolanSyKinsley notifications@github.com:

Are multiple people using the same terminal glasses bridge?

Reply to this email directly or view it on GitHubhttps://github.com/OpenMods/OpenPeripheral/issues/144#issuecomment-39623533 .

NolanSyKinsley commented 10 years ago

This may not be constructive towards the bug solution, but I have a question.

I don't know much about User Surface, what is your reasoning for using it? Seems to me it would only be needed if multiple people are using the same terminal bridge.

I made a mining HUD that updates every 5 seconds and my glasses are unequipped 95% of the time, never had an issue with it. I never had to touch user surface to do so, but am interested why you would need it.

theoriginalbit commented 10 years ago

Yes the main usage is when multiple users are using the same bridge. However the original idea I had behind a user surface was to also give you access to getting a users screen resolution, this is yet to be implemented.

I have confirmed OP's bug and think I've tracked down the problem, attempted a few fixes but to no avail, I'll have to speak to @boq about this more I believe; assuming boq was the one to implement that particular code fragment.

boq commented 10 years ago

I think resetting player's surface when he unequips glasses, dies, logouts, etc. was conscious decision, made in previous version of that code. At least that's what I thought when reimplementing that after split. It makes sense, since there is no better moment to free memory than this.

Therefore, player surfaces should not be used for permanent storage. You can just recreate it every time on event registered_player_join.

Closing that one as wontfix.

theoriginalbit commented 10 years ago

Perhaps we should perform a delete on all the objects then @boq ... elements drawn to the previous surface remain.

boq commented 10 years ago

Oh, I clear that data server side, but not client side. Ok, will fix.