Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 29 30 [31] 32 33 ... 42

Author Topic: [DFHack] Roses' Script Collection Updated 5/4/15  (Read 119896 times)

expwnent

  • Bay Watcher
    • View Profile
Re: [DFHack] Roses' Script Collection
« Reply #450 on: December 07, 2014, 05:09:29 am »

That all looks fine. As a temporary patch, try something like

Code: [Select]
local persist = require 'persist-table'
if ( not persist.GlobalTable.roses ) then
 persist.GlobalTable.roses = {}
end

It's a terrible workaround but if you want something temporary for testing it would help.

For me it would help a lot if you could make a precise list of instructions that cause the error on a new save, including save and load. Maybe print all persist-table instructions as they occur?
Logged

expwnent

  • Bay Watcher
    • View Profile
Re: [DFHack] Roses' Script Collection
« Reply #451 on: December 07, 2014, 07:15:41 am »

Can you uncomment the print statements in persist-table.lua after GlobalTable is defined and post the output when the problem happens?
Logged

expwnent

  • Bay Watcher
    • View Profile
Re: [DFHack] Roses' Script Collection
« Reply #452 on: December 07, 2014, 07:36:09 am »

BUGFIX

Code: [Select]
rawget(value,'mt') == rawget(GlobalTable,mt)
--change this to
rawget(value,'mt') == rawget(GlobalTable,'mt')

That should solve at least part of the problem.
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: [DFHack] Roses' Script Collection
« Reply #453 on: December 07, 2014, 01:26:37 pm »

Quote
1. A modification of the spawn-unit script, with options for relationship (enemy, friendly, civ, pet, tame, etc...), skills, attributes, equipment, and class (for use with the class system).
2. An extension of the inside-only building script, sort of like a building-trigger, with the indoor/outdoor only options, as well as number options (i.e. you can only have one of a particular building), and anything else I can think of.
These sound exciting, how are you coming along?
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

Roses

  • Bay Watcher
    • View Profile
Re: [DFHack] Roses' Script Collection
« Reply #454 on: December 07, 2014, 04:38:18 pm »

BUGFIX

Code: [Select]
rawget(value,'mt') == rawget(GlobalTable,mt)
--change this to
rawget(value,'mt') == rawget(GlobalTable,'mt')

That should solve at least part of the problem.

That seems to have fixed that problem, now I am encountering this error
Code: [Select]
[lua]# persistTable.GlobalTable.roses.ClassTable.SQUIRE.Experience = {'a','b','c'}
C:\Users\Miles\Desktop\My_DF2\hack\lua\persist-table.lua:199: setting value to a
n invalid table
stack traceback:
        [C]: in function 'error'
        C:\Users\Miles\Desktop\My_DF2\hack\lua\persist-table.lua:199: in functio
n '__newindex'
        (interactive):1: in main chunk
        [C]: in function 'safecall'
        C:\Users\Miles\Desktop\My_DF2\hack\lua\dfhack.lua:366: in function 'inte
rpreter'
        C:\Users\Miles\Desktop\My_DF2\hack\scripts/lua.lua:47: in main chunk
        (...tail calls...)
But I think I remember you saying somewhere a while back that you couldn't just set one table equal to another, is that correct? I already have a work around for the above error, but just want to make sure I am not doing something stupid.

Quote
1. A modification of the spawn-unit script, with options for relationship (enemy, friendly, civ, pet, tame, etc...), skills, attributes, equipment, and class (for use with the class system).
2. An extension of the inside-only building script, sort of like a building-trigger, with the indoor/outdoor only options, as well as number options (i.e. you can only have one of a particular building), and anything else I can think of.
These sound exciting, how are you coming along?
Unfortunately I have been super busy with work stuff and haven't had much DF time, and all the time I have had is getting put into fixing the horrible mess that is the class system. I think I got it working again, and now I am migrating over to the new persistent storage system since it is much nicer than the old one. Hopefully over the holidays I will have time to widdle down my to-do list.

EDIT: Question. Is there a way to reset the loaded hack/lua modules (from require 'blah-blah')? Currently any time I have to make a change to one of those scripts I am forced to quit DF and then start it up again.
« Last Edit: December 07, 2014, 06:52:22 pm by Roses »
Logged

Roses

  • Bay Watcher
    • View Profile
Re: [DFHack] Roses' Script Collection
« Reply #455 on: December 07, 2014, 07:49:29 pm »

Edit from above, Question. Is there a way to reset the loaded hack/lua modules (from require 'blah-blah')? Currently any time I have to make a change to one of those scripts I am forced to quit DF and then start it up again.

So I think I am going to have to rewrite a lot more than I thought. It seems the persistant tables aren't storing data as normal tables. That is to say, doing something like, for k,v in pairs(persistTable), I won't get what I want, instead I will get mt, key, and _children.

I have started to try and work with adding _children to the end of the table, but that won't quite give me the same thing.

EDIT: Replacing
Code: [Select]
for k,v in pairs(persistTable.GlobalTable.roses.ClassTable) do
 blah
 blah
 blah
