devolution

Author Topic: Anybody around with experience in LUA ?  (Read 2699 times)

0 Members and 1 Guest are viewing this topic.

Offline Anon21

  • Full Member
  • ***
  • Posts: 244
Anybody around with experience in LUA ?
« on: July 30, 2011, 06:50:36 AM »
Anybody around with experience in LUA? 

I'd like to replace the game script file "MeetTownDefault.script" with an equivalent LUA file "MeetTownDefault.lua" (as practice, with the eventual aim of replacing all script files with lua script files). It's hard going, though, so I could do with help to get started.  I've attached the GameScript version as an image and here's the code that calls it:

Code: [Select]
    string message = "You go out searching around town for any new girls, ";
    message += "and you notice a potential new girl and walk up to her.";
    g_MessageQue.AddToQue(message, 2);
    int v[2] = {0,-1};
    cTrigger* trig = 0;

    DirPath dp;
    string filename;
    cScriptManager sm;
/*
 *    is there a girl specific talk script?
 */
    if(!(trig = girl->m_Triggers.CheckForScript(TRIGGER_MEET, false, v))) {
        // no, so trigger the default one
        dp = DirPath()
            << "Resources" << "Scripts" << "MeetTownDefault.script"
        ;
    }
    else {
        // trigger the girl-specific one
        dp = DirPath()
            << "Resources" << "Characters" << girl->m_Name
            << trig->m_Script
        ;
    }
    eventrunning = true;
    sm.Load(dp, girl);

Offline fires_flair

  • Sr. Member
  • ****
  • Posts: 411
Re: Anybody around with experience in LUA ?
« Reply #1 on: July 30, 2011, 10:58:55 AM »
no experiance, but have you checked out the guild for lua in the topic 'manual'
http://pinkpetal.org/index.php?topic=20.msg7348#msg7348

Offline Anon21

  • Full Member
  • ***
  • Posts: 244
Re: Anybody around with experience in LUA ?
« Reply #2 on: July 30, 2011, 11:24:02 AM »
no experiance, but have you checked out the guild for lua in the topic 'manual'
http://pinkpetal.org/index.php?topic=20.msg7348#msg7348

Yes, but it leaves too many gaps for someone like me with no background knowledge.
(Not to mention only a basic understanding of c++)

There's a bit more you can get by reading the code ( particularly cLuaMenu.cpp ) but
basically I'm just going "Huh?" You see there's only one .lua script actually used in
the game - Intro.lua - and it only uses one function so there's nothing for my
patented "Monkey see, monkey do." approach to programming.

[EDIT] Actually I think it would be better if I kept the current script system mostly
intact but change the format of the .script files to something you can edit with
notepad instead of that horrible script editor.

[EDITx2] What I think we need is the script to be written in XML, and we need a DTD.
This may take some time.

