Alexandria Uptime: 21.04 Days
Total players online: 7



Take the Tour | Site Map

It is currently Wed Apr 24, 2019 2:13 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Tue Apr 16, 2019 3:34 pm 
Offline
Legendary Scripter
Legendary Scripter
User avatar

Joined: 08/14/2003 19:12
Posts: 1457

There is a function with 1 upvalue. using debug.setupvalue on that function changes the upvalue as expected. Now that same function is dumped and reloaded with load and I try to set the upvalue and by all appearances it worked but when I call the function there is an error
Code:
  1. do
  2. local uv=0
  3. local a=function()
  4. uv=uv+1
  5. print(uv)
  6. end
  7. local b=string.dump(a)
  8. debug.setupvalue(a,1,5)
  9. a()
  10. local c=load(b,nil,nil,_G)
  11. print(debug.setupvalue(c,1,20))
  12. print(debug.getupvalue(c,1))
  13. --print(debug.upvaluejoin(c,1,a,1))
  14. c()
  15. end


Using Lua 5.3.1

_________________
EasyUO User Since: November 2001
Registered This User On: April2, 2002

Kal In Ex\'s Script Library
:roll: I am INCOGNITO! :roll:


Last edited by Kal In Ex on Wed Apr 17, 2019 2:08 am, edited 1 time in total.

Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Tue Apr 16, 2019 10:15 pm 
Offline
Legendary Scripter
Legendary Scripter
User avatar

Joined: 07/10/2004 17:11
Posts: 2315

Hey Kal. What are you working on? I can't imagine you're doing anything in game? Unless you're just playing with the newest stuff to see what's possible. Just interested to hear what you're cooking up. Cause I've always liked messing with your scripts. ;) Magnifier, OCR, and plant.txt were a lot of fun while I was learning. Just interested what you're playing with now, and what you're working on?

_________________
Image


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Wed Apr 17, 2019 1:56 am 
Offline
Legendary Scripter
Legendary Scripter
User avatar

Joined: 08/14/2003 19:12
Posts: 1457

This is not for UO. I have been trying to make a script that can save the "state" of lua so that it can be restored later. I know some of the people here know alot about lua and I have been assuming I was making a simple mistake so before doing something like making a bug report I asked here.

_________________
EasyUO User Since: November 2001
Registered This User On: April2, 2002

Kal In Ex\'s Script Library
:roll: I am INCOGNITO! :roll:


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Wed Apr 17, 2019 4:18 am 
Offline
Legendary Scripter
Legendary Scripter
User avatar

Joined: 07/10/2004 17:11
Posts: 2315

? http://lua-users.org/wiki/PlutoLibrary

_________________
Image


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Wed Apr 17, 2019 5:14 am 
Offline
Legendary Scripter
Legendary Scripter
User avatar

Joined: 08/14/2003 19:12
Posts: 1457

Pluto is interesting...

try #1
using load with a function that has been dumped I get a function with upvalues that can be "set" and "joined" using the debug functions... the function fails with errors indicating (to me) its not using the right values.

try #2
using load with a script I get a function with upvalues that can be "set" and "joined" using the debug functions... the function works as expected.

alternatives?
since dumped functions seem buggy I am left with...

alternative #1
all functions (with upvalues) in the "state" that need to be saved must also have the script they were created from saved so that when the function needs to be reloaded it can be reloaded from script.

alternative #2
all functions in the "state" that need to use upvalues (shared values outside the functions definition) will be written as callable tables and use __index to share values. there are performance issues with this but tables are easy "upvalues" to restore. the biggest problem is that a core part of lua has to be avoided =(

_________________
EasyUO User Since: November 2001
Registered This User On: April2, 2002

Kal In Ex\'s Script Library
:roll: I am INCOGNITO! :roll:


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Wed Apr 17, 2019 12:03 pm 
Offline
Legendary Scripter
Legendary Scripter
User avatar

Joined: 07/10/2004 17:11
Posts: 2315

Did you find TamedPluto or Eris? I didn't look around, but TamedPluto is supposedly a better version of Pluto. I haven't played with them, I just did a quick search and found Pluto.

_________________
Image


Top
  ProfileShow poster's scripts in the public script library 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Hosted by CalWeb Internet Services, Inc.