end
with
Code: [Select]
for _,v in pairs(persistTable.GlobalTable.roses.ClassTable._children) do
local k = persistTable.GlobalTable.roses.ClassTable[v]
 blah
 blah
 blah
end

Seems to work...
Logged

expwnent

  • Bay Watcher
    • View Profile
Re: [DFHack] Roses' Script Collection
« Reply #456 on: December 08, 2014, 11:32:13 am »

For technical reasons you have to use ._children to iterate through them. Don't rely on any particular order of the children. I guess I could make it sort them but currently it doesn't.

They're metatables, not tables. Instead of just doing a hashtable lookup they call a function I wrote to do table lookups and insertions. There is a metafunction for pairs and ipairs I think but it's not respected by all builtin Lua functions so it might cause more problems than it helps.

Setting a value to a table is currently not supported. For lists you'll have to do something like table.blah['1'] = 'a', table.blah['2'] = 'b', etc.
Logged

expwnent

  • Bay Watcher
    • View Profile
Re: [DFHack] Roses' Script Collection
« Reply #457 on: December 08, 2014, 11:34:25 am »

Quote
1. A modification of the spawn-unit script, with options for relationship (enemy, friendly, civ, pet, tame, etc...), skills, attributes, equipment, and class (for use with the class system).
2. An extension of the inside-only building script, sort of like a building-trigger, with the indoor/outdoor only options, as well as number options (i.e. you can only have one of a particular building), and anything else I can think of.
These sound exciting, how are you coming along?

Rumrusher says that the current version of spawn.lua works but I haven't tested it myself. Sometime in the next few weeks I plan on reimplementing spawn-unit and making it work.
Logged

expwnent

  • Bay Watcher
    • View Profile
Re: [DFHack] Roses' Script Collection
« Reply #458 on: December 08, 2014, 11:53:46 am »

PS: The "reload" keyword is what you're looking for. Takes the name of a module as an argument. For some reason it requires the module to be loaded first. It might not work with persist-table though because I use some shenanigans there because to detect "inappropriate" tables it has to do pointer equality tests on metatable blah blah technical reasons.
Logged

Roses

  • Bay Watcher
    • View Profile
Re: [DFHack] Roses' Script Collection
« Reply #459 on: December 08, 2014, 05:11:38 pm »

For technical reasons you have to use ._children to iterate through them. Don't rely on any particular order of the children. I guess I could make it sort them but currently it doesn't.

They're metatables, not tables. Instead of just doing a hashtable lookup they call a function I wrote to do table lookups and insertions. There is a metafunction for pairs and ipairs I think but it's not respected by all builtin Lua functions so it might cause more problems than it helps.

Setting a value to a table is currently not supported. For lists you'll have to do something like table.blah['1'] = 'a', table.blah['2'] = 'b', etc.

That's fine, I found a work around that was pretty much the same. I'm trying to think if random ordering would have any effect... I don't think it would.

Quote
1. A modification of the spawn-unit script, with options for relationship (enemy, friendly, civ, pet, tame, etc...), skills, attributes, equipment, and class (for use with the class system).
2. An extension of the inside-only building script, sort of like a building-trigger, with the indoor/outdoor only options, as well as number options (i.e. you can only have one of a particular building), and anything else I can think of.
These sound exciting, how are you coming along?

Rumrusher says that the current version of spawn.lua works but I haven't tested it myself. Sometime in the next few weeks I plan on reimplementing spawn-unit and making it work.

Hmm, maybe I will wait until you re implement spawn-unit, and then make my modifications from there.

PS: The "reload" keyword is what you're looking for. Takes the name of a module as an argument. For some reason it requires the module to be loaded first. It might not work with persist-table though because I use some shenanigans there because to detect "inappropriate" tables it has to do pointer equality tests on metatable blah blah technical reasons.

I thought I tried reload, but maybe I didn't have the name of the module right. Is that run in lua or from the DFHack command line?
Logged

expwnent

  • Bay Watcher
    • View Profile
Re: [DFHack] Roses' Script Collection
« Reply #460 on: December 08, 2014, 05:29:37 pm »

I think it works in Lua. It does need quotes of course.
Logged

Roses

  • Bay Watcher
    • View Profile
Re: [DFHack] Roses' Script Collection
« Reply #461 on: December 09, 2014, 04:20:09 pm »

@Putnam, I have downloaded your fortbent mod in order to do my testing, so far it appears to be in working order. As mentioned earlier, you can keep your classes as defined.
Code: [Select]
[CLASS:BREATH_1]
    [NAME:breath]
    [EXP:15]
    [LEVELS:1]
    [SPELL:WINDY_BULLET_I:AUTO]
    [AUTO_UPGRADE:BREATH_2]
[CLASS:BREATH_2]
    [NAME:breath]
    [EXP:20]
    [LEVELS:1]
    [SPELL:WINDY_BULLET_II:AUTO]
    [AUTO_UPGRADE:BREATH_3]
[CLASS:BREATH_3]
    [NAME:breath]
    [EXP:25]
    [LEVELS:1]
    [SPELL:WINDY_BULLET_III:AUTO]
    [AUTO_UPGRADE:BREATH_4]