Code: [Select]
<!DOCTYPE wmscript
[
<!ELEMENT dialog (#PCDATA)>
<!ELEMENT init (choicebox,setvar,setvarrandom)>
<!ELEMENT choicebox (choice)>
<!ELEMENT text (#PCDATA)>
<!ELEMENT endscript>
<!ELEMENT restart>
<!ELEMENT setvar (#PCDATA)>
<!ELEMENT setvarrandom (varmin, varmax)>
<!ELEMENT varmin (#PCDATA)>
<!ELEMENT varmax (#PCDATA)>

<!ATTLIST setvar id ID #REQUIRED>
<!ATTLIST setvarrandom id ID #REQUIRED>
<!ATTLIST choicebox id ID #REQUIRED choices CDATA #IMPLIED>

"Dialog ~"
TEXT
"INIT"
"ENDINIT"
"ENDSCRIPT"
"Restart"
"CHOICEBOX ~ ~"
INT 0 65535
INT 0 65535
"TEXT ~"
TEXT
"SetVar ~ ~"
INT 0 19
INT 0 65535
"SetVarRandom ~ ~ ~"
INT 0 19
INT 0 65535
INT 0 65535
"IfVar ~ ~ ~"
INT 0 19
CHOICE 6
"EqualTo"
"LessThan"
"LessOrEqualTo"
"GreaterThan"
"GreaterOrEqualTo"
"NotEqualTo"
INT 0 65535
"Else"
"EndIf"
"ActivateChoice ~"
INT 0 65535
"If Choice from ChoiceBox ~ is ~"
INT 0 65535
INT 0 65535
"SetPlayerSuspicion ~"
INT -100 100
"SetPlayerDisposition ~"
INT -100 100
"ClearGlobalFlag ~"
INT 0 4
"AddCustomerToDungeon ~ ~ ~"
CHOICE 2
"for not paying"
"beating a girl"
INT 0 65535
BOOL
"AddRandomGirlToDungeon ~ ~ ~ ~ ~"
CHOICE 2
"Kidnaped"
"Captured"
INT 0 65535
INT 0 65535
BOOL
BOOL
"Set Global ~ ~"
INT 0 4
INT 0 65535
"SetGirlFlag ~ ~"
INT 0 29
INT 0 254
"AddRandomValueToGold ~ ~"
INT 0 65535
INT 0 65535
"AddManyRandomGirlsToDungeon ~ ~ ~ ~ ~ ~"
INT 0 65535
CHOICE 2
"Kidnaped"
"Captured"
INT 0 65535
INT 0 65535
BOOL
BOOL
"Add Target Girl"
"AdjustTargetGirlStat ~ ~"
CHOICE 32
"CHARISMA"
"HAPPINESS"
"LIBEDO"
"CONSTITUTION"
"INTELLIGENCE"
"CONFIDENCE"
"MANA"
"AGILITY"
"FAME"
"LEVEL"
"ASKPRICE"
"HOUSE"
"EXP"
"AGE"
"OBEDIENCE"
"SPIRIT"
"BEAUTY"
"TIREDNESS"
"HEALTH"
"PCFEAR"
"PCLOVE"
"PCHATE"
"ANAL"
"MAGIC"
"BDSM"
"NORMALSEX"
"BEASTIALITY"
"GROUP"
"LESBIAN"
"SERVICE"
"STRIP"
"COMBAT"
INT -100 100
"PlayerRapeTargetGirl"
"GivePlayerRandomSpecialItem"
"IfPassSkillCheck ~"
CHOICE 10
"ANAL"
"MAGIC"
"BDSM"
"NORMALSEX"
"BEASTIALITY"
"GROUP"
"LESBIAN"
"SERVICE"
"STRIP"
"COMBAT"
"IfPassStatCheck ~"
CHOICE 22
"CHARISMA"
"HAPPINESS"
"LIBEDO"
"CONSTITUTION"
"INTELLIGENCE"
"CONFIDENCE"
"MANA"
"AGILITY"
"FAME"
"LEVEL"
"ASKPRICE"
"HOUSE"
"EXP"
"AGE"
"OBEDIENCE"
"SPIRIT"
"BEAUTY"
"TIREDNESS"
"HEALTH"
"PCFEAR"
"PCLOVE"
"PCHATE"
"IfGirlFlag ~ ~ ~"
INT 0 29
CHOICE 6
"EqualTo"
"LessThan"
"LessOrEqualTo"
"GreaterThan"
"GreaterOrEqualTo"
"NotEqualTo"
INT 0 254
"GameOver"
"IfStat ~ ~ ~"
CHOICE 22
"CHARISMA"
"HAPPINESS"
"LIBEDO"
"CONSTITUTION"
"INTELLIGENCE"
"CONFIDENCE"
"MANA"
"AGILITY"
"FAME"
"LEVEL"
"ASKPRICE"
"HOUSE"
"EXP"
"AGE"
"OBEDIENCE"
"SPIRIT"
"BEAUTY"
"TIREDNESS"
"HEALTH"
"PCFEAR"
"PCLOVE"
"PCHATE"
CHOICE 6
"EqualTo"
"LessThan"
"LessOrEqualTo"
"GreaterThan"
"GreaterOrEqualTo"
"NotEqualTo"
INT 0 255
"IfSkill ~ ~ ~"
CHOICE 10
"ANAL"
"MAGIC"
"BDSM"
"NORMALSEX"
"BEASTIALITY"
"GROUP"
"LESBIAN"
"SERVICE"
"STRIP"
"COMBAT"
CHOICE 6
"EqualTo"
"LessThan"
"LessOrEqualTo"
"GreaterThan"
"GreaterOrEqualTo"
"NotEqualTo"
INT 0 255
"IfHasTrait ~"
TEXT
"Torture Target Girl"
"Scold Target Girl"
"Have Normal Sex"
"Have Beast Sex"
"Have Anal Sex"
"Have Bondage Sex"
"If Not Disobey"
« Last Edit: July 30, 2011, 01:18:54 PM by Anon21 »

Offline LordJerle

  • Full Member
  • ***
  • Posts: 239
Re: Anybody around with experience in LUA ?
« Reply #3 on: August 11, 2011, 01:56:00 PM »
As far as I know, the LUA is incomplete, which is probably why it seems so messy.

Offline DocClox

  • Dev Team
  • *****
  • Posts: 1867
  • Messing Around With Python
Re: Anybody around with experience in LUA ?
« Reply #4 on: August 12, 2011, 10:01:38 AM »
Yeah, the intro script was just a proof of concept job, just to show that it could be done.

There's a pile of stuff in terms of hooks and code samples on the wave, if it's any help.

And if there's only one script in svn, then there's also probably a load of uncommitted code on my hard drive. I'll have a dig and see if I can find what's what.