[CLASS:BREATH_4]
    [NAME:breath]
    [EXP:30]
    [LEVELS:1]
    [SPELL:WINDY_BULLET_IV:AUTO]
    [AUTO_UPGRADE:BREATH_5]
[CLASS:BREATH_5]
    [NAME:breath]
    [EXP:100]
    [LEVELS:1]
    [SPELL:WINDY_DELAY:AUTO]
    [AUTO_UPGRADE:BREATH_GOD_TIER_1]
Or you can change to the new, more compact system
Code: [Select]
[CLASS:BREATH]
    [NAME:breath]
    [EXP:15:20:25:30:100]
    [LEVELS:5]
    [SPELL:WINDY_BULLET_I:0]
        [SPELL_AUTO_LEARN]
    [SPELL:WINDY_BULLET_II:1]
        [SPELL_AUTO_LEARN]
    [SPELL:WINDY_BULLET_III:2]
        [SPELL_AUTO_LEARN]
    [SPELL:WINDY_BULLET_IV:3]
        [SPELL_AUTO_LEARN]
    [SPELL:WINDY_DELAY:4]
        [SPELL_AUTO_LEARN]
    [AUTO_UPGRADE:BREATH_GOD_TIER]
Your choice, but I will continue to make sure it is backwards compatible

Also, you now how the option of changing the [NAME] to the format [NAME:singular:plural:adjective]. If you leave out adjective (i.e. [NAME:singular:plural] it will use the singular for the adjective. If you leave out both plural and adjective it will use the singular for adjective and the singular+s for plural. (So it would be imputed in the game as breath:breaths:breath)

Again, sorry this has taken me so long, I am planning on uploading it soon, but want to make good and sure I have squashed some of the more egregious errors.

EDIT: You also have the option of replacing the previously learned spells if you wish (i.e. replace WINDY_BULLET_II with WINDY_BULLET_III) by using
Code: [Select]
[CLASS:BREATH]
    [NAME:breath]
    [EXP:15:20:25:30:100]
    [LEVELS:5]
    [SPELL:WINDY_BULLET_I:0]
        [SPELL_AUTO_LEARN]
    [SPELL:WINDY_BULLET_II:1]
        [SPELL_UPGRADE:WINDY_BULLET_I]
        [SPELL_AUTO_LEARN]
    [SPELL:WINDY_BULLET_III:2]
        [SPELL_UPGRADE:WINDY_BULLET_II]
        [SPELL_AUTO_LEARN]
    [SPELL:WINDY_BULLET_IV:3]
        [SPELL_UPGRADE:WINDY_BULLET_III]
        [SPELL_AUTO_LEARN]
    [SPELL:WINDY_DELAY:4]
        [SPELL_AUTO_LEARN]
    [AUTO_UPGRADE:BREATH_GOD_TIER]

EDIT2: @expwnent, everything with the new persistent system seems to be working just fine after I made that one change. It's been a little tough getting used to the metatable thing, but some very easy changes to make it work. Thanks very much for doing this! I am currently writing a little list (mostly for myself, but for anyone else thats interested to) of the table names I am using and what information they are saving. That way if anyone else wants to access anything they can easily see where the information is stored. I prefixed everything with roses so that no one else using the system should overwrite anything I write (i.e. persistTable.GlobalTable.roses.BLAHBLAHBLAH)

EDIT3: I have also added the option to have multiple class files all be read in. So if you would prefer to split up your classes you can, although it is mainly for people to be able to trade their files and not have to worry about copying anything anywhere, just drag and drop. It will look for all files named classes_something.txt (also just plain classes.txt) and read in all the classes. It does not check for duplicates, however, so the user would have to make sure they do not have any duplicates themselves.
« Last Edit: December 09, 2014, 04:50:22 pm by Roses »
Logged

Roses

  • Bay Watcher
    • View Profile
Re: [DFHack] Roses' Script Collection
« Reply #462 on: December 10, 2014, 04:29:16 am »

Alright, I'm stumped. Does add-syndrome not work correctly for syndromes that add a display name? I know it used to, but I can't get it to work now... Everything else is working fine.

EDIT: aaaaaaaaaand never mind, I just needed to unpause the game... Well the class system is now working. I will upload it tomorrow.
« Last Edit: December 10, 2014, 04:34:09 am by Roses »
Logged

Vherid

  • Bay Watcher
  • [CREATURE:SLARK]
    • View Profile
Re: [DFHack] Roses' Script Collection
« Reply #463 on: December 10, 2014, 10:07:40 am »

So out of curiosity, and from my limited understanding of scripts, your projectile experiment gives creatures the ability to do special projectile things, and not items. Like I can't make a machine gun, but I can make a creature who technically wields one forever by giving him this script. Or does it attach to items after all?

Roses

  • Bay Watcher
    • View Profile
Re: [DFHack] Roses' Script Collection
« Reply #464 on: December 10, 2014, 02:59:37 pm »

By combining it with item-trigger you can make it so a weapon you equip gives the unit the interaction needed to use the projectile script.
Logged
Pages: 1 ... 29 30 [31] 32 33 ... 42